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


PHP Discount::delete方法代码示例

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


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

示例1: foreach

 * Delete old voucher
 **/
if (_PS_VERSION_ >= '1.5') {
    $discounts = $context->cart->getCartRules();
} else {
    $discounts = $cart->getDiscounts();
}
if (count($discounts)) {
    foreach ($discounts as $key => $val) {
        if (strcmp($val['name'], 'Fid\'Bag') === 0) {
            if (_PS_VERSION_ >= '1.5') {
                $voucher = new CartRule($val['id_cart_rule']);
            } else {
                $voucher = new Discount($val['id_discount']);
            }
            $voucher->delete();
        }
    }
}
/**
 * create voucher
 **/
if ($amount > 0) {
    if (_PS_VERSION_ >= '1.5') {
        $voucher = new CartRule();
        $voucher->free_shipping = false;
        $voucher->reduction_percent = false;
        $voucher->reduction_amount = $amount;
        $voucher->name = array();
        $languages = Language::getLanguages(true);
        foreach ($languages as $language) {
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:31,代码来源:consume_immediate_rebate.php

示例2: preProcess

 public function preProcess()
 {
     global $isVirtualCart, $cookie;
     parent::preProcess();
     // Redirect to the good order process
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 and (strpos($_SERVER['PHP_SELF'], 'order.php') === false and strpos($_SERVER['PHP_SELF'], 'cart-summary-large.php') === false)) {
         Tools::redirect('order.php');
     }
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 and strpos($_SERVER['PHP_SELF'], 'order-opc.php') === false) {
         if (isset($_GET['step']) and $_GET['step'] == 3) {
             Tools::redirect('order-opc.php?isPaymentStep=true');
         }
         Tools::redirect('order-opc.php');
     }
     if (Configuration::get('PS_CATALOG_MODE')) {
         $this->errors[] = Tools::displayError('This store has not accepted your new order.');
     }
     if (Tools::isSubmit('submitReorder') and $id_order = (int) Tools::getValue('id_order')) {
         $oldCart = new Cart(Order::getCartIdStatic((int) $id_order, (int) self::$cookie->id_customer));
         $duplication = $oldCart->duplicate();
         if (!$duplication or !Validate::isLoadedObject($duplication['cart'])) {
             $this->errors[] = Tools::displayError('Sorry, we cannot renew your order.');
         } elseif (!$duplication['success']) {
             $this->errors[] = Tools::displayError('Missing items - we are unable to renew your order');
         } else {
             self::$cookie->id_cart = $duplication['cart']->id;
             self::$cookie->write();
             if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                 Tools::redirect('order-opc.php');
             }
             Tools::redirect('order.php');
         }
     }
     if (Tools::isSubmit('submit_instructions')) {
         $instructions = Tools::getValue('special_instructions');
         self::$cart->gift_message = pSQL($instructions);
         self::$cart->update();
         Tools::redirect('order?step=3');
     }
     if ($this->nbProducts) {
         /* check discount validity */
         $cartDiscounts = self::$cart->getDiscounts();
         $discountInvalid = false;
         foreach ($cartDiscounts as $k => $cartDiscount) {
             if ($error = self::$cart->checkDiscountValidity(new Discount((int) $cartDiscount['id_discount']), $cartDiscounts, self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING), self::$cart->getProducts())) {
                 self::$cart->deleteDiscount((int) $cartDiscount['id_discount']);
                 $discountInvalid = true;
             }
         }
         if ($discountInvalid) {
             Tools::redirect('order-opc.php');
         }
         if (Tools::getValue('redeem_points')) {
             $points = (int) Tools::getValue('redeem_points');
             if ($points < 1) {
                 self::$smarty->assign('redeem_points', $points);
                 $this->errors[] = Tools::displayError('You can redeem minimum of 1 coin in an order.');
             }
             $orderTotal = self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
             $redemption_status = VBRewards::checkPointsValidity($cookie->id_customer, $points + self::$cart->getPoints(), $orderTotal);
             if ($redemption_status === CAN_REDEEM_COINS) {
                 self::$cart->addPoints($points);
                 self::$smarty->assign('redeem_points', (int) self::$cart->getPoints());
             } else {
                 if ($redemption_status === INSUFFICIENT_VALID_ORDERS) {
                     $this->errors[] = Tools::displayError('Coins can be redeemed from second purchase onwards.');
                 } else {
                     if ($redemption_status === MIN_CRITERIA_NOT_MET) {
                         $this->errors[] = Tools::displayError('Order value should be more than 100 USD to redeem coins');
                     }
                 }
             }
             $this->adjustPoints();
         } elseif (Tools::getValue('deletePoints')) {
             self::$cart->deletePoints();
         }
         if (Tools::isSubmit('submitAddDiscount') and Tools::getValue('discount_name')) {
             $discountName = Tools::getValue('discount_name');
             if (!Validate::isDiscountName($discountName)) {
                 $this->errors[] = Tools::displayError('Voucher name invalid.');
             } else {
                 $discount = new Discount((int) Discount::getIdByName($discountName));
                 if (Validate::isLoadedObject($discount)) {
                     if ($tmpError = self::$cart->checkDiscountValidity($discount, self::$cart->getDiscounts(), self::$cart->getOrderTotal(), self::$cart->getProducts(), true)) {
                         $this->errors[] = $tmpError;
                     }
                 } else {
                     $this->errors[] = Tools::displayError('Voucher name invalid.');
                 }
                 if (!sizeof($this->errors)) {
                     self::$cart->addDiscount((int) $discount->id);
                     Tools::redirect('order-opc.php');
                 }
             }
             self::$smarty->assign(array('errors' => $this->errors, 'discount_name' => Tools::safeOutput($discountName)));
             $this->adjustPoints();
         } elseif (isset($_GET['deleteDiscount']) and Validate::isUnsignedId($_GET['deleteDiscount'])) {
             self::$cart->deleteDiscount((int) $_GET['deleteDiscount']);
             Tools::redirect('order-opc.php');
         }
//.........这里部分代码省略.........
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:101,代码来源:ParentOrderController.php


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