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


PHP CartRule::cartRuleExists方法代码示例

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


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

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

示例2: discountExists

 /**
  * @deprecated 1.5.0.1
  */
 public static function discountExists($discountName, $id_discount = 0)
 {
     return parent::cartRuleExists($discountName);
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:7,代码来源:Discount.php

示例3: create_split_discount

 private static function create_split_discount($amount, $id_customer, $id_currency, $id_carts)
 {
     ${"GLOBALS"}["lpfswanqwex"] = "code";
     ${"GLOBALS"}["iuztfsobjr"] = "id_customer";
     $ezdxpbfeg = "languages";
     ${"GLOBALS"}["rnwtmfeg"] = "amount";
     $wbglpjrhabt = "id_carts";
     $wvwcmnzwlplf = "id_currency";
     global $cookie;
     ${${"GLOBALS"}["lpfswanqwex"]} = "split discount-" . ${${"GLOBALS"}["qnutktejfsm"]};
     ${"GLOBALS"}["rommybk"] = "languages";
     ${"GLOBALS"}["pjlvntsji"] = "discount";
     $zwjuqmhrgn = "timeinfo";
     if (CartRule::cartRuleExists(${${"GLOBALS"}["thjhsxt"]})) {
         ${"GLOBALS"}["mutlcfyzn"] = "cartRuleInfo";
         $efjrrcbmmc = "code";
         ${"GLOBALS"}["dvulqgqhgy"] = "cartRuleInfo";
         ${${"GLOBALS"}["dvulqgqhgy"]} = CartRule::getCartsRuleByCode(${$efjrrcbmmc}, $cookie->id_lang);
         if (!empty(${${"GLOBALS"}["mutlcfyzn"]})) {
             ${"GLOBALS"}["dutusymn"] = "id_currency";
             $ugjhbkcy = "id_customer";
             $vhkwbuk = "discount";
             ${"GLOBALS"}["wtngbnwjou"] = "amount";
             ${$vhkwbuk} = new CartRule((int) ${${"GLOBALS"}["exnqrgnk"]}[0]["id_cart_rule"]);
             $discount->reduction_amount = Tools::ps_round(abs(${${"GLOBALS"}["wtngbnwjou"]}), 2);
             $discount->id_customer = ${$ugjhbkcy};
             $discount->reduction_currency = ${${"GLOBALS"}["dutusymn"]};
             ${"GLOBALS"}["lftybruvzf"] = "discount";
             $discount->save();
             return ${${"GLOBALS"}["lftybruvzf"]};
         }
     }
     ${$zwjuqmhrgn} = AgileHelper::getDbDateTime(1, "DAY");
     ${${"GLOBALS"}["rommybk"]} = Language::getLanguages();
     ${${"GLOBALS"}["pjlvntsji"]} = new CartRule();
     $discount->code = "split discount-" . ${$wbglpjrhabt};
     $discount->description = $discount->code;
     $discount->id_customer = ${${"GLOBALS"}["iuztfsobjr"]};
     $discount->id_group = 0;
     $discount->reduction_currency = ${${"GLOBALS"}["lppjvltcyn"]};
     $discount->reduction_amount = Tools::ps_round(abs(${${"GLOBALS"}["rnwtmfeg"]}), 2);
     $discount->minimum_amount_currency = ${$wvwcmnzwlplf};
     $discount->quantity = 1;
     $discount->quantity_per_user = 1;
     $discount->date_from = ${${"GLOBALS"}["vwwosyf"]}["timenow"];
     $discount->date_to = ${${"GLOBALS"}["vwwosyf"]}["newtime"];
     $discount->partial_use = 0;
     $discount->include_tax = 1;
     $discount->active = 1;
     $discount->cart_display = 0;
     $discount->date_add = ${${"GLOBALS"}["vwwosyf"]}["timenow"];
     $discount->date_upd = ${${"GLOBALS"}["vwwosyf"]}["timenow"];
     foreach (${$ezdxpbfeg} as ${${"GLOBALS"}["ehrifiqsh"]}) {
         $edrgrgkvw = "fields";
         $hfpvhmutci = "field";
         ${${"GLOBALS"}["samttghly"]} = array("name");
         $gigicrqhcvtw = "language";
         $vuqkbfsbtw = "field";
         foreach (${$edrgrgkvw} as ${$vuqkbfsbtw}) {
             $discount->{${$hfpvhmutci}}[intval(${$gigicrqhcvtw}["id_lang"])] = $discount->code;
         }
     }
     $discount->save();
     return ${${"GLOBALS"}["gwtztyfxho"]};
 }
开发者ID:sho5kubota,项目名称:guidingyou2,代码行数:65,代码来源:AgileMultipleSellerBase.php

示例4: 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->highlight = 1;
            $cart_rule->quantity_per_user = 1;
            $cart_rule->reduction_tax = (bool) Configuration::get('PS_LOYALTY_TAX');
            // 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->minimum_amount_currency = (int) $this->context->currency->id;
            $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);
            }
            $contains_categories = is_array($categories) && count($categories);
            if ($contains_categories) {
                $cart_rule->product_restriction = 1;
            }
            $cart_rule->add();
            //Restrict cartRules with categories
            if ($contains_categories) {
                //Creating rule group
                $id_cart_rule = (int) $cart_rule->id;
                $sql = "INSERT INTO " . _DB_PREFIX_ . "cart_rule_product_rule_group (id_cart_rule, quantity) VALUES ('{$id_cart_rule}', 1)";
                Db::getInstance()->execute($sql);
                $id_group = (int) Db::getInstance()->Insert_ID();
                //Creating product rule
                $sql = "INSERT INTO " . _DB_PREFIX_ . "cart_rule_product_rule (id_product_rule_group, type) VALUES ('{$id_group}', 'categories')";
                Db::getInstance()->execute($sql);
                $id_product_rule = (int) Db::getInstance()->Insert_ID();
                //Creating restrictions
                $values = array();
                foreach ($categories as $category) {
                    $category = (int) $category;
                    $values[] = "('{$id_product_rule}', '{$category}')";
                }
                $values = implode(',', $values);
                $sql = "INSERT INTO " . _DB_PREFIX_ . "cart_rule_product_rule_value (id_product_rule, id_item) VALUES {$values}";
                Db::getInstance()->execute($sql);
            }
            // Register order(s) which contributed to create this voucher
            if (!LoyaltyModule::registerDiscount($cart_rule)) {
                $cart_rule->delete();
            }
        }
        Tools::redirect($this->context->link->getModuleLink('loyalty', 'default', array('process' => 'summary')));
    }
