12615 - remove automatically ups product from cart, change text displayed in delivery step
This commit is contained in:
parent
5501f37d2d
commit
c8b204e35d
@ -1670,6 +1670,7 @@ class CartCore extends ObjectModel
|
||||
$warehouse_count_by_address[$product['id_address_delivery']][$warehouse['id_warehouse']]++;
|
||||
}
|
||||
}
|
||||
unset($product);
|
||||
|
||||
arsort($warehouse_count_by_address);
|
||||
|
||||
@ -1879,13 +1880,14 @@ class CartCore extends ObjectModel
|
||||
public function getDeliveryOptionList(Country $default_country = null, $flush = false)
|
||||
{
|
||||
static $cache = null;
|
||||
if ($cache !== null && !$flush)
|
||||
if ($cache !== null && !$flush){
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$delivery_option_list = array();
|
||||
$carriers_price = array();
|
||||
$carrier_collection = array();
|
||||
$package_list = $this->getPackageList();
|
||||
$package_list = $this->getPackageList($flush);
|
||||
|
||||
// Foreach addresses
|
||||
foreach ($package_list as $id_address => $packages)
|
||||
@ -2093,8 +2095,10 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
|
||||
// Sort delivery option list
|
||||
foreach ($delivery_option_list as &$array)
|
||||
foreach ($delivery_option_list as &$array){
|
||||
uasort ($array, array('Cart', 'sortDeliveryOptionList'));
|
||||
}
|
||||
unset($array);
|
||||
|
||||
$cache = $delivery_option_list;
|
||||
return $delivery_option_list;
|
||||
|
@ -579,11 +579,23 @@ class Cart extends CartCore
|
||||
{
|
||||
$UPS_ids_reference = array('34', '49');
|
||||
|
||||
$current_id_address_delivery = $this->id_address_delivery;
|
||||
|
||||
// in case tho delivery is already selected, check for the default adress of the customer
|
||||
if (empty($current_id_address_delivery)) {
|
||||
$current_id_address_delivery = Address::getFirstCustomerAddressId($this->id_customer);
|
||||
}
|
||||
|
||||
// in case no adresse has been specified
|
||||
if (empty($current_id_address_delivery)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// get all carrier reference for the current select address' zone delivery
|
||||
$sql = 'SELECT `id_reference`
|
||||
FROM `'._DB_PREFIX_.'carrier` c
|
||||
JOIN `'._DB_PREFIX_.'carrier_zone` cz ON cz.`id_carrier` = c.`id_carrier`
|
||||
WHERE cz.`id_zone` = '.(int)Address::getZoneById($this->id_address_delivery).'
|
||||
WHERE cz.`id_zone` = '.(int)Address::getZoneById($current_id_address_delivery).'
|
||||
AND c.`active` = 1
|
||||
AND c.`deleted` = 0';
|
||||
$rows = Db::getInstance()->executeS($sql);
|
||||
@ -608,7 +620,7 @@ class Cart extends CartCore
|
||||
|
||||
// we exclude this product when UPS is not in its limited list of carriers
|
||||
if (0 == count(array_intersect($UPS_ids_reference, array_column($rows, 'id_carrier_reference')))) {
|
||||
return trim($product['name']);
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,32 +26,73 @@
|
||||
|
||||
class OrderController extends OrderControllerCore
|
||||
{
|
||||
private function updateCartWhenContainProductToExclude()
|
||||
{
|
||||
$restricted_product = $this->context->cart->getExcludedUPSProductNameForUPSDelivery();
|
||||
if (is_array($restricted_product)) {
|
||||
if ($this->context->language->id == 1) {
|
||||
$txt = sprintf('"%s" est un soin qui ne peut malheureusement pas être transporté par voie aérienne. Afin de poursuivre votre commande, nous l\'avons retiré de votre panier.', trim($restricted_product['name']));
|
||||
}
|
||||
else {
|
||||
$txt = sprintf('"%s" cannot be carried by plane. We remove the product from your cart so that you can resume your order.', trim($restricted_product['name']));
|
||||
}
|
||||
$this->addCookieRestrictedProductText($txt);
|
||||
$this->context->smarty->assign('restricted_product_txt', $txt);
|
||||
$this->context->cart->deleteProduct($restricted_product['id_product']);
|
||||
}
|
||||
}
|
||||
|
||||
private function getCookieRestrictedProductText()
|
||||
{
|
||||
if (isset($this->context->cookie->restricted_product_txt)) {
|
||||
return $this->context->cookie->restricted_product_txt;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private function addCookieRestrictedProductText($txt)
|
||||
{
|
||||
$this->context->cookie->restricted_product_txt = $txt;
|
||||
}
|
||||
|
||||
private function removeCookieRestrictedProductText()
|
||||
{
|
||||
if (isset($this->context->cookie->restricted_product_txt)) {
|
||||
unset($this->context->cookie->restricted_product_txt);
|
||||
}
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
// Update carrier selected on preProccess in order to fix a bug of
|
||||
// block cart when it's hooked on leftcolumn
|
||||
if(Tools::isSubmit('submitPanier')){
|
||||
if(Tools::isSubmit('submitPanier')) {
|
||||
$echantillons_ids_product=$_POST['echantillon'];
|
||||
|
||||
// Rajouter les échantillons dans le panier
|
||||
if (!$this->context->cart->saveEchantillons($echantillons_ids_product)) {
|
||||
|
||||
Tools::redirect('index.php?controller=order&step=0&error_echantillons=1');
|
||||
}
|
||||
}
|
||||
if ((int)(Tools::getValue('gift')))
|
||||
{
|
||||
|
||||
if ((int)(Tools::getValue('gift'))) {
|
||||
$this->context->cart->gift = (int)(Tools::getValue('gift'));
|
||||
}
|
||||
if (Tools::getValue('message'))
|
||||
{
|
||||
|
||||
if (Tools::getValue('message')) {
|
||||
$this->context->cart->gift_message = strip_tags($_POST['message']);
|
||||
// die();
|
||||
}
|
||||
|
||||
if (Tools::getValue('step')=='1') {
|
||||
$this->updateCartWhenContainProductToExclude();
|
||||
// force option list to be refreshed
|
||||
$this->context->smarty->assign('delivery_option_list', $this->context->cart->getDeliveryOptionList(null, true));
|
||||
}
|
||||
|
||||
// if ($this->step == 2 && Tools::isSubmit('processCarrier'))
|
||||
// if ($this->step == 1 || ($this->step == 2 && Tools::isSubmit('processAddress')))
|
||||
$this->processCarrier();
|
||||
//$this->processCarrier();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,6 +130,9 @@ class OrderController extends OrderControllerCore
|
||||
{
|
||||
global $isVirtualCart;
|
||||
|
||||
ParentOrderController::initContent();
|
||||
|
||||
|
||||
$this->context->smarty->assign('step', Tools::getValue('step',-2));
|
||||
|
||||
$this->context->cart->checkProductForEchantillon();
|
||||
@ -193,13 +237,17 @@ class OrderController extends OrderControllerCore
|
||||
// Wrapping fees
|
||||
$wrapping_fees = $this->context->cart->getGiftWrappingPrice(false);
|
||||
$wrapping_fees_tax_inc = $wrapping_fees = $this->context->cart->getGiftWrappingPrice();
|
||||
|
||||
$result = array_merge($result, array(
|
||||
'restricted_product_txt' => $this->getCookieRestrictedProductText(),
|
||||
'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'),
|
||||
'HOOK_PAYMENT' => $this->_getPaymentMethods(),
|
||||
'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)($this->context->cookie->id_currency)))),
|
||||
'carrier_data' => $this->_getCarrierList()),
|
||||
$this->getFormatedSummaryDetail()
|
||||
);
|
||||
|
||||
$this->removeCookieRestrictedProductText();
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
}
|
||||
@ -225,8 +273,6 @@ class OrderController extends OrderControllerCore
|
||||
$this->_assignEchantillons();
|
||||
$this->_assignCarrier();
|
||||
// $this->processCarrier();
|
||||
// echo $this->step;
|
||||
// die();
|
||||
$this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl');
|
||||
break;
|
||||
|
||||
@ -235,11 +281,8 @@ class OrderController extends OrderControllerCore
|
||||
Tools::redirect('index.php?controller=order&step=0&error_echantillons=1');
|
||||
}
|
||||
|
||||
// echo "test";
|
||||
// die();
|
||||
// $this->processCarrier();
|
||||
$this->_assignSummaryInformations();
|
||||
$this->_assignCarrier();
|
||||
//$this->_assignCarrier();
|
||||
$this->_assignAddress();
|
||||
$this->autoStep();
|
||||
$this->processAddressFormat();
|
||||
@ -250,17 +293,17 @@ class OrderController extends OrderControllerCore
|
||||
// $this->context->smarty->assign('product_list', $this->context->cart->getProducts());
|
||||
// $this->setTemplate(_PS_THEME_DIR_.'order-address-multishipping.tpl');
|
||||
// }
|
||||
// else
|
||||
// echo "test";
|
||||
// die();
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address.tpl');
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address.tpl');
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
if (count($this->context->cart->getDeliveryAddressesWithoutCarriers(true))>0) {
|
||||
if (is_array($this->context->cart->getExcludedUPSProductNameForUPSDelivery())) {
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
}
|
||||
// if (count($this->context->cart->getDeliveryAddressesWithoutCarriers(true))>0) {
|
||||
// }
|
||||
|
||||
if (!$this->context->cart->isNbEchantillonsInCartAllowed()) {
|
||||
Tools::redirect('index.php?controller=order&step=0&error_echantillons=1');
|
||||
@ -272,7 +315,7 @@ class OrderController extends OrderControllerCore
|
||||
// $this->processAddress();
|
||||
$this->_assignAddress();
|
||||
$this->autoStep();
|
||||
$this->_assignCarrier();
|
||||
//$this->_assignCarrier();
|
||||
// $this->setTemplate(_PS_THEME_DIR_.'order-carrier.tpl');
|
||||
// break;
|
||||
|
||||
@ -388,7 +431,7 @@ class OrderController extends OrderControllerCore
|
||||
'currencyFormat' => $this->context->currency->format,
|
||||
'currencyBlank' => $this->context->currency->blank,
|
||||
));
|
||||
parent::initContent();
|
||||
//parent::initContent();
|
||||
}
|
||||
|
||||
protected function _getCarrierList()
|
||||
@ -566,9 +609,6 @@ class OrderController extends OrderControllerCore
|
||||
|
||||
if ($delivery->deleted || $invoice->deleted)
|
||||
{
|
||||
// echo $delivery->deleted;
|
||||
// echo $invoice->deleted;
|
||||
// die();
|
||||
if ($delivery->deleted)
|
||||
unset($this->context->cart->id_address_delivery);
|
||||
if ($invoice->deleted)
|
||||
@ -716,17 +756,8 @@ class OrderController extends OrderControllerCore
|
||||
|
||||
// return true;
|
||||
|
||||
if (count($this->errors))
|
||||
{
|
||||
// print_r($this->errors);
|
||||
if (count($this->errors)) {
|
||||
$this->context->smarty->assign('errors', $this->errors);
|
||||
// $this->_assignCarrier();
|
||||
// $this->step = 2;
|
||||
// echo $this->step;
|
||||
// die();
|
||||
// $this->displayContent();
|
||||
// include(dirname(__FILE__).'/../footer.php');
|
||||
// exit;
|
||||
}
|
||||
$orderTotal = $this->context->cart->getOrderTotal();
|
||||
}
|
||||
@ -742,7 +773,8 @@ class OrderController extends OrderControllerCore
|
||||
$this->context->cart->autosetProductAddress();
|
||||
|
||||
$this->context->smarty->assign('cart', $this->context->cart);
|
||||
parent::_assignCarrier();
|
||||
//parent::_assignCarrier();
|
||||
$this->_assignCarrier();
|
||||
// Assign wrapping and TOS
|
||||
$this->_assignWrappingAndTOS();
|
||||
|
||||
@ -760,10 +792,8 @@ class OrderController extends OrderControllerCore
|
||||
$list_ids_carrier_mondial_relay[] = $row['id_carrier'];
|
||||
}
|
||||
|
||||
// if (!isset($this->context->customer->id))
|
||||
// die(Tools::displayError('Fatal error: No customer'));
|
||||
// Assign carrier
|
||||
// parent::_assignCarrier();
|
||||
//parent::_assignCarrier();
|
||||
// Assign wrapping and TOS
|
||||
$this->_assignWrappingAndTOS();
|
||||
|
||||
|
@ -61,9 +61,13 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
//update the display of the addresses
|
||||
var is_from_clicked = false;
|
||||
function updateAddressesDisplay(first_view)
|
||||
{
|
||||
// alert(first_view);
|
||||
if (first_view!=true) {
|
||||
is_from_clicked = true;
|
||||
}
|
||||
//alert(first_view);
|
||||
// alert('test');
|
||||
// update content of delivery address
|
||||
// updateAddressDisplay('delivery');
|
||||
@ -199,6 +203,10 @@ function updateCarrierList(json)
|
||||
|
||||
function updateAddressSelection(deliveryAddress)
|
||||
{
|
||||
if (is_from_clicked==true) {
|
||||
$('#restricted_product_txt').removeClass('restricted_initial');
|
||||
}
|
||||
|
||||
var idAddress_delivery = $('#id_address_delivery').val();
|
||||
var idAddress_invoice = ($('#id_address_invoice').length == 1 ? $('#id_address_invoice').val() : ($('#addressesAreEquals:checked').length == 1 ? idAddress_delivery : ($('#id_address_invoice').length == 1 ? $('#id_address_invoice').val() : deliveryAddress)));
|
||||
// alert(refreshAddress);
|
||||
@ -232,6 +240,16 @@ function updateAddressSelection(deliveryAddress)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$('#restricted_product_txt').hasClass('restricted_initial')){
|
||||
$('#restricted_product_txt').html(jsonData.restricted_product_txt);
|
||||
if (jsonData.restricted_product_txt == '') {
|
||||
$('#restricted_product_txt').hide();
|
||||
}
|
||||
else {
|
||||
$('#restricted_product_txt').show();
|
||||
}
|
||||
}
|
||||
|
||||
// Update all product keys with the new address id
|
||||
$('#cart_summary .address_'+deliveryAddress).each(function() {
|
||||
$(this)
|
||||
|
@ -242,7 +242,7 @@
|
||||
<div class="addresses clearfix">
|
||||
<p class="address_delivery select">
|
||||
<label for="id_address_delivery">{if $cart->isVirtualCart()}{l s='Choose a billing address:'}{else}{l s='Choose a delivery address:'}{/if}</label>
|
||||
<select name="id_address_delivery" id="id_address_delivery" class="address_select selectBox selectBox210" onchange="updateAddressesDisplay();{*if $opc}updateAddressSelection();{/if*}">
|
||||
<select name="id_address_delivery" id="id_address_delivery" class="address_select selectBox selectBox210" onchange="updateAddressesDisplay('clicked');{*if $opc}updateAddressSelection();{/if*}">
|
||||
|
||||
{foreach from=$addresses key=k item=address}
|
||||
<option value="{$address.id_address|intval}" {if $address.id_address == $cart->id_address_delivery}selected="selected"{/if}>{$address.alias|escape:'htmlall':'UTF-8'}</option>
|
||||
|
@ -87,6 +87,16 @@
|
||||
<div id="carrier_area" class="opc-main-block">
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
{if isset($restricted_product_txt) && $restricted_product_txt!=''}
|
||||
<p class="warning restricted_initial" id="restricted_product_txt">
|
||||
{$restricted_product_txt}
|
||||
</p>
|
||||
{else}
|
||||
<p class="warning" id="restricted_product_txt" style="display:none"></p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="order_carrier_content">
|
||||
<div id="HOOK_BEFORECARRIER">
|
||||
{if isset($carriers) && isset($HOOK_BEFORECARRIER)}
|
||||
@ -132,26 +142,21 @@
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="hook_extracarrier" id="HOOK_EXTRACARRIER_{$id_address}">{if isset($HOOK_EXTRACARRIER_ADDR) && isset($HOOK_EXTRACARRIER_ADDR.$id_address)}{$HOOK_EXTRACARRIER_ADDR.$id_address}{/if}</div>
|
||||
{foreachelse}
|
||||
{foreachelse}
|
||||
{if !isset($restricted_product_name)}
|
||||
<p class="warning" id="noCarrierWarning">
|
||||
{$restricted_product_name = $cart->getExcludedUPSProductNameForUPSDelivery()}
|
||||
{if $restricted_product_name!=''}
|
||||
{l s='"%s" est un soin qui ne peut malheureusement pas être transporté par voie aérienne.' sprintf=$restricted_product_name}
|
||||
{foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address}
|
||||
{if empty($address->alias)}
|
||||
{l s='No carriers available.'}
|
||||
{else}
|
||||
{l s='No carriers available for the address "%s".' sprintf=$address->alias}
|
||||
{/if}
|
||||
{if !$address@last}
|
||||
<br />
|
||||
{l s='Afin de poursuivre votre commande, nous vous conseillons de le retirer de votre panier ou de choisir une autre adresse de livraison.'}
|
||||
{else}
|
||||
{foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address}
|
||||
{if empty($address->alias)}
|
||||
{l s='No carriers available.'}
|
||||
{else}
|
||||
{l s='No carriers available for the address "%s".' sprintf=$address->alias}
|
||||
{/if}
|
||||
{if !$address@last}
|
||||
<br />
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
</p>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
|
||||
|
@ -86,6 +86,15 @@
|
||||
<div id="carrier_area" class="opc-main-block">
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
{if isset($restricted_product_txt) && $restricted_product_txt!=''}
|
||||
<p class="warning restricted_initial" id="restricted_product_txt">
|
||||
{$restricted_product_txt}
|
||||
</p>
|
||||
{else}
|
||||
<p class="warning" id="restricted_product_txt" style="display:none"></p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="order_carrier_content">
|
||||
<div id="HOOK_BEFORECARRIER">
|
||||
@ -132,26 +141,21 @@
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="hook_extracarrier" id="HOOK_EXTRACARRIER_{$id_address}">{if isset($HOOK_EXTRACARRIER_ADDR) && isset($HOOK_EXTRACARRIER_ADDR.$id_address)}{$HOOK_EXTRACARRIER_ADDR.$id_address}{/if}</div>
|
||||
{foreachelse}
|
||||
{foreachelse}
|
||||
{if !isset($restricted_product_name)}
|
||||
<p class="warning" id="noCarrierWarning">
|
||||
{$restricted_product_name = $cart->getExcludedUPSProductNameForUPSDelivery()}
|
||||
{if $restricted_product_name!=''}
|
||||
{l s='"%s" est un soin qui ne peut malheureusement pas être transporté par voie aérienne.' sprintf=$restricted_product_name}
|
||||
{foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address}
|
||||
{if empty($address->alias)}
|
||||
{l s='No carriers available.'}
|
||||
{else}
|
||||
{l s='No carriers available for the address "%s".' sprintf=$address->alias}
|
||||
{/if}
|
||||
{if !$address@last}
|
||||
<br />
|
||||
{l s='Afin de poursuivre votre commande, nous vous conseillons de le retirer de votre panier ou de choisir une autre adresse de livraison.'}
|
||||
{else}
|
||||
{foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address}
|
||||
{if empty($address->alias)}
|
||||
{l s='No carriers available.'}
|
||||
{else}
|
||||
{l s='No carriers available for the test address "%s".' sprintf=$address->alias}
|
||||
{/if}
|
||||
{if !$address@last}
|
||||
<br />
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
</p>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user