[-] FO : Check for cart rules before diplaying shopping cart in OPC

This commit is contained in:
gRoussac
2013-03-13 18:42:40 +01:00
parent 930e10f87c
commit be6ad7855a
5 changed files with 24 additions and 13 deletions
+1 -1
View File
@@ -1195,7 +1195,7 @@ class CarrierCore extends ObjectModel
$carrier_list = $available_carrier_list; $carrier_list = $available_carrier_list;
if (isset($warehouse_carrier_list)) if (isset($warehouse_carrier_list))
$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list); $carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0) if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0)
{ {
+8 -8
View File
@@ -298,15 +298,15 @@ class AuthControllerCore extends FrontController
$this->context->cart = new Cart($id_cart); $this->context->cart = new Cart($id_cart);
else else
{ {
$this->context->cart->id_carrier = 0; $this->context->cart->id_carrier = 0;
$this->context->cart->setDeliveryOption(null); $this->context->cart->setDeliveryOption(null);
$this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
$this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
} }
$this->context->cart->id_customer = (int)$customer->id; $this->context->cart->id_customer = (int)$customer->id;
$this->context->cart->secure_key = $customer->secure_key; $this->context->cart->secure_key = $customer->secure_key;
$this->context->cart->save(); $this->context->cart->save();
$this->context->cookie->id_cart = (int)$this->context->cart->id; $this->context->cookie->id_cart = (int)$this->context->cart->id;
$this->context->cookie->update(); $this->context->cookie->update();
$this->context->cart->autosetProductAddress(); $this->context->cart->autosetProductAddress();
@@ -396,7 +396,7 @@ class AuthControllerCore extends FrontController
$error_phone = true; $error_phone = true;
elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create'))) elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create')))
&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))) && (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
$error_phone = true; $error_phone = true;
} }
if ($error_phone) if ($error_phone)
@@ -598,7 +598,7 @@ class AuthControllerCore extends FrontController
Tools::redirect('index.php?controller=address'); Tools::redirect('index.php?controller=address');
if ($back = Tools::getValue('back')) if ($back = Tools::getValue('back'))
Tools::redirect(html_entity_decode($back)); Tools::redirect(html_entity_decode($back));
// redirection: if cart is not empty : redirection to the cart // redirection: if cart is not empty : redirection to the cart
if (count($this->context->cart->getProducts(true)) > 0) if (count($this->context->cart->getProducts(true)) > 0)
+13 -2
View File
@@ -289,6 +289,17 @@ class OrderOpcControllerCore extends ParentOrderController
public function initContent() public function initContent()
{ {
parent::initContent(); parent::initContent();
/* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
if (empty($this->context->cart->id_carrier))
{
$checked = $this->context->cart->simulateCarrierSelectedOutput();
$checked = ((int)Cart::desintifier($checked));
$this->context->cart->id_carrier = $checked;
$this->context->cart->update();
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
}
// SHOPPING CART // SHOPPING CART
$this->_assignSummaryInformations(); $this->_assignSummaryInformations();
@@ -337,9 +348,9 @@ class OrderOpcControllerCore extends ParentOrderController
/* Load guest informations */ /* Load guest informations */
if ($this->isLogged && $this->context->cookie->is_guest) if ($this->isLogged && $this->context->cookie->is_guest)
$this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
// ADDRESS
if ($this->isLogged) if ($this->isLogged)
$this->_assignAddress(); // ADDRESS $this->_assignAddress();
// CARRIER // CARRIER
$this->_assignCarrier(); $this->_assignCarrier();
// PAYMENT // PAYMENT
+1 -1
View File
@@ -460,7 +460,7 @@ class ParentOrderControllerCore extends FrontController
$carriers = $this->context->cart->simulateCarriersOutput(); $carriers = $this->context->cart->simulateCarriersOutput();
$checked = $this->context->cart->simulateCarrierSelectedOutput(); $checked = $this->context->cart->simulateCarrierSelectedOutput();
$delivery_option_list = $this->context->cart->getDeliveryOptionList(); $delivery_option_list = $this->context->cart->getDeliveryOptionList();
$this->setDefaultCarrierSelection($this->context->cart->getDeliveryOptionList()); $this->setDefaultCarrierSelection($delivery_option_list);
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'address_collection' => $this->context->cart->getAddressCollection(), 'address_collection' => $this->context->cart->getAddressCollection(),
+1 -1
View File
@@ -629,7 +629,7 @@ $(function() {
// force to refresh carrier list // force to refresh carrier list
if (isGuest) if (isGuest)
{ {
isLogged = 1; isLogged = 1;
$('#opc_account_saved').fadeIn('slow'); $('#opc_account_saved').fadeIn('slow');
$('#submitAccount').hide(); $('#submitAccount').hide();