本文整理汇总了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;
}