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


PHP CartRule类代码示例

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


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

示例1: registerDiscount

 public function registerDiscount($id_customer, $register = false, $id_currency = 0)
 {
     $configurations = Configuration::getMultiple(array('REFERRAL_DISCOUNT_TYPE', 'REFERRAL_PERCENTAGE', 'REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency));
     $cartRule = new CartRule();
     if ($configurations['REFERRAL_DISCOUNT_TYPE'] == Discount::PERCENT) {
         $cartRule->reduction_percent = (double) $configurations['REFERRAL_PERCENTAGE'];
     } elseif ($configurations['REFERRAL_DISCOUNT_TYPE'] == Discount::AMOUNT and isset($configurations['REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency])) {
         $cartRule->reduction_amount = (double) $configurations['REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency];
     }
     $cartRule->quantity = 1;
     $cartRule->quantity_per_user = 1;
     $cartRule->date_from = date('Y-m-d H:i:s', time());
     $cartRule->date_to = date('Y-m-d H:i:s', time() + 31536000);
     // + 1 year
     $cartRule->code = $this->getDiscountPrefix() . Tools::passwdGen(6);
     $cartRule->name = Configuration::getInt('REFERRAL_DISCOUNT_DESCRIPTION');
     $cartRule->id_customer = (int) $id_customer;
     $cartRule->id_currency = (int) $id_currency;
     if ($cartRule->add()) {
         if ($register != false) {
             if ($register == 'sponsor') {
                 $this->id_cart_rule_sponsor = (int) $cartRule->id;
             } elseif ($register == 'sponsored') {
                 $this->id_cart_rule = (int) $cartRule->id;
             }
             return $this->save();
         }
         return true;
     }
     return false;
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:31,代码来源:ReferralProgramModule.php

示例2: registerDiscount

 public function registerDiscount($id_customer, $amount, $day, $type, $name)
 {
     $languages = Language::getLanguages(false);
     $cartRule = new CartRule();
     if ($type == 'percent') {
         $cartRule->reduction_percent = $amount;
     } else {
         $cartRule->reduction_amount = $amount;
     }
     $cartRule->quantity = 1;
     $cartRule->quantity_per_user = 1;
     $cartRule->date_from = date('Y-m-d H:i:s', time());
     $cartRule->date_to = date('Y-m-d H:i:s', time() + 86000 * $day);
     //$cartRule->minimum_amount = ''; // Utile ?
     $cartRule->minimum_amount_tax = true;
     $cartRule->code = $name . '_' . strtoupper(Tools::passwdGen(6));
     //$cartRule->code = $name;
     // QUESTION ?
     // It does not work if I do not use languages but it works with the referalprogam module (Prestashop Module)
     foreach ($languages as $lang) {
         $cartRule->name[$lang['id_lang']] = $name . ' Customer ID :' . $id_customer;
     }
     $cartRule->id_customer = (int) $id_customer;
     $cartRule->reduction_tax = true;
     $cartRule->highlight = 1;
     if ($cartRule->add()) {
         return $cartRule;
     }
     return false;
 }
开发者ID:mrtwister76,项目名称:superabandonedcart,代码行数:30,代码来源:Campaign.php

示例3: initContent

 /**
  * Preparing hidden form with payment data before sending it to Dotpay
  */
 public function initContent()
 {
     parent::initContent();
     $this->display_column_left = false;
     $this->display_header = false;
     $this->display_footer = false;
     $cartId = 0;
     if (Tools::getValue('order_id') == false) {
         $cartId = $this->context->cart->id;
         $exAmount = $this->api->getExtrachargeAmount(true);
         if ($exAmount > 0 && !$this->isExVPinCart()) {
             $productId = $this->config->getDotpayExchVPid();
             if ($productId != 0) {
                 $product = new Product($productId, true);
                 $product->price = $exAmount;
                 $product->save();
                 $product->flushPriceCache();
                 $this->context->cart->updateQty(1, $product->id);
                 $this->context->cart->update();
                 $this->context->cart->getPackageList(true);
             }
         }
         $discAmount = $this->api->getDiscountAmount();
         if ($discAmount > 0) {
             $discount = new CartRule($this->config->getDotpayDiscountId());
             $discount->reduction_amount = $this->api->getDiscountAmount();
             $discount->reduction_currency = $this->context->cart->id_currency;
             $discount->reduction_tax = 1;
             $discount->update();
             $this->context->cart->addCartRule($discount->id);
             $this->context->cart->update();
             $this->context->cart->getPackageList(true);
         }
         $result = $this->module->validateOrder($this->context->cart->id, (int) $this->config->getDotpayNewStatusId(), $this->getDotAmount(), $this->module->displayName, NULL, array(), NULL, false, $this->customer->secure_key);
     } else {
         $this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id'));
         $this->initPersonalData();
         $cartId = $this->context->cart->id;
     }
     $this->api->onPrepareAction(Tools::getValue('dotpay_type'), array('order' => Order::getOrderByCartId($cartId), 'customer' => $this->context->customer->id));
     $sa = new DotpaySellerApi($this->config->getDotpaySellerApiUrl());
     if ($this->config->isDotpayDispInstruction() && $this->config->isApiConfigOk() && $this->api->isChannelInGroup(Tools::getValue('channel'), array(DotpayApi::cashGroup, DotpayApi::transfersGroup)) && $sa->isAccountRight($this->config->getDotpayApiUsername(), $this->config->getDotpayApiPassword(), $this->config->getDotpayApiVersion())) {
         $this->context->cookie->dotpay_channel = Tools::getValue('channel');
         Tools::redirect($this->context->link->getModuleLink($this->module->name, 'confirm', array('order_id' => Order::getOrderByCartId($cartId))));
         die;
     }
     $this->context->smarty->assign(array('hiddenForm' => $this->api->getHiddenForm()));
     $cookie = new Cookie('lastOrder');
     $cookie->orderId = Order::getOrderByCartId($cartId);
     $cookie->write();
     $this->setTemplate("preparing.tpl");
 }
开发者ID:dotpay,项目名称:dotpay,代码行数:55,代码来源:preparing.php

示例4: 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

示例5: postProcess

 /**
  * Do whatever you have to before redirecting the customer on the website of your payment processor.
  */
 public function postProcess()
 {
     /**
      * Oops, an error occured.
      */
     if (Tools::getValue('action') == 'error') {
         return $this->displayError('An error occurred while trying to redirect the customer');
     } else {
         //First solution to know if refreshed page: http://stackoverflow.com/a/6127748
         $refreshButtonPressed = isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0';
         $result = $this->module->callToRest('GET', '/orders?mid=' . Context::getContext()->cart->id, null, false);
         $result['response'] = json_decode($result['response'], true);
         if ($result['code'] == '200' && isset($result['response']['results'][0]['id']) && !$refreshButtonPressed) {
             //The cart exists on Aplazame, we try to send with another ID
             $oldCart = new Cart(Context::getContext()->cart->id);
             $data = $oldCart->duplicate();
             if ($data['success']) {
                 $cart = $data['cart'];
                 Context::getContext()->cart = $cart;
                 CartRule::autoAddToCart(Context::getContext());
                 Context::getContext()->cookie->id_cart = $cart->id;
             } else {
                 $this->module->logError('Error: Cannot duplicate cart ' . Context::getContext()->cart->id);
             }
         }
         $this->context->smarty->assign(array('cart_id' => Context::getContext()->cart->id, 'secure_key' => Context::getContext()->customer->secure_key, 'aplazame_order_json' => json_encode($this->module->getCheckoutSerializer(0, Context::getContext()->cart->id), 128), 'aplazame_version' => ConfigurationCore::get('APLAZAME_API_VERSION', null), 'aplazame_url' => Configuration::get('APLAZAME_API_URL', null), 'aplazame_mode' => Configuration::get('APLAZAME_LIVE_MODE', null) ? 'false' : 'true'));
         return $this->setTemplate('redirect.tpl');
     }
 }
开发者ID:jgermade,项目名称:prestashop,代码行数:32,代码来源:redirect.php

示例6: delete

 public function delete()
 {
     if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL) {
         $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_attribute = ' . (int) $this->id);
         $products = array();
         foreach ($result as $row) {
             $combination = new Combination($row['id_product_attribute']);
             $new_request = Db::getInstance()->executeS('SELECT id_product, default_on FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product_attribute = ' . (int) $row['id_product_attribute']);
             foreach ($new_request as $value) {
                 if ($value['default_on'] == 1) {
                     $products[] = $value['id_product'];
                 }
             }
             $combination->delete();
         }
         foreach ($products as $product) {
             $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product = ' . (int) $product . ' LIMIT 1');
             foreach ($result as $row) {
                 if (Validate::isLoadedObject($product = new Product((int) $product))) {
                     $product->deleteDefaultAttributes();
                     $product->setDefaultAttribute($row['id_product_attribute']);
                 }
             }
         }
         // Delete associated restrictions on cart rules
         CartRule::cleanProductRuleIntegrity('attributes', $this->id);
         /* Reinitializing position */
         $this->cleanPositions((int) $this->id_attribute_group);
     }
     $return = parent::delete();
     if ($return) {
         Hook::exec('actionAttributeDelete', array('id_attribute' => $this->id));
     }
     return $return;
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:35,代码来源:Attribute.php

示例7: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $cart_rules = CartRule::getCustomerCartRules($this->context->language->id, $this->context->customer->id, true, false);
     $nb_cart_rules = count($cart_rules);
     $this->context->smarty->assign(array('nb_cart_rules' => (int) $nb_cart_rules, 'cart_rules' => $cart_rules));
     $this->setTemplate(_PS_THEME_DIR_ . 'discount.tpl');
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:12,代码来源:DiscountController.php

示例8: 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

示例9: 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

示例10: findCode

function findCode($code)
{
    if (version_compare(_PS_VERSION_, '1.5', '>=')) {
        return CartRule::getIdByCode($code);
    } else {
        return Discount::getIdByName($code);
    }
}
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:8,代码来源:mailjet.cron.php

示例11: _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

示例12: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $cart_rules = CartRule::getCustomerCartRules($this->context->language->id, $this->context->customer->id, true, false);
     $nb_cart_rules = count($cart_rules);
     foreach ($cart_rules as &$discount) {
         $discount['value'] = Tools::convertPriceFull($discount['value'], new Currency((int) $discount['reduction_currency']), new Currency((int) $this->context->cart->id_currency));
     }
     $this->context->smarty->assign(array('nb_cart_rules' => (int) $nb_cart_rules, 'cart_rules' => $cart_rules, 'discount' => $cart_rules, 'nbDiscounts' => (int) $nb_cart_rules));
     $this->setTemplate(_PS_THEME_DIR_ . 'discount.tpl');
 }
开发者ID:ortegon000,项目名称:tienda,代码行数:15,代码来源:DiscountController.php

示例13: delete

 public function delete()
 {
     $address = new Address($this->id_address);
     if (Validate::isLoadedObject($address) and !$address->delete()) {
         return false;
     }
     if (parent::delete()) {
         CartRule::cleanProductRuleIntegrity('manufacturers', $this->id);
         return $this->deleteImage();
     }
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:11,代码来源:Manufacturer.php

示例14: login_customer

 /**
  * Logs a given customer in.
  */
 public static function login_customer($id_customer)
 {
     // Make sure that that the customers exists.
     $sql = "SELECT * FROM `" . _DB_PREFIX_ . "customer` WHERE `id_customer` = '" . pSQL($id_customer) . "'";
     $result = Db::getInstance()->GetRow($sql);
     // The user account has been found!
     if (!empty($result['id_customer'])) {
         // See => CustomerCore::getByEmail
         $customer = new Customer();
         $customer->id = $result['id_customer'];
         foreach ($result as $key => $value) {
             if (key_exists($key, $customer)) {
                 $customer->{$key} = $value;
             }
         }
         // See => AuthControllerCore::processSubmitLogin
         Hook::exec('actionBeforeAuthentication');
         $context = Context::getContext();
         $context->cookie->id_compare = isset($context->cookie->id_compare) ? $context->cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id);
         $context->cookie->id_customer = (int) $customer->id;
         $context->cookie->customer_lastname = $customer->lastname;
         $context->cookie->customer_firstname = $customer->firstname;
         $context->cookie->logged = 1;
         $customer->logged = 1;
         $context->cookie->is_guest = $customer->isGuest();
         $context->cookie->passwd = $customer->passwd;
         $context->cookie->email = $customer->email;
         // Add customer to the context
         $context->customer = $customer;
         if (Configuration::get('PS_CART_FOLLOWING') && (empty($context->cookie->id_cart) || Cart::getNbProducts($context->cookie->id_cart) == 0) && ($id_cart = (int) Cart::lastNoneOrderedCart($context->customer->id))) {
             $context->cart = new Cart($id_cart);
         } else {
             $context->cart->id_carrier = 0;
             $context->cart->setDeliveryOption(null);
             $context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id);
             $context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id);
         }
         $context->cart->id_customer = (int) $customer->id;
         $context->cart->secure_key = $customer->secure_key;
         $context->cart->save();
         $context->cookie->id_cart = (int) $context->cart->id;
         $context->cookie->update();
         $context->cart->autosetProductAddress();
         Hook::exec('actionAuthentication');
         // Login information have changed, so we check if the cart rules still apply
         CartRule::autoRemoveFromCart($context);
         CartRule::autoAddToCart($context);
         // Customer is now logged in.
         return true;
     }
     // Invalid customer specified.
     return false;
 }
开发者ID:rever92,项目名称:social-login-prestashop,代码行数:56,代码来源:tools.php

示例15: processTransformPoints

    /**
     * Transform loyalty point to a voucher
     */
    public function processTransformPoints()
    {
        $customer_points = (int) LoyaltyModule::getPointsByCustomer((int) $this->context->customer->id);
        if ($customer_points > 0) {
            /* Generate a voucher code */
            $voucher_code = null;
            do {
                $voucher_code = 'FID' . rand(1000, 100000);
            } while (CartRule::cartRuleExists($voucher_code));
            // Voucher creation and affectation to the customer
            $cart_rule = new CartRule();
            $cart_rule->code = $voucher_code;
            $cart_rule->id_customer = (int) $this->context->customer->id;
            $cart_rule->reduction_currency = (int) $this->context->currency->id;
            $cart_rule->reduction_amount = LoyaltyModule::getVoucherValue((int) $customer_points);
            $cart_rule->quantity = 1;
            $cart_rule->quantity_per_user = 1;
            // If merchandise returns are allowed, the voucher musn't be usable before this max return date
            $date_from = Db::getInstance()->getValue('
			SELECT UNIX_TIMESTAMP(date_add) n
			FROM ' . _DB_PREFIX_ . 'loyalty
			WHERE id_cart_rule = 0 AND id_customer = ' . (int) $this->context->cookie->id_customer . '
			ORDER BY date_add DESC');
            if (Configuration::get('PS_ORDER_RETURN')) {
                $date_from += 60 * 60 * 24 * (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS');
            }
            $cart_rule->date_from = date('Y-m-d H:i:s', $date_from);
            $cart_rule->date_to = date('Y-m-d H:i:s', strtotime($cart_rule->date_from . ' +1 year'));
            $cart_rule->minimum_amount = (double) Configuration::get('PS_LOYALTY_MINIMAL');
            $cart_rule->active = 1;
            $categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY');
            if ($categories != '' && $categories != 0) {
                $categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'));
            } else {
                die(Tools::displayError());
            }
            $languages = Language::getLanguages(true);
            $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int) Configuration::get('PS_LANG_DEFAULT'));
            foreach ($languages as $language) {
                $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int) $language['id_lang']);
                $cart_rule->name[(int) $language['id_lang']] = $text ? strval($text) : strval($default_text);
            }
            if (is_array($categories) && count($categories)) {
                $cart_rule->add(true, false, $categories);
            } else {
                $cart_rule->add();
            }
            // Register order(s) which contributed to create this voucher
            LoyaltyModule::registerDiscount($cart_rule);
            Tools::redirect($this->context->link->getModuleLink('loyalty', 'default', array('process' => 'summary')));
        }
    }
开发者ID:jicheng17,项目名称:pengwine,代码行数:55,代码来源:default.php


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