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


PHP CartRule::isFeatureActive方法代码示例

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


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

示例1: hookFooter

 public function hookFooter($params)
 {
     if (!$this->isCached('blockmyaccountfooter.tpl', $this->getCacheId())) {
         $this->smarty->assign(array('voucherAllowed' => CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'), 'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlockfooter')));
     }
     return $this->display(__FILE__, 'blockmyaccountfooter.tpl', $this->getCacheId());
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:7,代码来源:blockmyaccountfooter.php

示例2: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $has_address = $this->context->customer->getAddresses($this->context->language->id);
     $this->context->smarty->assign(array('has_customer_an_address' => empty($has_address), 'voucherAllowed' => (int) CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN')));
     $this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('displayCustomerAccount'));
     $this->setTemplate(_PS_THEME_DIR_ . 'my-account.tpl');
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:12,代码来源:MyAccountController.php

示例3: hookDisplayLeftColumn

 public function hookDisplayLeftColumn($params)
 {
     if (!$this->context->customer->isLogged()) {
         return false;
     }
     $this->smarty->assign(array('voucherAllowed' => CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'), 'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlock')));
     return $this->display(__FILE__, $this->name . '.tpl');
 }
开发者ID:evgrishin,项目名称:mh16014,代码行数:8,代码来源:blockmyaccount.php

示例4: _assignSummaryInformations

 protected function _assignSummaryInformations()
 {
     $summary = $this->context->cart->getSummaryDetails();
     $customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
     // override customization tax rate with real tax (tax rules)
     if ($customizedDatas) {
         foreach ($summary['products'] as &$productUpdate) {
             $productId = (int) isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id'];
             $productAttributeId = (int) isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id'];
             if (isset($customizedDatas[$productId][$productAttributeId])) {
                 $productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             }
         }
         Product::addCustomizationPrice($summary['products'], $customizedDatas);
     }
     $cart_product_context = Context::getContext()->cloneContext();
     foreach ($summary['products'] as $key => &$product) {
         $product['quantity'] = $product['cart_quantity'];
         // for compatibility with 1.2 themes
         if ($cart_product_context->shop->id != $product['id_shop']) {
             $cart_product_context->shop = new Shop((int) $product['id_shop']);
         }
         $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], _PS_PRICE_COMPUTE_PRECISION_, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
         /**
          * ABU edit: variable is_discount set à 1 à tord, calcul foireux de presta
          * @bugfix: https://github.com/PrestaShop/PrestaShop/commit/379e28b341730ea95c0b2d6567817305ea841b23
          * @perso: soustraction de l'ecotax au price_without_specific_price @else
          */
         if (Product::getTaxCalculationMethod()) {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
         } else {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'] - $product['ecotax'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
         }
     }
     // Get available cart rules and unset the cart rules already in the cart
     $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
     $cart_cart_rules = $this->context->cart->getCartRules();
     foreach ($available_cart_rules as $key => $available_cart_rule) {
         if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], CartRule::BO_ORDER_CODE_PREFIX) === 0) {
             unset($available_cart_rules[$key]);
             continue;
         }
         foreach ($cart_cart_rules as $cart_cart_rule) {
             if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
                 unset($available_cart_rules[$key]);
                 continue 2;
             }
         }
     }
     $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
     $this->context->smarty->assign($summary);
     $this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
     $this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
 }
开发者ID:ecSta,项目名称:prestanight,代码行数:56,代码来源:ParentOrderController.php

示例5: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0));
     $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1));
     $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive());
     $blockmanufacturer = Module::getInstanceByName('blockmanufacturer');
     $blocksupplier = Module::getInstanceByName('blocksupplier');
     $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active);
     $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active);
     $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS'));
     $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP'));
     $this->setTemplate(_PS_THEME_DIR_ . 'sitemap.tpl');
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:18,代码来源:SitemapController.php

