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


PHP JeproshopContext::getShopContext方法代码示例

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


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

示例1: getCustomerCartRules

 /**
  * @static
  * @param $lang_id
  * @param $customer_id
  * @param bool $published
  * @param bool $includeGeneric
  * @param bool $inStock
  * @param JeproshopCartModelCart|null $cart
  * @return array
  */
 public static function getCustomerCartRules($lang_id, $customer_id, $published = false, $includeGeneric = true, $inStock = false, JeproshopCartModelCart $cart = null)
 {
     if (!JeproshopCartRuleModelCartRule::isFeaturePublished()) {
         return array();
     }
     $db = JFactory::getDBO();
     $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_cart_rule') . " AS cart_rule LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_lang');
     $query .= " AS cart_rule_lang ON (cart_rule." . $db->quoteName('cart_rule_id') . " = cart_rule_lang." . $db->quoteName('cart_rule_id') . " AND ";
     $query .= "cart_rule_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") WHERE ( cart_rule." . $db->quoteName('customer_id') . " = ";
     $query .= (int) $customer_id . " OR cart_rule.group_restriction = 1 " . ($includeGeneric ? "OR cart_rule." . $db->quoteName('customer_id') . " = 0" : "");
     $query .= ") AND cart_rule.date_from < \"" . date('Y-m-d H:i:s') . "\" AND cart_rule.date_to > \"" . date('Y-m-d H:i:s') . "\"";
     $query .= ($published ? " AND cart_rule" . $db->quoteName('published') . " = 1" : "") . ($inStock ? " AND cart_rule." . $db->quoteName('quantity') . " > 0" : "");
     $db->setQuery($query);
     $result = $db->loadObjectList();
     // Remove cart rule that does not match the customer groups
     $customerGroups = JeproshopCustomerModelCustomer::getGroupsStatic($customer_id);
     foreach ($result as $key => $cart_rule) {
         if ($cart_rule->group_restriction) {
             $query = "SELECT " . $db->quoteName('group_id') . " FROM " . $db->quoteName('#__jeproshop_cart_rule_group') . " WHERE " . $db->quoteName('cart_rule_id') . " = " . (int) $cart_rule->cart_rule_id;
             $db->setQuery($query);
             $cartRuleGroups = $db->loadObjectList();
             foreach ($cartRuleGroups as $cartRuleGroup) {
                 if (in_array($cartRuleGroup->group_id, $customerGroups)) {
                     continue 2;
                 }
             }
             unset($result[$key]);
         }
     }
     foreach ($result as &$cart_rule) {
         if ($cart_rule->quantity_per_user) {
             $quantity_used = JeproshopOrderModelOrder::getCustomerDiscounts((int) $customer_id, (int) $cart_rule->cart_rule_id);
             if (isset($cart) && isset($cart->cart_id)) {
                 $quantity_used += $cart->getDiscountsCustomer((int) $cart_rule->cart_rule_id);
             }
             $cart_rule->quantity_for_user = $cart_rule->quantity_per_user - $quantity_used;
         } else {
             $cart_rule->quantity_for_user = 0;
         }
     }
     unset($cart_rule);
     foreach ($result as $cart_rule) {
         if ($cart_rule->shop_restriction) {
             $query = "SELECT shop_id FROM " . $db->quoteName('#__jeproshop_cart_rule_shop') . " WHERE cart_rule_id = " . (int) $cart_rule->cart_rule_id;
             $db->setQuery($query);
             $cartRuleShops = $db->loadObjectList();
             foreach ($cartRuleShops as $cartRuleShop) {
                 if (JeproshopShopModelShop::isFeatureActive() && $cartRuleShop->shop_id == JeproshopContext::getShopContext()->shop->shop_id) {
                     continue 2;
                 }
             }
             unset($result[$key]);
         }
     }
     // RetroCompatibility with 1.4 discounts
     foreach ($result as &$cart_rule) {
         $cart_rule->value = 0;
         $cart_rule->minimal = JeproshopTools::convertPriceFull($cart_rule->minimum_amount, new JeproshopCurrencyModelCurrency($cart_rule->minimum_amount_currency), JeproshopContext::getContext()->currency);
         $cart_rule->cumulable = !$cart_rule->cart_rule_restriction;
         $cart_rule->discount_type_id = false;
         if ($cart_rule->free_shipping) {
             $cart_rule->discount_type_id = Discount::FREE_SHIPPING;
         } elseif ($cart_rule->reduction_percent > 0) {
             $cart_rule->discount_type_id = Discount::PERCENT;
             $cart_rule->value = $cart_rule->reduction_percent;
         } elseif ($cart_rule->reduction_amount > 0) {
             $cart_rule->discount_type_id = Discount::AMOUNT;
             $cart_rule->value = $cart_rule->reduction_amount;
         }
     }
     return $result;
 }
开发者ID:jeprodev,项目名称:jeproshop,代码行数:82,代码来源:cart.php


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