当前位置: 首页>>代码示例>>PHP>>正文


PHP OrderDetail::createList方法代码示例

本文整理汇总了PHP中OrderDetail::createList方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderDetail::createList方法的具体用法?PHP OrderDetail::createList怎么用?PHP OrderDetail::createList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrderDetail的用法示例。


在下文中一共展示了OrderDetail::createList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateOrder


//.........这里部分代码省略.........
                    $order->total_products_wt = (double) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
                    $order->total_discounts_tax_excl = (double) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
                    $order->total_discounts_tax_incl = (double) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
                    $order->total_discounts = $order->total_discounts_tax_incl;
                    $order->total_shipping_tax_excl = (double) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list);
                    $order->total_shipping_tax_incl = (double) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list);
                    $order->total_shipping = $order->total_shipping_tax_incl;
                    if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
                        $order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
                    }
                    $order->total_wrapping_tax_excl = (double) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
                    $order->total_wrapping_tax_incl = (double) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
                    $order->total_wrapping = $order->total_wrapping_tax_incl;
                    $order->total_paid_tax_excl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), 2);
                    $order->total_paid_tax_incl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), 2);
                    $order->total_paid = $order->total_paid_tax_incl;
                    $order->invoice_date = '0000-00-00 00:00:00';
                    $order->delivery_date = '0000-00-00 00:00:00';
                    // Creating order
                    $result = $order->add();
                    if (!$result) {
                        throw new PrestaShopException('Can\'t save Order');
                    }
                    // Amount paid by customer is not the right one -> Status = payment error
                    // We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
                    // if ($order->total_paid != $order->total_paid_real)
                    // We use number_format in order to compare two string
                    if ($order_status->logable && number_format($cart_total_paid, 2) != number_format($amount_paid, 2)) {
                        $id_order_state = Configuration::get('PS_OS_ERROR');
                    }
                    $order_list[] = $order;
                    // Insert new Order detail list using cart for the current order
                    $order_detail = new OrderDetail(null, null, $this->context);
                    $order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
                    $order_detail_list[] = $order_detail;
                    // Adding an entry in order_carrier table
                    if (!is_null($carrier)) {
                        $order_carrier = new OrderCarrier();
                        $order_carrier->id_order = (int) $order->id;
                        $order_carrier->id_carrier = (int) $id_carrier;
                        $order_carrier->weight = (double) $order->getTotalWeight();
                        $order_carrier->shipping_cost_tax_excl = (double) $order->total_shipping_tax_excl;
                        $order_carrier->shipping_cost_tax_incl = (double) $order->total_shipping_tax_incl;
                        $order_carrier->add();
                    }
                }
            }
            // The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
            if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
                $this->context->country = $context_country;
            }
            // Register Payment only if the order status validate the order
            if ($order_status->logable) {
                // $order is the last order loop in the foreach
                // The method addOrderPayment of the class Order make a create a paymentOrder
                //     linked to the order reference and not to the order id
                if (isset($extra_vars['transaction_id'])) {
                    $transaction_id = $extra_vars['transaction_id'];
                } else {
                    $transaction_id = null;
                }
                if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
                    throw new PrestaShopException('Can\'t save Order Payment');
                }
            }
            // Next !
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:67,代码来源:PaymentModule.php

示例2: validateOrder


