// Merging multishipping branche on 1.5
This commit is contained in:
@@ -246,7 +246,6 @@ class AddressControllerCore extends FrontController
|
||||
}
|
||||
else
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
Tools::redirect($mod ? $back.'&back='.$mod : $back);
|
||||
}
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating your address.');
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class CartControllerCore extends FrontController
|
||||
|
||||
protected $id_product;
|
||||
protected $id_product_attribute;
|
||||
protected $id_address_delivery;
|
||||
protected $customization_id;
|
||||
protected $qty;
|
||||
|
||||
@@ -54,6 +55,7 @@ class CartControllerCore extends FrontController
|
||||
$this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
|
||||
$this->customization_id = (int)Tools::getValue('id_customization');
|
||||
$this->qty = abs(Tools::getValue('qty', 1));
|
||||
$this->id_address_delivery = (int)Tools::getValue('id_address_delivery');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
@@ -68,6 +70,10 @@ class CartControllerCore extends FrontController
|
||||
$this->processChangeProductInCart();
|
||||
else if (Tools::getIsset('delete'))
|
||||
$this->processDeleteProductInCart();
|
||||
else if(Tools::getIsset('changeAddressDelivery'))
|
||||
$this->processChangeProductAddressDelivery();
|
||||
else if(Tools::getIsset('duplicate'))
|
||||
$this->processDuplicateProduct();
|
||||
|
||||
// Make redirection
|
||||
if (!$this->errors && !$this->ajax)
|
||||
@@ -94,7 +100,8 @@ class CartControllerCore extends FrontController
|
||||
*/
|
||||
protected function processDeleteProductInCart()
|
||||
{
|
||||
if ($this->context->cart->deleteProduct($this->id_product, $this->id_product_attribute, $this->customization_id))
|
||||
if ($this->context->cart->deleteProduct($this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery))
|
||||
{
|
||||
if (!Cart::getNbProducts((int)($this->context->cart->id)))
|
||||
{
|
||||
$this->context->cart->id_carrier = 0;
|
||||
@@ -102,8 +109,40 @@ class CartControllerCore extends FrontController
|
||||
$this->context->cart->gift_message = '';
|
||||
$this->context->cart->update();
|
||||
}
|
||||
}
|
||||
CartRule::autoRemoveFromCart();
|
||||
}
|
||||
|
||||
protected function processChangeProductAddressDelivery()
|
||||
{
|
||||
$old_id_address_delivery = (int)Tools::getValue('old_id_address_delivery');
|
||||
$new_id_address_delivery = (int)Tools::getValue('new_id_address_delivery');
|
||||
|
||||
$this->context->cart->setProductAddressDelivery(
|
||||
$this->id_product,
|
||||
$this->id_product_attribute,
|
||||
$old_id_address_delivery,
|
||||
$new_id_address_delivery);
|
||||
}
|
||||
|
||||
protected function processDuplicateProduct()
|
||||
{
|
||||
if (
|
||||
!$this->context->cart->duplicateProduct(
|
||||
$this->id_product,
|
||||
$this->id_product_attribute,
|
||||
$this->id_address_delivery,
|
||||
(int)Tools::getValue('new_id_address_delivery'),
|
||||
1,
|
||||
true
|
||||
)
|
||||
)
|
||||
{
|
||||
//$error_message = $this->l('Error durring product duplication');
|
||||
// For the moment no translations
|
||||
$error_message = 'Error durring product duplication';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This process add or update a product in the cart
|
||||
@@ -160,7 +199,7 @@ class CartControllerCore extends FrontController
|
||||
|
||||
if (!$this->errors)
|
||||
{
|
||||
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'));
|
||||
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery, Tools::getValue('op', 'up'));
|
||||
if ($updateQuantity < 0)
|
||||
{
|
||||
// If product has attribute, minimal quantity is set with minimal quantity of attribute
|
||||
|
||||
@@ -64,6 +64,16 @@ class OrderControllerCore extends ParentOrderController
|
||||
|
||||
if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3)))
|
||||
Tools::redirect('index.php?controller=authentication&back='.urlencode('order.php&step='.$this->step));
|
||||
|
||||
if (Tools::getValue('multi-shipping') == 1)
|
||||
$this->context->smarty->assign('multi_shipping', true);
|
||||
else
|
||||
$this->context->smarty->assign('multi_shipping', false);
|
||||
|
||||
if ($this->context->customer->id)
|
||||
$this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
|
||||
else
|
||||
$this->context->smarty->assign('address_list', array());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,11 +94,17 @@ class OrderControllerCore extends ParentOrderController
|
||||
$this->context->smarty->assign('empty', 1);
|
||||
$this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl');
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
$this->_assignAddress();
|
||||
$this->processAddressFormat();
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address.tpl');
|
||||
if (Tools::getValue('multi-shipping') == 1)
|
||||
{
|
||||
$this->_assignSummaryInformations();
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address-multishipping.tpl');
|
||||
}
|
||||
else
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address.tpl');
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -183,6 +199,11 @@ class OrderControllerCore extends ParentOrderController
|
||||
*/
|
||||
public function processAddress()
|
||||
{
|
||||
if (!Tools::getValue('multi-shipping'))
|
||||
$this->context->cart->setNoMultishipping();
|
||||
|
||||
// Add checking for all addresses
|
||||
|
||||
if (!Tools::isSubmit('id_address_delivery') || !Address::isCountryActiveById((int)Tools::getValue('id_address_delivery')))
|
||||
$this->errors[] = Tools::displayError('This address is not in a valid area.');
|
||||
else
|
||||
@@ -213,7 +234,6 @@ class OrderControllerCore extends ParentOrderController
|
||||
protected function processCarrier()
|
||||
{
|
||||
global $orderTotal;
|
||||
|
||||
parent::_processCarrier();
|
||||
|
||||
if (count($this->errors))
|
||||
@@ -227,7 +247,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
}
|
||||
$orderTotal = $this->context->cart->getOrderTotal();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Address step
|
||||
*/
|
||||
@@ -235,6 +255,9 @@ class OrderControllerCore extends ParentOrderController
|
||||
{
|
||||
parent::_assignAddress();
|
||||
|
||||
if (Tools::getValue('multi-shipping'))
|
||||
$this->context->cart->autosetProductAddress();
|
||||
|
||||
$this->context->smarty->assign('cart', $this->context->cart);
|
||||
if ($this->context->customer->is_guest)
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
|
||||
@@ -217,10 +217,8 @@ class ParentOrderControllerCore extends FrontController
|
||||
else
|
||||
$id_zone = Country::getIdZone((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
if (Validate::isInt(Tools::getValue('id_carrier')) && count(Carrier::checkCarrierZone((int)(Tools::getValue('id_carrier')), (int)($id_zone))))
|
||||
$this->context->cart->id_carrier = (int)(Tools::getValue('id_carrier'));
|
||||
else if (!$this->context->cart->isVirtualCart() && (int)(Tools::getValue('id_carrier')) == 0)
|
||||
$this->errors[] = Tools::displayError('Invalid carrier or no carrier selected');
|
||||
if (Tools::getIsset('delivery_option') && $this->validateDeliveryOption(Tools::getValue('delivery_option')))
|
||||
$this->context->cart->delivery_option = serialize(Tools::getValue('delivery_option'));
|
||||
|
||||
Hook::exec('processCarrier', array('cart' => $this->context->cart));
|
||||
|
||||
@@ -230,6 +228,22 @@ class ParentOrderControllerCore extends FrontController
|
||||
// Carrier has changed, so we check if the cart rules still apply
|
||||
CartRule::autoRemoveFromCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate get/post param delivery option
|
||||
* @param array $delivery_option
|
||||
*/
|
||||
protected function validateDeliveryOption($delivery_option)
|
||||
{
|
||||
if (!is_array($delivery_option))
|
||||
return false;
|
||||
|
||||
foreach ($delivery_option as $option)
|
||||
if (!preg_match('/(\d+,)?\d+/', $option))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _assignSummaryInformations()
|
||||
{
|
||||
@@ -364,10 +378,14 @@ class ParentOrderControllerCore extends FrontController
|
||||
$address = new Address($this->context->cart->id_address_delivery);
|
||||
$id_zone = Address::getZoneById($address->id);
|
||||
$carriers = Carrier::getCarriersForOrder($id_zone, $this->context->customer->getGroups());
|
||||
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'checked' => $this->setDefaultCarrierSelection($carriers),
|
||||
'carriers' => $carriers,
|
||||
'address_collection' => $this->context->cart->getAddressCollection(),
|
||||
'delivery_option_list' => $this->context->cart->getDeliveryOptionList(),
|
||||
'delivery_option' => $this->context->cart->getDeliveryOption(),
|
||||
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT'))
|
||||
));
|
||||
$this->context->smarty->assign(array(
|
||||
|
||||
Reference in New Issue
Block a user