示例6: getWidgetVariables

 public function getWidgetVariables($hookName = null, array $configuration = [])
 {
     $link = $this->context->link;
     $my_account_urls = array(0 => array('title' => $this->l('Orders'), 'url' => $link->getPageLink('history', true)), 2 => array('title' => $this->l('Credit slips'), 'url' => $link->getPageLink('order-slip', true)), 3 => array('title' => $this->l('Addresses'), 'url' => $link->getPageLink('addresses', true)), 4 => array('title' => $this->l('Personal info'), 'url' => $link->getPageLink('identity', true)));
     if ((int) Configuration::get('PS_ORDER_RETURN')) {
         $my_account_urls[1] = array('title' => $this->l('Merchandise returns'), 'url' => $link->getPageLink('order-follow', true));
     }
     if (CartRule::isFeatureActive()) {
         $my_account_urls[5] = array('title' => $this->l('Vouchers'), 'url' => $link->getPageLink('discount', true));
     }
     // Sort Account links base in his title, keeping the keys
     asort($my_account_urls);
     return array('my_account_urls' => $my_account_urls, 'logout_url' => $link->getPageLink('index', true, null, "mylogout"));
 }
开发者ID:prestashop,项目名称:ps_customeraccountlinks,代码行数:14,代码来源:ps_customeraccountlinks.php

示例7: initContent

 public function initContent()
 {
     parent::initContent();
     if ($orders = Order::getCustomerOrders($this->context->customer->id)) {
         foreach ($orders as &$order) {
             $myOrder = new Order((int) $order['id_order']);
             if (Validate::isLoadedObject($myOrder)) {
                 $order['virtual'] = $myOrder->isVirtual(false);
             }
         }
     }
     $has_address = $this->context->customer->getAddresses($this->context->language->id);
     $this->context->smarty->assign(array('orders' => $orders, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), 'slowValidation' => Tools::isSubmit('slowvalidation'), 'has_customer_an_address' => empty($has_address), 'voucherAllowed' => (int) CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN')));
     $this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('displayCustomerAccount'));
     $this->setTemplate(_PS_THEME_DIR_ . 'my-account.tpl');
 }
开发者ID:acreno,项目名称:pm-ps,代码行数:16,代码来源:MyAccountController.php

示例8: _assignSummaryInformations

 protected function _assignSummaryInformations()
 {
     $summary = $this->context->cart->getSummaryDetails();
     $customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
     // override customization tax rate with real tax (tax rules)
     if ($customizedDatas) {
         foreach ($summary['products'] as &$productUpdate) {
             $productId = (int) (isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id']);
             $productAttributeId = (int) (isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id']);
             if (isset($customizedDatas[$productId][$productAttributeId])) {
                 $productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             }
         }
         Product::addCustomizationPrice($summary['products'], $customizedDatas);
     }
     $cart_product_context = Context::getContext()->cloneContext();
     foreach ($summary['products'] as $key => &$product) {
         $product['quantity'] = $product['cart_quantity'];
         // for compatibility with 1.2 themes
         if ($cart_product_context->shop->id != $product['id_shop']) {
             $cart_product_context->shop = new Shop((int) $product['id_shop']);
         }
         $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], 2, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
         if (Product::getTaxCalculationMethod()) {
             $product['is_discounted'] = $product['price_without_specific_price'] != $product['price'];
         } else {
             $product['is_discounted'] = $product['price_without_specific_price'] != $product['price_wt'];
         }
     }
     // Get available cart rules and unset the cart rules already in the cart
     $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
     $cart_cart_rules = $this->context->cart->getCartRules();
     foreach ($available_cart_rules as $key => $available_cart_rule) {
         if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], 'BO_ORDER_') === 0) {
             unset($available_cart_rules[$key]);
             continue;
         }
         foreach ($cart_cart_rules as $cart_cart_rule) {
             if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
                 unset($available_cart_rules[$key]);
                 continue 2;
             }
         }
     }
     $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
     $this->context->smarty->assign($summary);
     $this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
     $this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:49,代码来源:ParentOrderController.php