//.........这里部分代码省略.........
                     $order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
                 }
                 $order->total_wrapping_tax_excl = (double) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
                 $order->total_wrapping_tax_incl = (double) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
                 $order->total_wrapping = $order->total_wrapping_tax_incl;
                 $order->total_paid_tax_excl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
                 $order->total_paid_tax_incl = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
                 $order->total_paid = $order->total_paid_tax_incl;
                 $order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
                 $order->invoice_date = '0000-00-00 00:00:00';
                 $order->delivery_date = '0000-00-00 00:00:00';
                 if (self::DEBUG_MODE) {
                     PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
                 }
                 // Creating order
                 $result = $order->add();
                 if (!$result) {
                     PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
                     throw new PrestaShopException('Can\'t save Order');
                 }
                 // Amount paid by customer is not the right one -> Status = payment error
                 // We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
                 // if ($order->total_paid != $order->total_paid_real)
                 // We use number_format in order to compare two string
                 if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)) {
                     $id_order_state = Configuration::get('PS_OS_ERROR');
                 }
                 $order_list[] = $order;
                 if (self::DEBUG_MODE) {
                     PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
                 }
                 // Insert new Order detail list using cart for the current order
                 $order_detail = new OrderDetail(null, null, $this->context);
                 $order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
                 $order_detail_list[] = $order_detail;
                 if (self::DEBUG_MODE) {
                     PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
                 }
                 // Adding an entry in order_carrier table
                 if (!is_null($carrier)) {
                     $order_carrier = new OrderCarrier();
                     $order_carrier->id_order = (int) $order->id;
                     $order_carrier->id_carrier = (int) $id_carrier;
                     $order_carrier->weight = (double) $order->getTotalWeight();
                     $order_carrier->shipping_cost_tax_excl = (double) $order->total_shipping_tax_excl;
                     $order_carrier->shipping_cost_tax_incl = (double) $order->total_shipping_tax_incl;
                     $order_carrier->add();
                 }
             }
         }
         // The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
         if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
             $this->context->country = $context_country;
         }
         if (!$this->context->country->active) {
             PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
             throw new PrestaShopException('The order address country is not active.');
         }
         if (self::DEBUG_MODE) {
             PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
         }
         // Register Payment only if the order status validate the order
         if ($order_status->logable) {
             // $order is the last order loop in the foreach
             // The method addOrderPayment of the class Order make a create a paymentOrder
             //     linked to the order reference and not to the order id
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:67,代码来源:PaymentModule.php

示例3: cronOrdersSync

 function cronOrdersSync()
 {
     $orders = $this->client->getOrders(array(7));
     foreach ($orders as $order) {
         $channelOrderId = $order->getId();
         $billingAddress = $order->getBillingAddress();
         $shippingAddress = $order->getShippingAddress();
         if (empty($billingAddress)) {
             continue;
         }
         $id_customer = $this->createPrestashopCustomer($billingAddress, $order->getEmail());
         $lines = $order->getLines();
         $AddressObject = new Address();
         $AddressObject->id_customer = $id_customer;
         $AddressObject->firstname = $billingAddress->getfirstName();
         $AddressObject->lastname = $billingAddress->getlastName();
         $AddressObject->address1 = " " . $billingAddress->getHouseNr();
         $AddressObject->address1 .= " " . $billingAddress->getHouseNrAddition();
         $AddressObject->address1 .= " " . $billingAddress->getStreetName();
         $AddressObject->address1 .= " " . $billingAddress->getZipCode();
         $AddressObject->address1 .= " " . $billingAddress->getCity();
         $AddressObject->city = $billingAddress->getCity();
         $AddressObject->id_customer = $id_customer;
         $AddressObject->id_country = Country::getByIso($billingAddress->getCountryIso());
         $AddressObject->alias = $billingAddress->getcompanyName() != "" ? "Company" : "Home";
         $AddressObject->add();
         $CarrierObject = new Carrier();
         $CarrierObject->delay[1] = "2-4";
         $CarrierObject->active = 1;
         $CarrierObject->name = "ChannelEngine Order";
         $CarrierObject->add();
         $id_carrier = $CarrierObject->id;
         $currency_object = new Currency();
         $default_currency_object = $currency_object->getDefaultCurrency();
         $id_currency = $default_currency_object->id;
         $id_address = $AddressObject->id;
         // Create Cart Object
         $cart = new Cart();
         $cart->id_customer = (int) $id_customer;
         $cart->id_address_delivery = $id_address;
         $cart->id_address_invoice = $id_address;
         $cart->id_lang = 1;
         $cart->id_currency = (int) $id_address;
         $cart->id_carrier = $id_carrier;
         $cart->recyclable = 0;
         $cart->id_shop_group = 1;
         $cart->gift = 0;
         $cart->add();
         if (!empty($lines)) {
             foreach ($lines as $item) {
                 $quantity = $item->getQuantity();
                 if (strpos($item->getmerchantProductNo(), '-') !== false) {
                     $getMerchantProductNo = explode("-", $item->getMerchantProductNo());
                     $cart->updateQty($quantity, $getMerchantProductNo[0], $getMerchantProductNo[1]);
                 } else {
                     $cart->updateQty($quantity, $item->getmerchantProductNo());
                 }
             }
         }
         $cart->update();
         $order_object = new Order();
         $order_object->id_address_delivery = $id_address;
         $order_object->id_address_invoice = $id_address;
         $order_object->id_cart = $cart->id;
         $order_object->id_currency = $id_currency;
         $order_object->id_customer = $id_customer;
         $order_object->id_carrier = $id_carrier;
         $order_object->payment = "ChannelEngine Order";
         $order_object->module = "1";
         $order_object->valid = 1;
         $order_object->total_paid_tax_excl = $order->getTotalInclVat();
         $order_object->total_discounts_tax_incl = 0;
         $order_object->total_paid = $order->getTotalInclVat();
         $order_object->total_paid_real = $order->getTotalInclVat();
         $order_object->total_products = $order->getSubTotalInclVat() - $order->getSubTotalVat();
         $order_object->total_products_wt = $order->getSubTotalInclVat();
         $order_object->total_paid_tax_incl = $order->getSubTotalInclVat();
         $order_object->conversion_rate = 1;
         $order_object->id_shop = 1;
         $order_object->id_lang = 1;
         $order_object->id_shop_group = 1;
         $order_object->secure_key = md5(uniqid(rand(), true));
         $order_id = $order_object->add();
         // Insert new Order detail list using cart for the current order
         $order_detail = new OrderDetail();
         $orderClass = new Order();
         $order_detail->createList($order_object, $cart, 1, $cart->getProducts(), 1);
         $order_detail_list[] = $order_detail;
         // Adding an entry in order_carrier table
         if (!is_null($CarrierObject)) {
             $order_carrier = new OrderCarrier();
             $order_carrier->id_order = (int) $order_object->id;
             $order_carrier->id_carrier = (int) $id_carrier;
             $order_carrier->weight = (double) $order_object->getTotalWeight();
             $order_carrier->shipping_cost_tax_excl = (double) $order_object->total_shipping_tax_excl;
             $order_carrier->shipping_cost_tax_incl = (double) $order_object->total_shipping_tax_incl;
             $order_carrier->add();
         }
         foreach ($lines as $item) {
             $getMerchantProductNo = explode("-", $item->getMerchantProductNo());
//.........这里部分代码省略.........
开发者ID:channelengine,项目名称:prestashop,代码行数:101,代码来源:ChannelEngineModule.php


注:本文中的OrderDetail::createList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。