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


PHP CartRule::add方法代码示例

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


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

 private function createDiscount($id_email_type, $amount, $id_customer, $dateValidity, $description)
 {
     $cartRule = new CartRule();
     $cartRule->reduction_percent = (double) $amount;
     $cartRule->id_customer = (int) $id_customer;
     $cartRule->date_to = $dateValidity;
     $cartRule->date_from = date('Y-m-d H:i:s');
     $cartRule->quantity = 1;
     $cartRule->quantity_per_user = 1;
     $cartRule->cart_rule_restriction = 1;
     $cartRule->minimum_amount = 0;
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         $cartRule->name[(int) $language['id_lang']] = $description;
     }
     $code = 'FLW-' . (int) $id_email_type . '-' . strtoupper(Tools::passwdGen(10));
     $cartRule->code = $code;
     $cartRule->active = 1;
     if (!$cartRule->add()) {
         return false;
     }
     return $cartRule;
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:23,代码来源:followup.php

示例4: ajaxProcessupdateFreeShipping

 public function ajaxProcessupdateFreeShipping()
 {
     if ($this->tabAccess['edit'] === '1') {
         if (!($id_cart_rule = CartRule::getIdByCode(CartRule::BO_ORDER_CODE_PREFIX . (int) $this->context->cart->id))) {
             $cart_rule = new CartRule();
             $cart_rule->code = CartRule::BO_ORDER_CODE_PREFIX . (int) $this->context->cart->id;
             $cart_rule->name = array(Configuration::get('PS_LANG_DEFAULT') => $this->l('Free Shipping', 'AdminTab', false, false));
             $cart_rule->id_customer = (int) $this->context->cart->id_customer;
             $cart_rule->free_shipping = true;
             $cart_rule->quantity = 1;
             $cart_rule->quantity_per_user = 1;
             $cart_rule->minimum_amount_currency = (int) $this->context->cart->id_currency;
             $cart_rule->reduction_currency = (int) $this->context->cart->id_currency;
             $cart_rule->date_from = date('Y-m-d H:i:s', time());
             $cart_rule->date_to = date('Y-m-d H:i:s', time() + 24 * 36000);
             $cart_rule->active = 1;
             $cart_rule->add();
         } else {
             $cart_rule = new CartRule((int) $id_cart_rule);
         }
         $this->context->cart->removeCartRule((int) $cart_rule->id);
         if (Tools::getValue('free_shipping')) {
             $this->context->cart->addCartRule((int) $cart_rule->id);
         }
         echo Tools::jsonEncode($this->ajaxReturnVars());
     }
 }
开发者ID:zangles,项目名称:lennyba,代码行数:27,代码来源:AdminCartsController.php