示例9: getOrderTotal

 /**
  * This function returns the total cart amount
  *
  * Possible values for $type:
  * Cart::ONLY_PRODUCTS
  * Cart::ONLY_DISCOUNTS
  * Cart::BOTH
  * Cart::BOTH_WITHOUT_SHIPPING
  * Cart::ONLY_SHIPPING
  * Cart::ONLY_WRAPPING
  * Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING
  * Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING
  *
  * @param bool $withTaxes With or without taxes
  * @param int $type Total type
  * @param bool $use_cache Allow using cache of the method CartRule::getContextualValue
  * @return float Order total
  */
 public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true)
 {
     // Dependencies
     $address_factory = Adapter_ServiceLocator::get('Adapter_AddressFactory');
     $price_calculator = Adapter_ServiceLocator::get('Adapter_ProductPriceCalculator');
     $configuration = Adapter_ServiceLocator::get('Core_Business_ConfigurationInterface');
     $ps_tax_address_type = $configuration->get('PS_TAX_ADDRESS_TYPE');
     $ps_use_ecotax = $configuration->get('PS_USE_ECOTAX');
     $ps_round_type = $configuration->get('PS_ROUND_TYPE');
     $ps_ecotax_tax_rules_group_id = $configuration->get('PS_ECOTAX_TAX_RULES_GROUP_ID');
     $compute_precision = $configuration->get('_PS_PRICE_COMPUTE_PRECISION_');
     if (!$this->id) {
         return 0;
     }
     $type = (int) $type;
     $array_type = array(Cart::ONLY_PRODUCTS, Cart::ONLY_DISCOUNTS, Cart::BOTH, Cart::BOTH_WITHOUT_SHIPPING, Cart::ONLY_SHIPPING, Cart::ONLY_WRAPPING, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING);
     // Define virtual context to prevent case where the cart is not the in the global context
     $virtual_context = Context::getContext()->cloneContext();
     $virtual_context->cart = $this;
     if (!in_array($type, $array_type)) {
         die(Tools::displayError());
     }
     $with_shipping = in_array($type, array(Cart::BOTH, Cart::ONLY_SHIPPING));
     // if cart rules are not used
     if ($type == Cart::ONLY_DISCOUNTS && !CartRule::isFeatureActive()) {
         return 0;
     }
     // no shipping cost if is a cart with only virtuals products
     $virtual = $this->isVirtualCart();
     if ($virtual && $type == Cart::ONLY_SHIPPING) {
         return 0;
     }
     if ($virtual && $type == Cart::BOTH) {
         $type = Cart::BOTH_WITHOUT_SHIPPING;
     }
     if ($with_shipping || $type == Cart::ONLY_DISCOUNTS) {
         if (is_null($products) && is_null($id_carrier)) {
             $shipping_fees = $this->getTotalShippingCost(null, (bool) $with_taxes);
         } else {
             $shipping_fees = $this->getPackageShippingCost($id_carrier, (bool) $with_taxes, null, $products);
         }
     } else {
         $shipping_fees = 0;
     }
     if ($type == Cart::ONLY_SHIPPING) {
         return $shipping_fees;
     }
     if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
         $type = Cart::ONLY_PRODUCTS;
     }
     $param_product = true;
     if (is_null($products)) {
         $param_product = false;
         $products = $this->getProducts();
     }
     if ($type == Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING) {
         foreach ($products as $key => $product) {
             if ($product['is_virtual']) {
                 unset($products[$key]);
             }
         }
         $type = Cart::ONLY_PRODUCTS;
     }
     $order_total = 0;
     if (Tax::excludeTaxeOption()) {
         $with_taxes = false;
     }
     $products_total = array();
     $ecotax_total = 0;
     foreach ($products as $product) {
         // products refer to the cart details
         if ($virtual_context->shop->id != $product['id_shop']) {
             $virtual_context->shop = new Shop((int) $product['id_shop']);
         }
         if ($ps_tax_address_type == 'id_address_invoice') {
             $id_address = (int) $this->id_address_invoice;
         } else {
             $id_address = (int) $product['id_address_delivery'];
         }
         // Get delivery address of the product from the cart
         if (!$address_factory->addressExists($id_address)) {
             $id_address = null;
//.........这里部分代码省略.........
开发者ID:satanicman,项目名称:Pizzushi.loc,代码行数:101,代码来源:Cart.php

示例10: autoAddToCart

    /**
     * @static
     * @param Context|null $context
     * @return mixed
     */
    public static function autoAddToCart(Context $context = null)
    {
        if ($context === null) {
            $context = Context::getContext();
        }
        if (!CartRule::isFeatureActive() || !Validate::isLoadedObject($context->cart)) {
            return;
        }
        $sql = '
		SELECT cr.*
		FROM ' . _DB_PREFIX_ . 'cart_rule cr
		LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_shop crs ON cr.id_cart_rule = crs.id_cart_rule
		LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_carrier crca ON cr.id_cart_rule = crca.id_cart_rule
		' . ($context->cart->id_carrier ? 'LEFT JOIN ' . _DB_PREFIX_ . 'carrier c ON (c.id_reference = crca.id_carrier AND c.deleted = 0)' : '') . '		
		LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_country crco ON cr.id_cart_rule = crco.id_cart_rule
		WHERE cr.active = 1
		AND cr.code = ""
		AND cr.quantity > 0
		AND cr.date_from < "' . date('Y-m-d H:i:s') . '"
		AND cr.date_to > "' . date('Y-m-d H:i:s') . '"
		AND (
			cr.id_customer = 0
			' . ($context->customer->id ? 'OR cr.id_customer = ' . (int) $context->cart->id_customer : '') . '
		)
		AND (
			cr.`carrier_restriction` = 0
			' . ($context->cart->id_carrier ? 'OR c.id_carrier = ' . (int) $context->cart->id_carrier : '') . '
		)
		AND (
			cr.`shop_restriction` = 0
			' . (Shop::isFeatureActive() && $context->shop->id ? 'OR crs.id_shop = ' . (int) $context->shop->id : '') . '
		)
		AND (
			cr.`group_restriction` = 0
			' . ($context->customer->id ? 'OR 0 < (
				SELECT cg.`id_group`
				FROM `' . _DB_PREFIX_ . 'customer_group` cg
				INNER JOIN `' . _DB_PREFIX_ . 'cart_rule_group` crg ON cg.id_group = crg.id_group
				WHERE cr.`id_cart_rule` = crg.`id_cart_rule`
				AND cg.`id_customer` = ' . (int) $context->customer->id . '
				LIMIT 1
			)' : '') . '
		)
		AND (
			cr.`reduction_product` <= 0
			OR cr.`reduction_product` IN (
				SELECT `id_product`
				FROM `' . _DB_PREFIX_ . 'cart_product`
				WHERE `id_cart` = ' . (int) $context->cart->id . '
			)
		)
		AND cr.id_cart_rule NOT IN (SELECT id_cart_rule FROM ' . _DB_PREFIX_ . 'cart_cart_rule WHERE id_cart = ' . (int) $context->cart->id . ')
		ORDER BY priority';
        $result = Db::getInstance()->executeS($sql);
        if ($result) {
            $cart_rules = ObjectModel::hydrateCollection('CartRule', $result);
            if ($cart_rules) {
                foreach ($cart_rules as $cart_rule) {
                    if ($cart_rule->checkValidity($context, false, false)) {
                        $context->cart->addCartRule($cart_rule->id);
                    }
                }
            }
        }
    }
开发者ID:dev-lav,项目名称:htdocs,代码行数:70,代码来源:CartRule.php

示例11: autoRemoveFromCart

 /**
  * Automatically remove this CartRule from the Cart
  *
  * @param Context|null $context Context instance
  *
  * @return array Error messages
  */
 public static function autoRemoveFromCart(Context $context = null)
 {
     if (!$context) {
         $context = Context::getContext();
     }
     if (!CartRule::isFeatureActive() || !Validate::isLoadedObject($context->cart)) {
         return array();
     }
     static $errors = array();
     foreach ($context->cart->getCartRules() as $cart_rule) {
         if ($error = $cart_rule['obj']->checkValidity($context, true)) {
             $context->cart->removeCartRule($cart_rule['obj']->id);
             $context->cart->update();
             $errors[] = $error;
         }
     }
     return $errors;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:25,代码来源:CartRule.php

示例12: autoAddToCart

    /**
     * @static
     * @param Context|null $context
     * @return mixed
     */
    public static function autoAddToCart(Context $context = null)
    {
        if ($context === null) {
            $context = Context::getContext();
        }
        if (!CartRule::isFeatureActive() || !Validate::isLoadedObject($context->cart)) {
            return;
        }
        $result = Db::getInstance()->executeS('
		SELECT cr.*
		FROM ' . _DB_PREFIX_ . 'cart_rule cr
		LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_shop crs ON cr.id_cart_rule = crs.id_cart_rule
		LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_carrier crca ON cr.id_cart_rule = crca.id_cart_rule
		LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_country crco ON cr.id_cart_rule = crco.id_cart_rule
		WHERE cr.active = 1
		AND cr.code = ""
		AND cr.quantity > 0
		AND cr.date_from < "' . date('Y-m-d H:i:s') . '"
		AND cr.date_to > "' . date('Y-m-d H:i:s') . '"
		AND (
			cr.id_customer = 0
			' . ($context->customer->id ? 'OR cr.id_customer = ' . (int) $context->cart->id_customer : '') . '
		)
		AND (
			cr.carrier_restriction = 0
			' . ($context->cart->id_carrier ? 'OR crca.id_carrier = ' . (int) $context->cart->id_carrier : '') . '
		)
		AND (
			cr.shop_restriction = 0
			' . (Shop::isFeatureActive() && $context->shop->id ? 'OR crs.id_shop = ' . (int) $context->shop->id : '') . '
		)
		AND (
			cr.group_restriction = 0
			' . ($context->customer->id ? 'OR 0 < (
				SELECT cg.id_group
				FROM ' . _DB_PREFIX_ . 'customer_group cg
				LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_group crg ON cg.id_group = crg.id_group
				WHERE cr.id_cart_rule = crg.id_cart_rule
				AND cg.id_customer = ' . (int) $context->customer->id . '
			)' : '') . '
		)
		AND (
			cr.reduction_product <= 0
			OR cr.reduction_product IN (
				SELECT id_product
				FROM ' . _DB_PREFIX_ . 'cart_product
				WHERE id_cart = ' . (int) $context->cart->id . '
			)
		)
		AND cr.id_cart_rule NOT IN (SELECT id_cart_rule	FROM ' . _DB_PREFIX_ . 'cart_cart_rule WHERE id_cart = ' . (int) $context->cart->id . ')
		ORDER BY priority');
        $cartRules = ObjectModel::hydrateCollection('CartRule', $result);
        foreach ($cartRules as $cartRule) {
            if ($cartRule->checkValidity($context, false, false)) {
                $context->cart->addCartRule($cartRule->id);
            }
        }
    }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:63,代码来源:CartRule.php

示例13: setMobileTemplate

 /**
  * This checks if the template set is available for mobile themes,
  * otherwise the front template is choosen.
  */
 public function setMobileTemplate($template)
 {
     // Needed for site map
     $blockmanufacturer = Module::getInstanceByName('blockmanufacturer');
     $blocksupplier = Module::getInstanceByName('blocksupplier');
     $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0));
     $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1));
     $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive());
     $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active);
     $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active);
     $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS'));
     $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP'));
     $this->context->smarty->assign('conditions', Configuration::get('PS_CONDITIONS'));
     $this->context->smarty->assign('id_cgv', Configuration::get('PS_CONDITIONS_CMS_ID'));
     $this->context->smarty->assign('PS_SHOP_NAME', Configuration::get('PS_SHOP_NAME'));
     $mobile_template = '';
     $tpl_file = basename($template);
     $dirname = dirname($template) . (substr(dirname($template), -1, 1) == '/' ? '' : '/');
     if ($dirname == _PS_THEME_DIR_) {
         if (file_exists(_PS_THEME_MOBILE_DIR_ . $tpl_file)) {
             $template = _PS_THEME_MOBILE_DIR_ . $tpl_file;
         }
     } elseif ($dirname == _PS_THEME_MOBILE_DIR_) {
         if (!file_exists(_PS_THEME_MOBILE_DIR_ . $tpl_file) && file_exists(_PS_THEME_DIR_ . $tpl_file)) {
             $template = _PS_THEME_DIR_ . $tpl_file;
         }
     }
     $assign = array();
     $assign['tpl_file'] = basename($tpl_file, '.tpl');
     if (isset($this->php_self)) {
         $assign['controller_name'] = $this->php_self;
     }
     $this->context->smarty->assign($assign);
     $this->template = $template;
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:39,代码来源:FrontController.php

