本文整理汇总了PHP中Order::getByReference方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getByReference方法的具体用法?PHP Order::getByReference怎么用?PHP Order::getByReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order::getByReference方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateReference
public static function generateReference()
{
do {
$reference = strtoupper(Tools::passwdGen(9, 'NO_NUMERIC'));
} while (Order::getByReference($reference));
return $reference;
}
示例2: postProcess
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('submitGuestTracking') || Tools::isSubmit('submitTransformGuestToCustomer')) {
// These lines are here for retrocompatibility with old theme
$id_order = Tools::getValue('id_order');
$order_collection = array();
if ($id_order) {
if (is_numeric($id_order)) {
$order = new Order((int) $id_order);
if (Validate::isLoadedObject($order)) {
$order_collection = Order::getByReference($order->reference);
}
} else {
$order_collection = Order::getByReference($id_order);
}
}
// Get order reference, ignore package reference (after the #, on the order reference)
$order_reference = current(explode('#', Tools::getValue('order_reference')));
// Ignore $result_number
if (!empty($order_reference)) {
$order_collection = Order::getByReference($order_reference);
}
$email = Tools::getValue('email');
if (empty($order_reference) && empty($id_order)) {
$this->errors[] = Tools::displayError('Please provide your order\'s reference number.');
} elseif (empty($email)) {
$this->errors[] = Tools::displayError('Please provide a valid email address.');
} elseif (!Validate::isEmail($email)) {
$this->errors[] = Tools::displayError('Please provide a valid email address.');
} elseif (!Customer::customerExists($email, false, false)) {
$this->errors[] = Tools::displayError('There is no account associated with this email address.');
} elseif (Customer::customerExists($email, false, true)) {
$this->errors[] = Tools::displayError('This page is for guest accounts only. Since your guest account has already been transformed into a customer account, you can no longer view your order here. Please log in to your customer account to view this order');
$this->context->smarty->assign('show_login_link', true);
} elseif (!count($order_collection)) {
$this->errors[] = Tools::displayError('Invalid order reference');
} elseif (!$order_collection->getFirst()->isAssociatedAtGuest($email)) {
$this->errors[] = Tools::displayError('Invalid order reference');
} else {
$this->assignOrderTracking($order_collection);
if (Tools::isSubmit('submitTransformGuestToCustomer')) {
$customer = new Customer((int) $order->id_customer);
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('Invalid customer');
} elseif (!Tools::getValue('password')) {
$this->errors[] = Tools::displayError('Invalid password.');
} elseif (!$customer->transformToCustomer($this->context->language->id, Tools::getValue('password'))) {
// @todo clarify error message
$this->errors[] = Tools::displayError('An error occurred while transforming a guest into a registered customer.');
} else {
$this->context->smarty->assign('transformSuccess', true);
}
}
}
}
}
示例3: changeOrderStatus
public function changeOrderStatus($result_order)
{
$orders = Order::getByReference($result_order);
$isOk = true;
if ($orders) {
foreach ($orders as $order) {
$isOk &= $this->changeOrderStatusSub($order->id);
}
}
return $isOk;
}
示例4: displayMain
public function displayMain()
{
global $smarty, $link, $cookie;
if (!$cookie->logged) {
Tools::redirect($link->getPage('LoginView'));
}
$user = new User((int) $cookie->id_user);
if ($reference = Tools::getRequest('reference')) {
$order = Order::getByReference($reference);
$smarty->assign(array('products' => $order->cart->getProducts(), 'h_order' => $order));
}
$smarty->assign(array('orders' => $user->getOrders(), 'DISPLAY_LEFT' => Module::hookBlock(array('myaccount'))));
return $smarty->fetch('my-orders.tpl');
}
示例5: getOrder
protected function getOrder()
{
$id_order = false;
if (!is_numeric($reference = Tools::getValue('id_order'))) {
$reference = ltrim($reference, '#');
$orders = Order::getByReference($reference);
if ($orders) {
foreach ($orders as $order) {
$id_order = $order->id;
break;
}
}
} else {
$id_order = Tools::getValue('id_order');
}
return (int) $id_order;
}
示例6: postProcess
public function postProcess()
{
$this->context = Context::getContext();
$this->query = trim(Tools::getValue('bo_query'));
$searchType = (int) Tools::getValue('bo_search_type');
/* Handle empty search field */
if (!empty($this->query)) {
if (!$searchType && strlen($this->query) > 1) {
$this->searchFeatures();
}
/* Product research */
if (!$searchType || $searchType == 1) {
/* Handle product ID */
if ($searchType == 1 && (int) $this->query && Validate::isUnsignedInt((int) $this->query)) {
if (($product = new Product($this->query)) && Validate::isLoadedObject($product)) {
Tools::redirectAdmin('index.php?tab=AdminProducts&id_product=' . (int) $product->id . '&addproduct' . '&token=' . Tools::getAdminTokenLite('AdminProducts'));
}
}
/* Normal catalog search */
$this->searchCatalog();
}
/* Customer */
if (!$searchType || $searchType == 2 || $searchType == 6) {
if (!$searchType || $searchType == 2) {
/* Handle customer ID */
if ($searchType && (int) $this->query && Validate::isUnsignedInt((int) $this->query)) {
if (($customer = new Customer($this->query)) && Validate::isLoadedObject($customer)) {
Tools::redirectAdmin('index.php?tab=AdminCustomers&id_customer=' . (int) $customer->id . '&viewcustomer' . '&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id));
}
}
/* Normal customer search */
$this->searchCustomer();
}
if ($searchType == 6) {
$this->searchIP();
}
}
/* Order */
if (!$searchType || $searchType == 3) {
if (Validate::isUnsignedInt(trim($this->query)) && (int) $this->query && ($order = new Order((int) $this->query)) && Validate::isLoadedObject($order)) {
if ($searchType == 3) {
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order=' . (int) $order->id . '&vieworder' . '&token=' . Tools::getAdminTokenLite('AdminOrders'));
} else {
$row = get_object_vars($order);
$row['id_order'] = $row['id'];
$customer = $order->getCustomer();
$row['customer'] = $customer->firstname . ' ' . $customer->lastname;
$order_state = $order->getCurrentOrderState();
$row['osname'] = $order_state->name[$this->context->language->id];
$this->_list['orders'] = array($row);
}
} else {
$orders = Order::getByReference($this->query);
$nb_orders = count($orders);
if ($nb_orders == 1 && $searchType == 3) {
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order=' . (int) $orders[0]->id . '&vieworder' . '&token=' . Tools::getAdminTokenLite('AdminOrders'));
} elseif ($nb_orders) {
$this->_list['orders'] = array();
foreach ($orders as $order) {
$row = get_object_vars($order);
$row['id_order'] = $row['id'];
$customer = $order->getCustomer();
$row['customer'] = $customer->firstname . ' ' . $customer->lastname;
$order_state = $order->getCurrentOrderState();
$row['osname'] = $order_state->name[$this->context->language->id];
$this->_list['orders'][] = $row;
}
} elseif ($searchType == 3) {
$this->errors[] = Tools::displayError('No order was found with this ID:') . ' ' . Tools::htmlentitiesUTF8($this->query);
}
}
}
/* Invoices */
if ($searchType == 4) {
if (Validate::isOrderInvoiceNumber($this->query) && ($invoice = OrderInvoice::getInvoiceByNumber($this->query))) {
Tools::redirectAdmin($this->context->link->getAdminLink('AdminPdf') . '&submitAction=generateInvoicePDF&id_order=' . (int) $invoice->id_order);
}
$this->errors[] = Tools::displayError('No invoice was found with this ID:') . ' ' . Tools::htmlentitiesUTF8($this->query);
}
/* Cart */
if ($searchType == 5) {
if ((int) $this->query && Validate::isUnsignedInt((int) $this->query) && ($cart = new Cart($this->query)) && Validate::isLoadedObject($cart)) {
Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart=' . (int) $cart->id . '&viewcart' . '&token=' . Tools::getAdminToken('AdminCarts' . (int) Tab::getIdFromClassName('AdminCarts') . (int) $this->context->employee->id));
}
$this->errors[] = Tools::displayError('No cart was found with this ID:') . ' ' . Tools::htmlentitiesUTF8($this->query);
}
/* IP */
// 6 - but it is included in the customer block
/* Module search */
if (!$searchType || $searchType == 7) {
/* Handle module name */
if ($searchType == 7 && Validate::isModuleName($this->query) and ($module = Module::getInstanceByName($this->query)) && Validate::isLoadedObject($module)) {
Tools::redirectAdmin('index.php?tab=AdminModules&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=' . ucfirst($module->name) . '&token=' . Tools::getAdminTokenLite('AdminModules'));
}
/* Normal catalog search */
$this->searchModule();
}
}
$this->display = 'view';
}
示例7: validateOrder
public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
{
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
}
if (!isset($this->context)) {
$this->context = Context::getContext();
}
$this->context->cart = new Cart($id_cart);
$this->context->customer = new Customer($this->context->cart->id_customer);
// The tax cart is loaded before the customer so re-cache the tax calculation method
$this->context->cart->setTaxCalculationMethod();
$this->context->language = new Language($this->context->cart->id_lang);
$this->context->shop = $shop ? $shop : new Shop($this->context->cart->id_shop);
ShopUrl::resetMainDomainCache();
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$context_country = $this->context->country;
}
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
if (!Validate::isLoadedObject($order_status)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t load Order status');
}
if (!$this->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
// Does order already exists ?
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
// For each package, generate an order
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$package_list = $this->context->cart->getPackageList();
$cart_delivery_option = $this->context->cart->getDeliveryOption();
// If some delivery options are not defined, or not valid, use the first valid option
foreach ($delivery_option_list as $id_address => $package) {
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
foreach ($package as $key => $val) {
$cart_delivery_option[$id_address] = $key;
break;
}
}
}
$order_list = array();
$order_detail_list = array();
do {
$reference = Order::generateReference();
} while (Order::getByReference($reference)->count());
$this->currentOrderReference = $reference;
$order_creation_failed = false;
$cart_total_paid = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
foreach ($cart_delivery_option as $id_address => $key_carriers) {
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
foreach ($data['package_list'] as $id_package) {
// Rewrite the id_warehouse
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
}
}
}
// Make sure CartRule caches are empty
CartRule::cleanCache();
$cart_rules = $this->context->cart->getCartRules();
foreach ($cart_rules as $cart_rule) {
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
if ($error = $rule->checkValidity($this->context, true, true)) {
$this->context->cart->removeCartRule((int) $rule->id);
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
}
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
} else {
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
}
}
}
}
foreach ($package_list as $id_address => $packageByAddress) {
foreach ($packageByAddress as $id_package => $package) {
$order = new Order();
$order->product_list = $package['product_list'];
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$address = new Address($id_address);
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
if (!$this->context->country->active) {
throw new PrestaShopException('The delivery address country is not active.');
}
}
$carrier = null;
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
$order->id_carrier = (int) $carrier->id;
//.........这里部分代码省略.........
示例8: findPurchasedItems
/**
* Finds purchased items for the order.
*
* @param Context $context the context.
* @param Order $order the order object.
* @return NostoTaggingOrderPurchasedItem[] the purchased items.
*/
protected function findPurchasedItems(Context $context, Order $order)
{
$purchased_items = array();
$currency = new Currency($order->id_currency);
if (!Validate::isLoadedObject($currency)) {
return $purchased_items;
}
$products = array();
$total_discounts_tax_incl = 0;
$total_shipping_tax_incl = 0;
$total_wrapping_tax_incl = 0;
$total_gift_tax_incl = 0;
// Cart rules and split orders are available from prestashop 1.5 onwards.
if (_PS_VERSION_ >= '1.5') {
// One order can be split into multiple orders, so we need to combine their data.
$order_collection = Order::getByReference($order->reference);
foreach ($order_collection as $item) {
/** @var $item Order */
$products = array_merge($products, $item->getProducts());
$total_discounts_tax_incl = Tools::ps_round($total_discounts_tax_incl + $item->total_discounts_tax_incl, 2);
$total_shipping_tax_incl = Tools::ps_round($total_shipping_tax_incl + $item->total_shipping_tax_incl, 2);
$total_wrapping_tax_incl = Tools::ps_round($total_wrapping_tax_incl + $item->total_wrapping_tax_incl, 2);
}
// We need the cart rules used for the order to check for gift products and free shipping.
// The cart is the same even if the order is split into many objects.
$cart = new Cart($order->id_cart);
if (Validate::isLoadedObject($cart)) {
$cart_rules = (array) $cart->getCartRules();
} else {
$cart_rules = array();
}
$gift_products = array();
foreach ($cart_rules as $cart_rule) {
if ((int) $cart_rule['gift_product']) {
foreach ($products as $key => &$product) {
if (empty($product['gift']) && (int) $product['product_id'] === (int) $cart_rule['gift_product'] && (int) $product['product_attribute_id'] === (int) $cart_rule['gift_product_attribute']) {
$product['product_quantity'] = (int) $product['product_quantity'];
$product['product_quantity']--;
if (!($product['product_quantity'] > 0)) {
unset($products[$key]);
}
$total_gift_tax_incl = Tools::ps_round($total_gift_tax_incl + $product['product_price_wt'], 2);
$gift_product = $product;
$gift_product['product_quantity'] = 1;
$gift_product['product_price_wt'] = 0;
$gift_product['gift'] = true;
$gift_products[] = $gift_product;
break;
// One gift product per cart rule
}
}
unset($product);
}
}
$items = array_merge($products, $gift_products);
} else {
$products = $order->getProducts();
$total_discounts_tax_incl = $order->total_discounts;
$total_shipping_tax_incl = $order->total_shipping;
$total_wrapping_tax_incl = $order->total_wrapping;
$items = $products;
}
$id_lang = (int) $context->language->id;
foreach ($items as $item) {
$p = new Product($item['product_id'], false, $context->language->id);
if (Validate::isLoadedObject($p)) {
$product_name = $p->name;
$id_attribute = (int) $item['product_attribute_id'];
$attribute_combinations = $this->getProductAttributeCombinationsById($p, $id_attribute, $id_lang);
if (!empty($attribute_combinations)) {
$attribute_combination_names = array();
foreach ($attribute_combinations as $attribute_combination) {
$attribute_combination_names[] = $attribute_combination['attribute_name'];
}
if (!empty($attribute_combination_names)) {
$product_name .= ' (' . implode(', ', $attribute_combination_names) . ')';
}
}
$purchased_item = new NostoTaggingOrderPurchasedItem();
$purchased_item->setProductId((int) $p->id);
$purchased_item->setQuantity((int) $item['product_quantity']);
$purchased_item->setName((string) $product_name);
$purchased_item->setUnitPrice(Nosto::helper('price')->format($item['product_price_wt']));
$purchased_item->setCurrencyCode((string) $currency->iso_code);
$purchased_items[] = $purchased_item;
}
}
if ($this->include_special_items && !empty($purchased_items)) {
// Add special items for discounts, shipping and gift wrapping.
if ($total_discounts_tax_incl > 0) {
// Subtract possible gift product price from total as gifts are tagged with price zero (0).
$total_discounts_tax_incl = Tools::ps_round($total_discounts_tax_incl - $total_gift_tax_incl, 2);
if ($total_discounts_tax_incl > 0) {
//.........这里部分代码省略.........
示例9: validateOrder
/**
* Validate an order in database
* Function called from a payment module
*
* @param integer $id_cart Value
* @param integer $id_order_state Value
* @param float $amount_paid Amount really paid by customer (in the default currency)
* @param string $payment_method Payment method (eg. 'Credit card')
* @param string $message Message to attach to order
*/
public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown',
$message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false,
$secure_key = false, Shop $shop = null)
{
$this->context->cart = new Cart($id_cart);
$this->context->customer = new Customer($this->context->cart->id_customer);
$this->context->language = new Language($this->context->cart->id_lang);
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
ShopUrl::resetMainDomainCache();
$id_currency = $currency_special ? (int)$currency_special : (int)$this->context->cart->id_currency;
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
$context_country = $this->context->country;
$order_status = new OrderState((int)$id_order_state, (int)$this->context->language->id);
if (!Validate::isLoadedObject($order_status))
throw new PrestaShopException('Can\'t load Order status');
if (!$this->active)
die(Tools::displayError());
// Does order already exists ?
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false)
{
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key)
die(Tools::displayError());
// For each package, generate an order
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$package_list = $this->context->cart->getPackageList();
$cart_delivery_option = $this->context->cart->getDeliveryOption();
// If some delivery options are not defined, or not valid, use the first valid option
foreach ($delivery_option_list as $id_address => $package)
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package))
foreach ($package as $key => $val)
{
$cart_delivery_option[$id_address] = $key;
break;
}
$order_list = array();
$order_detail_list = array();
do
$reference = Order::generateReference();
while(Order::getByReference($reference)->count());
$this->currentOrderReference = $reference;
$order_creation_failed = false;
$cart_total_paid = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
foreach ($cart_delivery_option as $id_address => $key_carriers)
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
foreach ($data['package_list'] as $id_package)
{
// Rewrite the id_warehouse
$package_list[$id_address][$id_package]['id_warehouse'] = (int)$this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int)$id_carrier);
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
}
// Make sure CarRule caches are empty
CartRule::cleanCache();
foreach ($package_list as $id_address => $packageByAddress)
foreach ($packageByAddress as $id_package => $package)
{
$order = new Order();
$order->product_list = $package['product_list'];
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery')
{
$address = new Address($id_address);
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
}
$carrier = null;
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier']))
{
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
$order->id_carrier = (int)$carrier->id;
$id_carrier = (int)$carrier->id;
}
else
{
$order->id_carrier = 0;
$id_carrier = 0;
}
$order->id_customer = (int)$this->context->cart->id_customer;
//.........这里部分代码省略.........
示例10: ajaxCall
public function ajaxCall()
{
if (Tools::getIsset('rangargs')) {
$reference = Tools::getValue('rangargs');
$orders = Order::getByReference($reference);
if ($orders) {
$isOK = true;
foreach ($orders as $obj) {
$status = OrderHistory::getLastOrderState($obj->id);
if ($status->id != Configuration::get('PS_OS_PAYMENT')) {
$isOK &= false;
break;
}
}
if ($isOK) {
die(Tools::jsonEncode(array('status' => 1)));
}
}
}
sleep(1);
die(Tools::jsonEncode(array('status' => 0, 'id_order' => $reference, 'id' => $status->id)));
}
示例11: ajaxProcessSaveOrder
//.........这里部分代码省略.........
$customer->firstname = Tools::getValue('firstname');
$customer->lastname = Tools::getValue('lastname');
$customer->email = Tools::getValue('email');
$customer->phone = Tools::getValue('phone');
$customer->id_gender = Tools::getValue('id_gender');
$customer->id_shop = (int) Context::getContext()->shop->id;
$customer->update();
$addresses = $customer->getAddresses((int) Context::getContext()->language->id);
if (empty($addresses)) {
$customer->id_address_delivery = $customer->id_address_invoice = 0;
} else {
$customer->id_address_delivery = $addresses[0]['id_address'];
$customer->id_address_invoice = $addresses[0]['id_address'];
$address = new Address($addresses[0]['id_address'], (int) Context::getContext()->language->id);
$address->firstname = $customer->firstname;
$address->lastname = $customer->lastname;
$address->phone = $customer->phone;
$address->phone_mobile = $customer->phone;
$address->update();
}
}
$id_order = (int) Tools::getValue('id_order');
$feature_duration = Configuration::get('APH_FEATURE_DURATION');
$services_duration = json_decode(Configuration::get('APH_SERVICES_DURATION'), true);
$reservation_offline_status = Configuration::get('APH_RESERVATION_OFFLINE_STATUS');
// always add taxes even if there are not displayed to the customer
$use_taxes = true;
// Total method
$total_method = Cart::BOTH_WITHOUT_SHIPPING;
//TODO ajaxProcessAddProductOnOrder() in AdminOrdersController
if ($id_order < 1) {
do {
$reference = Order::generateReference();
} while (Order::getByReference($reference)->count());
$order = new Order();
$order->id_customer = (int) $customer->id;
$order->secure_key = $customer->secure_key;
$order->id_address_invoice = $customer->id_address_delivery;
$order->id_address_delivery = $customer->id_address_invoice;
$order->id_currency = (int) Context::getContext()->currency->id;
$order->id_lang = (int) Context::getContext()->language->id;
$order->reference = $reference;
$order->id_shop = (int) Context::getContext()->shop->id;
$order->id_shop_group = (int) Context::getContext()->shop->id_shop_group;
$order->id_cart = 0;
$order->id_carrier = 0;
$order->payment = 'Pagamento alla consegna';
$order->module = 'cashondelivery';
$order->total_paid = 0;
$order->total_paid_real = 0;
$order->total_products = 0;
$order->total_products_wt = 0;
$order->conversion_rate = 1;
$order->delivery_number = 1;
$order->delivery_date = $delivery_date . ' ' . $delivery_time_from;
$order->current_state = $reservation_offline_status;
if ($order->validateFields(false, true) !== true) {
PrestaShopLogger::addLog('AphCalendar::saveOrder - Fields of order not valid', 1, null, 'AphCalendar', 0, true);
die(Tools::jsonEncode(array('result' => false, 'error' => 'Si e\' verificato un problema durante la creazione dell\'appuntamento. Prego riprovare.')));
}
$result = $order->add();
if (!$result) {
PrestaShopLogger::addLog('AphCalendar::saveOrder - Order is about to be added', 1, null, 'AphCalendar', 0, true);
die(Tools::jsonEncode(array('result' => false, 'error' => 'Si e\' verificato un problema durante la creazione dell\'appuntamento. Prego riprovare.')));
}
// Create new cart