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


PHP Customization::getCustomizationWeight方法代码示例

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


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

示例1: getProducts


//.........这里部分代码省略.........
     }
     $sql->select('image_shop.`id_image` id_image, il.`legend`');
     $sql->leftJoin('image_shop', 'image_shop', 'image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $this->id_shop);
     $sql->leftJoin('image_lang', 'il', 'il.`id_image` = image_shop.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang);
     $result = Db::getInstance()->executeS($sql);
     // Reset the cache before the following return, or else an empty cart will add dozens of queries
     $products_ids = array();
     $pa_ids = array();
     if ($result) {
         foreach ($result as $key => $row) {
             $products_ids[] = $row['id_product'];
             $pa_ids[] = $row['id_product_attribute'];
             $specific_price = SpecificPrice::getSpecificPrice($row['id_product'], $this->id_shop, $this->id_currency, $id_country, $this->id_shop_group, $row['cart_quantity'], $row['id_product_attribute'], $this->id_customer, $this->id);
             if ($specific_price) {
                 $reduction_type_row = array('reduction_type' => $specific_price['reduction_type']);
             } else {
                 $reduction_type_row = array('reduction_type' => 0);
             }
             $result[$key] = array_merge($row, $reduction_type_row);
         }
     }
     // Thus you can avoid one query per product, because there will be only one query for all the products of the cart
     Product::cacheProductsFeatures($products_ids);
     Cart::cacheSomeAttributesLists($pa_ids, $this->id_lang);
     $this->_products = array();
     if (empty($result)) {
         return array();
     }
     $ecotax_rate = (double) Tax::getProductEcotaxRate($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $apply_eco_tax = Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX');
     $cart_shop_context = Context::getContext()->cloneContext();
     foreach ($result as &$row) {
         if (isset($row['ecotax_attr']) && $row['ecotax_attr'] > 0) {
             $row['ecotax'] = (double) $row['ecotax_attr'];
         }
         $row['stock_quantity'] = (int) $row['quantity'];
         // for compatibility with 1.2 themes
         $row['quantity'] = (int) $row['cart_quantity'];
         // get the customization weight impact
         $customization_weight = Customization::getCustomizationWeight($row['id_customization']);
         if (isset($row['id_product_attribute']) && (int) $row['id_product_attribute'] && isset($row['weight_attribute'])) {
             $row['weight_attribute'] += $customization_weight;
             $row['weight'] = (double) $row['weight_attribute'];
         } else {
             $row['weight'] += $customization_weight;
         }
         if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
             $address_id = (int) $this->id_address_invoice;
         } else {
             $address_id = (int) $row['id_address_delivery'];
         }
         if (!Address::addressExists($address_id)) {
             $address_id = null;
         }
         if ($cart_shop_context->shop->id != $row['id_shop']) {
             $cart_shop_context->shop = new Shop((int) $row['id_shop']);
         }
         $address = Address::initialize($address_id, true);
         $id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $row['id_product'], $cart_shop_context);
         $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
         $row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, isset($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 6, null, false, false, $row['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $address_id, $specific_price_output, true, true, $cart_shop_context, true, $row['id_customization']);
         $row['price_with_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, isset($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 6, null, false, true, $row['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $address_id, $specific_price_output, true, true, $cart_shop_context, true, $row['id_customization']);
         $row['price'] = $row['price_with_reduction_without_tax'] = Product::getPriceStatic((int) $row['id_product'], false, isset($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 6, null, false, true, $row['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $address_id, $specific_price_output, true, true, $cart_shop_context, true, $row['id_customization']);
         switch (Configuration::get('PS_ROUND_TYPE')) {
             case Order::ROUND_TOTAL:
                 $row['total'] = $row['price_with_reduction_without_tax'] * (int) $row['cart_quantity'];
                 $row['total_wt'] = $row['price_with_reduction'] * (int) $row['cart_quantity'];
                 break;
             case Order::ROUND_LINE:
                 $row['total'] = Tools::ps_round($row['price_with_reduction_without_tax'] * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
                 $row['total_wt'] = Tools::ps_round($row['price_with_reduction'] * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
                 break;
             case Order::ROUND_ITEM:
             default:
                 $row['total'] = Tools::ps_round($row['price_with_reduction_without_tax'], _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
                 $row['total_wt'] = Tools::ps_round($row['price_with_reduction'], _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
                 break;
         }
         $row['price_wt'] = $row['price_with_reduction'];
         $row['description_short'] = Tools::nl2br($row['description_short']);
         // check if a image associated with the attribute exists
         if ($row['id_product_attribute']) {
             $row2 = Image::getBestImageAttribute($row['id_shop'], $this->id_lang, $row['id_product'], $row['id_product_attribute']);
             if ($row2) {
                 $row = array_merge($row, $row2);
             }
         }
         $row['reduction_applies'] = $specific_price_output && (double) $specific_price_output['reduction'];
         $row['quantity_discount_applies'] = $specific_price_output && $row['cart_quantity'] >= (int) $specific_price_output['from_quantity'];
         $row['id_image'] = Product::defineProductImage($row, $this->id_lang);
         $row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
         $row['features'] = Product::getFeaturesStatic((int) $row['id_product']);
         if (array_key_exists($row['id_product_attribute'] . '-' . $this->id_lang, self::$_attributesLists)) {
             $row = array_merge($row, self::$_attributesLists[$row['id_product_attribute'] . '-' . $this->id_lang]);
         }
         $row = Product::getTaxesInformations($row, $cart_shop_context);
         $this->_products[] = $row;
     }
     return $this->_products;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:101,代码来源:Cart.php


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