示例14: getOrderTotal

 /**
  * This function returns the total cart amount
  *
  * Possible values for $type:
  * Cart::ONLY_PRODUCTS
  * Cart::ONLY_DISCOUNTS
  * Cart::BOTH
  * Cart::BOTH_WITHOUT_SHIPPING
  * Cart::ONLY_SHIPPING
  * Cart::ONLY_WRAPPING
  * Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING
  * Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING
  *
  * @param boolean $withTaxes With or without taxes
  * @param integer $type Total type
  * @param boolean $use_cache Allow using cache of the method CartRule::getContextualValue
  * @return float Order total
  */
 public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true)
 {
     if (!$this->id) {
         return 0;
     }
     $type = (int) $type;
     $array_type = array(Cart::ONLY_PRODUCTS, Cart::ONLY_DISCOUNTS, Cart::BOTH, Cart::BOTH_WITHOUT_SHIPPING, Cart::ONLY_SHIPPING, Cart::ONLY_WRAPPING, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING);
     // Define virtual context to prevent case where the cart is not the in the global context
     $virtual_context = Context::getContext()->cloneContext();
     $virtual_context->cart = $this;
     if (!in_array($type, $array_type)) {
         die(Tools::displayError());
     }
     $with_shipping = in_array($type, array(Cart::BOTH, Cart::ONLY_SHIPPING));
     // if cart rules are not used
     if ($type == Cart::ONLY_DISCOUNTS && !CartRule::isFeatureActive()) {
         return 0;
     }
     // no shipping cost if is a cart with only virtuals products
     $virtual = $this->isVirtualCart();
     if ($virtual && $type == Cart::ONLY_SHIPPING) {
         return 0;
     }
     if ($virtual && $type == Cart::BOTH) {
         $type = Cart::BOTH_WITHOUT_SHIPPING;
     }
     if ($with_shipping) {
         if (is_null($products) && is_null($id_carrier)) {
             $shipping_fees = $this->getTotalShippingCost(null, (bool) $with_taxes);
         } else {
             $shipping_fees = $this->getPackageShippingCost($id_carrier, (bool) $with_taxes, null, $products);
         }
     } else {
         $shipping_fees = 0;
     }
     if ($type == Cart::ONLY_SHIPPING) {
         return $shipping_fees;
     }
     if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
         $type = Cart::ONLY_PRODUCTS;
     }
     $param_product = true;
     if (is_null($products)) {
         $param_product = false;
         $products = $this->getProducts();
     }
     if ($type == Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING) {
         foreach ($products as $key => $product) {
             if ($product['is_virtual']) {
                 unset($products[$key]);
             }
         }
         $type = Cart::ONLY_PRODUCTS;
     }
     $order_total = 0;
     if (Tax::excludeTaxeOption()) {
         $with_taxes = false;
     }
     foreach ($products as $product) {
         if ($virtual_context->shop->id != $product['id_shop']) {
             $virtual_context->shop = new Shop((int) $product['id_shop']);
         }
         if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
             $address_id = (int) $this->id_address_invoice;
         } else {
             $address_id = (int) $product['id_address_delivery'];
         }
         // Get delivery address of the product from the cart
         if (!Address::addressExists($address_id)) {
             $address_id = null;
         }
         if ($this->_taxCalculationMethod == PS_TAX_EXC) {
             // Here taxes are computed only once the quantity has been applied to the product price
             $price = Product::getPriceStatic((int) $product['id_product'], false, (int) $product['id_product_attribute'], 2, null, false, true, $product['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $address_id, $null, true, true, $virtual_context);
             $total_ecotax = $product['ecotax'] * (int) $product['cart_quantity'];
             $total_price = $price * (int) $product['cart_quantity'];
             if ($with_taxes) {
                 $product_tax_rate = (double) Tax::getProductTaxRate((int) $product['id_product'], (int) $address_id, $virtual_context);
                 $product_eco_tax_rate = Tax::getProductEcotaxRate((int) $address_id);
                 $total_price = ($total_price - $total_ecotax) * (1 + $product_tax_rate / 100);
                 $total_ecotax = $total_ecotax * (1 + $product_eco_tax_rate / 100);
                 $total_price = Tools::ps_round($total_price + $total_ecotax, 2);
//.........这里部分代码省略.........
开发者ID:dev-lav,项目名称:htdocs,代码行数:101,代码来源:Cart.php

示例15: getTemplateVarConfiguration

 public function getTemplateVarConfiguration()
 {
     $quantity_discount_price = Configuration::get('PS_DISPLAY_DISCOUNT_PRICE');
     return array('display_taxes_label' => $this->getDisplayTaxesLabel(), 'low_quantity_threshold' => (int) Configuration::get('PS_LAST_QTIES'), 'is_b2b' => (bool) Configuration::get('PS_B2B_ENABLE'), 'is_catalog' => (bool) Configuration::isCatalogMode(), 'show_prices' => (bool) Configuration::showPrices(), 'opt_in' => array('partner' => (bool) Configuration::get('PS_CUSTOMER_OPTIN')), 'quantity_discount' => array('type' => $quantity_discount_price ? 'price' : 'discount', 'label' => $quantity_discount_price ? $this->getTranslator()->trans('Price', array(), 'Shop.Theme.Catalog') : $this->getTranslator()->trans('Discount', array(), 'Shop.Theme.Catalog')), 'voucher_enabled' => (int) CartRule::isFeatureActive(), 'return_enabled' => (int) Configuration::get('PS_ORDER_RETURN'), 'number_of_days_for_return' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'));
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:5,代码来源:FrontController.php


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