示例5: validateOrder

 public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
 {
     if (self::DEBUG_MODE) {
         PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
     }
     if (!isset($this->context)) {
         $this->context = Context::getContext();
     }
     $this->context->cart = new Cart($id_cart);
     $this->context->customer = new Customer($this->context->cart->id_customer);
     // The tax cart is loaded before the customer so re-cache the tax calculation method
     $this->context->cart->setTaxCalculationMethod();
     $this->context->language = new Language($this->context->cart->id_lang);
     $this->context->shop = $shop ? $shop : new Shop($this->context->cart->id_shop);
     ShopUrl::resetMainDomainCache();
     $id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
     $this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
     if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
         $context_country = $this->context->country;
     }
     $order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
     if (!Validate::isLoadedObject($order_status)) {
         PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
         throw new PrestaShopException('Can\'t load Order status');
     }
     if (!$this->active) {
         PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
         die(Tools::displayError());
     }
     // Does order already exists ?
     if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
         if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
             PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
             die(Tools::displayError());
         }
         // For each package, generate an order
         $delivery_option_list = $this->context->cart->getDeliveryOptionList();
         $package_list = $this->context->cart->getPackageList();
         $cart_delivery_option = $this->context->cart->getDeliveryOption();
         // If some delivery options are not defined, or not valid, use the first valid option
         foreach ($delivery_option_list as $id_address => $package) {
             if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
                 foreach ($package as $key => $val) {
                     $cart_delivery_option[$id_address] = $key;
                     break;
                 }
             }
         }
         $order_list = array();
         $order_detail_list = array();
         do {
             $reference = Order::generateReference();
         } while (Order::getByReference($reference)->count());
         $this->currentOrderReference = $reference;
         $order_creation_failed = false;
         $cart_total_paid = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
         foreach ($cart_delivery_option as $id_address => $key_carriers) {
             foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
                 foreach ($data['package_list'] as $id_package) {
                     // Rewrite the id_warehouse
                     $package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
                     $package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
                 }
             }
         }
         // Make sure CartRule caches are empty
         CartRule::cleanCache();
         $cart_rules = $this->context->cart->getCartRules();
         foreach ($cart_rules as $cart_rule) {
             if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
                 if ($error = $rule->checkValidity($this->context, true, true)) {
                     $this->context->cart->removeCartRule((int) $rule->id);
                     if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
                         if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                             Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
                         }
                         Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
                     } else {
                         $rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
                         $error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
                         PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
                     }
                 }
             }
         }
         foreach ($package_list as $id_address => $packageByAddress) {
             foreach ($packageByAddress as $id_package => $package) {
                 $order = new Order();
                 $order->product_list = $package['product_list'];
                 if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
                     $address = new Address($id_address);
                     $this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
                     if (!$this->context->country->active) {
                         throw new PrestaShopException('The delivery address country is not active.');
                     }
                 }
                 $carrier = null;
                 if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
                     $carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
                     $order->id_carrier = (int) $carrier->id;
//.........这里部分代码省略.........
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:101,代码来源:PaymentModule.php

示例6: add

 /**
  * @deprecated 1.5.0.1
  */
 public function add($autodate = true, $nullValues = false, $categories = null)
 {
     $r = parent::add($autodate, $nullValues);
     // Todo : manage categories
     return $r;
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:9,代码来源:Discount.php

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

示例8: dirname

    $cartRule->minimum_amount = (double) Configuration::get('PS_LOYALTY_MINIMAL');
    $cartRule->active = 1;
    $categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY');
    if ($categories != '' and $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']);
        $cartRule->name[(int) $language['id_lang']] = $text ? strval($text) : strval($default_text);
    }
    if (is_array($categories) and sizeof($categories)) {
        $cartRule->add(true, false, $categories);
    } else {
        $cartRule->add();
    }
    /* Register order(s) which contributed to create this voucher */
    if (!LoyaltyModule::registerDiscount($cartRule)) {
        $cartRule->delete();
    }
    Tools::redirect('modules/loyalty/loyalty-program.php');
}
include dirname(__FILE__) . '/../../header.php';
$orders = LoyaltyModule::getAllByIdCustomer((int) $cookie->id_customer, (int) $cookie->id_lang);
$displayorders = LoyaltyModule::getAllByIdCustomer((int) $cookie->id_customer, (int) $cookie->id_lang, false, true, (int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10, (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1);
$smarty->assign(array('orders' => $orders, 'displayorders' => $displayorders, 'pagination_link' => __PS_BASE_URI__ . 'modules/loyalty/loyalty-program.php', 'totalPoints' => (int) $customerPoints, 'voucher' => LoyaltyModule::getVoucherValue($customerPoints, (int) $context->currency->id), 'validation_id' => LoyaltyStateModule::getValidationId(), 'transformation_allowed' => $customerPoints > 0, 'page' => (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1, 'nbpagination' => (int) (Tools::getValue('n') > 0) ? (int) Tools::getValue('n') : 10, 'nArray' => array(10, 20, 50), 'max_page' => floor(sizeof($orders) / ((int) (Tools::getValue('n') > 0) ? (int) Tools::getValue('n') : 10))));
/* Discounts */
$nbDiscounts = 0;
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:31,代码来源:loyalty-program.php

示例9: validateOrder

    /**
     * Validate an order in database
     * Function called from a payment module
     *
     * @param integer $id_cart Value
     * @param integer $id_order_state Value
     * @param float $amount_paid Amount really paid by customer (in the default currency)
     * @param string $payment_method Payment method (eg. 'Credit card')
     * @param string $message Message to attach to order
     */
    public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
    {
        $this->context->cart = new Cart($id_cart);
        $this->context->customer = new Customer($this->context->cart->id_customer);
        $this->context->language = new Language($this->context->cart->id_lang);
        $this->context->shop = $shop ? $shop : new Shop($this->context->cart->id_shop);
        $id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
        $this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
        if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
            $context_country = $this->context->country;
        }
        $order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
        if (!Validate::isLoadedObject($order_status)) {
            throw new PrestaShopException('Can\'t load Order state status');
        }
        if (!$this->active) {
            die(Tools::displayError());
        }
        // Does order already exists ?
        if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
            if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
                die(Tools::displayError());
            }
            // For each package, generate an order
            $delivery_option_list = $this->context->cart->getDeliveryOptionList();
            $package_list = $this->context->cart->getPackageList();
            $cart_delivery_option = $this->context->cart->getDeliveryOption();
            // If some delivery options are not defined, or not valid, use the first valid option
            foreach ($delivery_option_list as $id_address => $package) {
                if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
                    foreach ($package as $key => $val) {
                        $cart_delivery_option[$id_address] = $key;
                        break;
                    }
                }
            }
            $order_list = array();
            $order_detail_list = array();
            $reference = Order::generateReference();
            $this->currentOrderReference = $reference;
            $order_creation_failed = false;
            $cart_total_paid = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
            foreach ($cart_delivery_option as $id_address => $key_carriers) {
                foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
                    foreach ($data['package_list'] as $id_package) {
                        // Rewrite the id_warehouse
                        $package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
                        $package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
                    }
                }
            }
            // Make sure CarRule caches are empty
            CartRule::cleanCache();
            foreach ($package_list as $id_address => $packageByAddress) {
                foreach ($packageByAddress as $id_package => $package) {
                    $order = new Order();
                    $order->product_list = $package['product_list'];
                    if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
                        $address = new Address($id_address);
                        $this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
                    }
                    $carrier = null;
                    if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
                        $carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
                        $order->id_carrier = (int) $carrier->id;
                        $id_carrier = (int) $carrier->id;
                    } else {
                        $order->id_carrier = 0;
                        $id_carrier = 0;
                    }
                    $order->id_customer = (int) $this->context->cart->id_customer;
                    $order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
                    $order->id_address_delivery = (int) $id_address;
                    $order->id_currency = $this->context->currency->id;
                    $order->id_lang = (int) $this->context->cart->id_lang;
                    $order->id_cart = (int) $this->context->cart->id;
                    $order->reference = $reference;
                    $order->id_shop = (int) $this->context->shop->id;
                    $order->id_shop_group = (int) $this->context->shop->id_shop_group;
                    $order->secure_key = $secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key);
                    $order->payment = $payment_method;
                    if (isset($this->name)) {
                        $order->module = $this->name;
                    }
                    $order->recyclable = $this->context->cart->recyclable;
                    $order->gift = (int) $this->context->cart->gift;
                    $order->gift_message = $this->context->cart->gift_message;
                    $order->mobile_theme = $this->context->cart->mobile_theme;
                    $order->conversion_rate = $this->context->currency->conversion_rate;
                    $amount_paid = !$dont_touch_amount ? Tools::ps_round((double) $amount_paid, 2) : $amount_paid;
