// Retro compatibility and updater improved for Discount/CartRules

This commit is contained in:
dMetzger
2011-11-02 14:23:44 +00:00
parent 61213efb5b
commit 4fbb25168e
21 changed files with 238 additions and 275 deletions
+3 -3
View File
@@ -317,12 +317,12 @@ class AdminCartsController extends AdminController
$errors = array();
$customer = new Customer((int)$this->context->cart->id_customer);
if (!$id_discount = Tools::getValue('id_voucher') OR !$discount = new Discount((int)$id_discount))
if (!$id_cart_rule = Tools::getValue('id_voucher') OR !$cartRule = new CartRule((int)$id_cart_rule))
$errors[] = Tools::displayError('Invalid voucher');
elseif ($err = $this->context->cart->checkDiscountValidity($discount, $this->context->cart->getDiscounts(), $this->context->cart->getOrderTotal(), $this->context->cart->getProducts(), true, $customer))
elseif ($err = $this->context->cart->checkDiscountValidity($cartRule, $this->context->cart->getDiscounts(), $this->context->cart->getOrderTotal(), $this->context->cart->getProducts(), true, $customer))
$errors[] = $err;
if (!sizeof($errors))
if (!$this->context->cart->addDiscount((int)$discount->id))
if (!$this->context->cart->addCartRule((int)$cartRule->id))
$errors[] = Tools::displayError('Can\'t add the voucher');
echo Tools::jsonEncode(array_merge($this->ajaxReturnVars(), array('errors' => $errors)));
}
@@ -253,18 +253,6 @@ class ParentOrderControllerCore extends FrontController
Product::addCustomizationPrice($summary['products'], $customizedDatas);
}
if ($free_ship = Tools::convertPrice((float)(Configuration::get('PS_SHIPPING_FREE_PRICE')), new Currency($this->context->cart->id_currency)))
{
$discounts = $this->context->cart->getCartRules();
$total_free_ship = $free_ship - ($summary['total_products_wt'] + $summary['total_discounts']);
foreach ($discounts as $discount)
if ($discount['id_discount_type'] == Discount::FREE_SHIPPING)
{
$total_free_ship = 0;
break;
}
$this->context->smarty->assign('free_ship', $total_free_ship);
}
foreach ($summary['products'] as $key => &$product)
{
$product['quantity'] = $product['cart_quantity'];// for compatibility with 1.2 themes