开发者ID:Benichou34,项目名称:loyalty,代码行数:81,代码来源:default.php

示例5: dirname

include_once dirname(__FILE__) . '/LoyaltyStateModule.php';
include_once dirname(__FILE__) . '/loyalty.php';
Tools::displayFileAsDeprecated();
$context = Context::getContext();
if (!$context->customer->isLogged()) {
    Tools::redirect('index.php?controller=authentication&back=modules/loyalty/loyalty-program.php');
}
$context->controller->addJqueryPlugin(array('dimensions', 'cluetip'));
$customerPoints = (int) LoyaltyModule::getPointsByCustomer((int) $cookie->id_customer);
/* transform point into voucher if needed */
if (Tools::getValue('transform-points') == 'true' and $customerPoints > 0) {
    /* Generate a voucher code */
    $voucherCode = NULL;
    do {
        $voucherCode = 'FID' . rand(1000, 100000);
    } while (CartRule::cartRuleExists($voucherCode));
    /* Voucher creation and affectation to the customer */
    $cartRule = new CartRule();
    $cartRule->code = $voucherCode;
    $cartRule->id_customer = (int) $context->customer->id;
    $cartRule->id_currency = (int) $context->currency->id;
    $cartRule->reduction_amount = LoyaltyModule::getVoucherValue((int) $customerPoints);
    $cartRule->quantity = 1;
    $cartRule->quantity_per_user = 1;
    /* If merchandise returns are allowed, the voucher musn't be usable before this max return date */
    $dateFrom = Db::getInstance()->getValue('
	SELECT UNIX_TIMESTAMP(date_add) n
	FROM ' . _DB_PREFIX_ . 'loyalty
	WHERE id_cart_rule = 0 AND id_customer = ' . (int) $cookie->id_customer . '
	ORDER BY date_add DESC');
    if (Configuration::get('PS_ORDER_RETURN')) {
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:31,代码来源:loyalty-program.php


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