//.........这里部分代码省略.........
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:101,代码来源:PaymentModule.php

示例10: time

     }
     $voucher->description = 'Discount Fid\'Bag';
     $voucher->id_customer = (int) $cart->id_customer;
     $voucher->reduction_currency = (int) $cart->id_currency;
     $voucher->quantity = 1;
     $voucher->quantity_per_user = 1;
     $voucher->cart_rule_restriction = 1;
     $voucher->cumulable_reduction = 1;
     $voucher->minimum_amount = (double) $voucher->reduction_amount;
     $voucher->reduction_tax = 1;
     $voucher->active = 1;
     $voucher->cart_display = 1;
     $now = time();
     $voucher->date_from = date('Y-m-d H:i:s', $now);
     $voucher->date_to = date('Y-m-d H:i:s', $now + 3600 * 24 * 365.25);
     if (!$voucher->validateFieldsLang(false) || !$voucher->add()) {
         die('0');
     }
     $cart->addCartRule($voucher->id);
 } else {
     $voucher = new Discount();
     $voucher->id_discount_type = 2;
     $voucher->value = $amount;
     $languages = Language::getLanguages(true);
     $voucher->name = 'Fid\'Bag';
     $voucher->description = 'Discount Fid\'Bag';
     $voucher->id_customer = (int) $cart->id_customer;
     $voucher->id_currency = (int) $cart->id_currency;
     $voucher->quantity = 1;
     $voucher->quantity_per_user = 1;
     $voucher->cumulable = 1;
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:31,代码来源:consume_immediate_rebate.php

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