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


PHP Discount::getValueByCartObj方法代码示例

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


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

示例1: getDiscounts

 /**
  * Return cart discounts
  *
  * @result array Discounts
  */
 public function getDiscounts($lite = false, $refresh = false)
 {
     if (!$this->id) {
         return array();
     }
     // if (!$lite AND !$refresh AND isset(self::$_discounts[$this->id]))
     //     return self::$_discounts[$this->id];
     // if ($lite AND isset(self::$_discountsLite[$this->id]))
     //     return self::$_discountsLite[$this->id];
     $sql = 'SELECT d.*, `id_cart`
     FROM `' . _DB_PREFIX_ . 'cart_discount` c
     LEFT JOIN `' . _DB_PREFIX_ . 'discount` d ON c.`id_discount` = d.`id_discount`
     WHERE `id_cart` = ' . (int) $this->id;
     $result = Db::getInstance()->ExecuteS($sql);
     $products = $this->getProducts();
     foreach ($result as $k => $discount) {
         $categories = Discount::getCategories((int) $discount['id_discount']);
         $in_category = false;
         foreach ($products as $product) {
             if (Product::idIsOnCategoryId((int) $product['id_product'], $categories)) {
                 $in_category = true;
                 break;
             }
         }
         if (!$in_category) {
             unset($result[$k]);
         }
     }
     if ($lite) {
         self::$_discountsLite[$this->id] = $result;
         return $result;
     }
     $total_products_wt = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
     $total_products = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
     $shipping_wt = $this->getOrderShippingCost();
     $shipping = $this->getOrderShippingCost(NULL, false);
     self::$_discounts[$this->id] = array();
     foreach ($result as $row) {
         $discount = new Discount($row['id_discount'], (int) $this->id_lang);
         $row['description'] = $discount->description ? $discount->description : $discount->name;
         $row['value_real'] = $discount->getValueByCartObj(sizeof($result), $total_products_wt, $shipping_wt, $this);
         $row['value_tax_exc'] = $discount->getValueByCartObj(sizeof($result), $total_products, $shipping, $this, false);
         self::$_discounts[$this->id][] = $row;
     }
     return isset(self::$_discounts[$this->id]) ? self::$_discounts[$this->id] : NULL;
 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:51,代码来源:Cart.php


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