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


PHP Carrier::getAvailableCarrierList方法代码示例

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


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

示例1: autoStep

 /**
  * Order process controller
  */
 public function autoStep()
 {
     if ($this->step >= 2 && (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     if ($this->step > 2 && !$this->context->cart->isVirtualCart()) {
         $redirect = false;
         if (count($this->context->cart->getDeliveryOptionList()) == 0) {
             $redirect = true;
         }
         if (!$this->context->cart->isMultiAddressDelivery()) {
             foreach ($this->context->cart->getProducts() as $product) {
                 if (!in_array($this->context->cart->id_carrier, Carrier::getAvailableCarrierList(new Product($product['id_product']), null, $this->context->cart->id_address_delivery))) {
                     $redirect = true;
                     break;
                 }
             }
         }
         if ($redirect) {
             Tools::redirect('index.php?controller=order&step=2');
         }
     }
     $delivery = new Address((int) $this->context->cart->id_address_delivery);
     $invoice = new Address((int) $this->context->cart->id_address_invoice);
     if ($delivery->deleted || $invoice->deleted) {
         if ($delivery->deleted) {
             unset($this->context->cart->id_address_delivery);
         }
         if ($invoice->deleted) {
             unset($this->context->cart->id_address_invoice);
         }
         Tools::redirect('index.php?controller=order&step=1');
     }
 }
开发者ID:carloslastresDev,项目名称:HealthyTaiwan_UsingPrestaShop,代码行数:37,代码来源:OrderController.php

示例2: getDeliveryAddressesWithoutCarriers

 /**
  * Get all the ids of the delivery addresses without carriers
  * 
  * @param bool $return_collection Return a collection
  * 
  * @return array Array of address id or of address object
  */
 public function getDeliveryAddressesWithoutCarriers($return_collection = false)
 {
     $addresses_without_carriers = array();
     foreach ($this->getProducts() as $product) {
         if (!in_array($product['id_address_delivery'], $addresses_without_carriers) && !count(Carrier::getAvailableCarrierList(new Product($product['id_product']), null, $product['id_address_delivery']))) {
             $addresses_without_carriers[] = $product['id_address_delivery'];
         }
     }
     if (!$return_collection) {
         return $addresses_without_carriers;
     } else {
         $addresses_instance_without_carriers = array();
         foreach ($addresses_without_carriers as $id_address) {
             $addresses_instance_without_carriers[] = new Address($id_address);
         }
         return $addresses_instance_without_carriers;
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:25,代码来源:Cart.php

示例3: processChangeProductAddressDelivery

 protected function processChangeProductAddressDelivery()
 {
     if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) {
         return;
     }
     $old_id_address_delivery = (int) Tools::getValue('old_id_address_delivery');
     $new_id_address_delivery = (int) Tools::getValue('new_id_address_delivery');
     if (!count(Carrier::getAvailableCarrierList(new Product($this->id_product), null, $new_id_address_delivery))) {
         $this->ajaxDie(Tools::jsonEncode(array('hasErrors' => true, 'error' => Tools::displayError('It is not possible to deliver this product to the selected address.', false))));
     }
     $this->context->cart->setProductAddressDelivery($this->id_product, $this->id_product_attribute, $old_id_address_delivery, $new_id_address_delivery);
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:12,代码来源:CartController.php

示例4: getPackageList

 public function getPackageList($flush = false)
 {
     static $cache = array();
     if (isset($cache[(int) $this->cart_id . '_' . (int) $this->address_delivery_id]) && $cache[(int) $this->cart_id . '_' . (int) $this->address_delivery_id] !== false && !$flush) {
         return $cache[(int) $this->cart_id . '_' . (int) $this->address_delivery_id];
     }
     $product_list = $this->getProducts();
     // Step 1 : Get product informations (warehouse_list and carrier_list), count warehouse
     // Determine the best warehouse to determine the packages
     // For that we count the number of time we can use a warehouse for a specific delivery address
     $warehouse_count_by_address = array();
     $warehouse_carrier_list = array();
     $stock_management_active = JeproshopSettingModelSetting::getValue('advanced_stock_management');
     foreach ($product_list as &$product) {
         if ((int) $product->address_delivery_id == 0) {
             $product->address_delivery_id = (int) $this->address_delivery_id;
         }
         if (!isset($warehouse_count_by_address[$product->address_delivery_id])) {
             $warehouse_count_by_address[$product->address_delivery_id] = array();
         }
         $product->warehouse_list = array();
         if ($stock_management_active && ((int) $product['advanced_stock_management'] == 1 || Pack::usesAdvancedStockManagement((int) $product->product_id))) {
             $warehouse_list = Warehouse::getProductWarehouseList($product->product_id, $product->roduct_attribute_id, $this->shop_id);
             if (count($warehouse_list) == 0) {
                 $warehouse_list = Warehouse::getProductWarehouseList($product->product_id, $product->roduct_attribute_id);
             }
             // Does the product is in stock ?
             // If yes, get only warehouse where the product is in stock
             $warehouse_in_stock = array();
             $manager = StockManagerFactory::getManager();
             foreach ($warehouse_list as $key => $warehouse) {
                 $product_real_quantities = $manager->getProductRealQuantities($product->product_id, $product->product_attribute_id, array($warehouse->warehouse_id), true);
                 if ($product_real_quantities > 0 || Pack::isPack((int) $product->product_id)) {
                     $warehouse_in_stock[] = $warehouse;
                 }
             }
             if (!empty($warehouse_in_stock)) {
                 $warehouse_list = $warehouse_in_stock;
                 $product->in_stock = true;
             } else {
                 $product->in_stock = false;
             }
         } else {
             //simulate default warehouse
             $warehouse_list = array(0);
             $product->in_stock = StockAvailable::getQuantityAvailableByProduct($product->product_id, $product->product_attribute_id) > 0;
         }
         foreach ($warehouse_list as $warehouse) {
             if (!isset($warehouse_carrier_list[$warehouse->warehouse_id])) {
                 $warehouse_object = new JeproshopWarehouseModelWarehouse($warehouse->warehouse_id);
                 $warehouse_carrier_list[$warehouse->warehouse_id] = $warehouse_object->getCarriers();
             }
             $product->warehouse_list[] = $warehouse->warehouse_id;
             if (!isset($warehouse_count_by_address[$product->address_delivery_id][$warehouse->warehouse_id])) {
                 $warehouse_count_by_address[$product->address_delivery_id][$warehouse->warehouse_id] = 0;
             }
             $warehouse_count_by_address[$product->address_delivery_id][$warehouse->warehouse_id]++;
         }
     }
     unset($product);
     arsort($warehouse_count_by_address);
     // Step 2 : Group product by warehouse
     $grouped_by_warehouse = array();
     foreach ($product_list as &$product) {
         if (!isset($grouped_by_warehouse[$product->address_delivery_id])) {
             $grouped_by_warehouse[$product->address_delivery_id] = array('in_stock' => array(), 'out_of_stock' => array());
         }
         $product->carrier_list = array();
         $warehouse_id = 0;
         foreach ($warehouse_count_by_address[$product->address_delivery_id] as $war_id => $val) {
             if (in_array((int) $war_id, $product->warehouse_list)) {
                 $product->carrier_list = array_merge($product->carrier_list, Carrier::getAvailableCarrierList(new Product($product->product_id), $war_id, $product->address_delivery_id, null, $this));
                 if (!$warehouse_id) {
                     $warehouse_id = (int) $war_id;
                 }
             }
         }
         if (!isset($grouped_by_warehouse[$product->address_delivery_id]['in_stock'][$warehouse_id])) {
             $grouped_by_warehouse[$product->address_delivery_id]['in_stock'][$warehouse_id] = array();
             $grouped_by_warehouse[$product->address_delivery_id]['out_of_stock'][$warehouse_id] = array();
         }
         if (!$this->allow_separated_package) {
             $key = 'in_stock';
         } else {
             $key = $product->in_stock ? 'in_stock' : 'out_of_stock';
         }
         if (empty($product->carrier_list)) {
             $product->carrier_list = array(0);
         }
         $grouped_by_warehouse[$product->address_delivery_id][$key][$warehouse_id][] = $product;
     }
     unset($product);
     // Step 3 : grouped product from grouped_by_warehouse by available carriers
     $grouped_by_carriers = array();
     foreach ($grouped_by_warehouse as $address_delivery_id => $products_in_stock_list) {
         if (!isset($grouped_by_carriers[$address_delivery_id])) {
             $grouped_by_carriers[$address_delivery_id] = array('in_stock' => array(), 'out_of_stock' => array());
         }
         foreach ($products_in_stock_list as $key => $warehouse_list) {
             if (!isset($grouped_by_carriers[$address_delivery_id][$key])) {
//.........这里部分代码省略.........
开发者ID:jeprodev,项目名称:jeproshop,代码行数:101,代码来源:cart.php

示例5: autoStep

 /**
  * Order process controller
  */
 public function autoStep()
 {
     $app = JFactory::getApplication();
     if (($this->current_step == 'address' || $this->current_step == 'delivery' || $this->current_step == 'payment') && (!$this->context->cart->address_delivery_id || !$this->context->cart->address_invoice_id)) {
         $app->redirect('index.php?option=com_jeproshop&view=order&step=summary');
     }
     if (($this->current_step == 'delivery' || $this->current_step == 'payment') && !$this->context->cart->isVirtualCart()) {
         $redirect = false;
         if (count($this->context->cart->getDeliveryOptionList()) == 0) {
             $redirect = true;
         }
         if (!$this->context->cart->isMultiAddressDelivery()) {
             foreach ($this->context->cart->getProducts() as $product) {
                 if (!in_array($this->context->cart->carrier_id, Carrier::getAvailableCarrierList(new Product($product['id_product']), null, $this->context->cart->id_address_delivery))) {
                     $redirect = true;
                     break;
                 }
             }
         }
         if ($redirect) {
             Tools::redirect('index.php?option=com_jeproshop&view=order&step=address');
         }
     }
     $delivery = new JeproshopAddressModelAddress((int) $this->context->cart->address_delivery_id);
     $invoice = new JeproshopAddressModelAddress((int) $this->context->cart->address_invoice_id);
     if ($delivery->deleted || $invoice->deleted) {
         if ($delivery->deleted) {
             unset($this->context->cart->address_delivery_id);
         }
         if ($invoice->deleted) {
             unset($this->context->cart->address_invoice_id);
         }
         $app->redirect('index.php?option=com_jeproshop&view=order&step=summary');
     }
 }
开发者ID:jeprodev,项目名称:jeproshop,代码行数:38,代码来源:view.html.php


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