// Multishipping : Refresh carrier list
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10502 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -139,7 +139,7 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
'summary' => $this->context->cart->getSummaryDetails(),
|
||||
'order_opc_adress' => $this->context->smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'),
|
||||
'block_user_info' => (isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : ''),
|
||||
'carrier_list' => $this->_getCarrierList(),
|
||||
'carrier_data' => $this->_getCarrierList(),
|
||||
'HOOK_TOP_PAYMENT' => Hook::exec('paymentTop'),
|
||||
'HOOK_PAYMENT' => $this->_getPaymentMethods(),
|
||||
'no_address' => 0,
|
||||
@@ -195,7 +195,8 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
'summary' => $this->context->cart->getSummaryDetails(),
|
||||
'HOOK_TOP_PAYMENT' => Hook::exec('paymentTop'),
|
||||
'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))))
|
||||
'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()
|
||||
));
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
@@ -422,6 +423,28 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
protected function _getCarrierList()
|
||||
{
|
||||
$address_delivery = new Address($this->context->cart->id_address_delivery);
|
||||
|
||||
$cms = new CMS(Configuration::get('PS_CONDITIONS_CMS_ID'), $this->context->language->id);
|
||||
$link_conditions = $this->context->link->getCMSLink($cms, $cms->link_rewrite, true);
|
||||
if (!strpos($link_conditions, '?'))
|
||||
$link_conditions .= '?content_only=1';
|
||||
else
|
||||
$link_conditions .= '&content_only=1';
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'checkedTOS' => (int)($this->context->cookie->checkedTOS),
|
||||
'recyclablePackAllowed' => (int)(Configuration::get('PS_RECYCLABLE_PACK')),
|
||||
'giftAllowed' => (int)(Configuration::get('PS_GIFT_WRAPPING')),
|
||||
'cms_id' => (int)(Configuration::get('PS_CONDITIONS_CMS_ID')),
|
||||
'conditions' => (int)(Configuration::get('PS_CONDITIONS')),
|
||||
'link_conditions' => $link_conditions,
|
||||
'recyclable' => (int)($this->context->cart->recyclable),
|
||||
'gift_wrapping_price' => (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE')),
|
||||
'delivery_option_list' => $this->context->cart->getDeliveryOptionList(),
|
||||
'delivery_option' => $this->context->cart->getDeliveryOption(),
|
||||
'address_collection' => $this->context->cart->getAddressCollection(),
|
||||
'opc' => true));
|
||||
|
||||
if ($this->context->customer->id)
|
||||
$groups = $this->context->customer->getGroups();
|
||||
else
|
||||
@@ -433,12 +456,14 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
else
|
||||
{
|
||||
$carriers = Carrier::getCarriersForOrder((int)Address::getZoneById((int)($address_delivery->id)), $groups);
|
||||
|
||||
$result = array(
|
||||
'HOOK_BEFORECARRIER' => Hook::exec('beforeCarrier', array(
|
||||
'carriers' => $carriers,
|
||||
'delivery_option_list' => $this->context->cart->getDeliveryOptionList(),
|
||||
'delivery_option' => $this->context->cart->getDeliveryOption()
|
||||
)),
|
||||
'carrier_block' => $this->context->smarty->fetch(_PS_THEME_DIR_.'order-carrier.tpl'),
|
||||
'HOOK_EXTRACARRIER' => Hook::exec('extraCarrier', array('address' => $address_delivery))
|
||||
);
|
||||
return $result;
|
||||
|
||||
@@ -109,7 +109,7 @@ function changeAddressDelivery(obj)
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (jsonData.carriers != null)
|
||||
updateCarrierList(jsonData);
|
||||
getCarrierListAndUpdate();
|
||||
|
||||
// @todo reverse the remove order
|
||||
// This effect remove the current line, but it's better to remove the other one, and refresshing this one
|
||||
@@ -299,7 +299,7 @@ function deleteProductFromSummary(id)
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
if (jsonData.carriers != null)
|
||||
updateCarrierList(jsonData);
|
||||
getCarrierListAndUpdate();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
|
||||
@@ -349,7 +349,7 @@ function upQuantity(id, qty)
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (jsonData.carriers != null)
|
||||
updateCarrierList(jsonData);
|
||||
getCarrierListAndUpdate();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
|
||||
@@ -408,7 +408,7 @@ function downQuantity(id, qty)
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (jsonData.carriers != null)
|
||||
updateCarrierList(jsonData);
|
||||
getCarrierListAndUpdate();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
|
||||
|
||||
@@ -26,79 +26,12 @@
|
||||
|
||||
function updateCarrierList(json)
|
||||
{
|
||||
var carriers = json.carriers;
|
||||
var html = json.carrier_block;
|
||||
|
||||
/* contains all carrier available for this address */
|
||||
if (!carriers || carriers.length == 0)
|
||||
{
|
||||
checkedCarrier = 0;
|
||||
$('input[name=id_carrier]:checked').attr('checked', false);
|
||||
$('#noCarrierWarning').show();
|
||||
$('#extra_carrier').hide();
|
||||
$('#recyclable_block').hide();
|
||||
$('table#carrierTable:visible').hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
checkedCarrier = json.checked;
|
||||
var html = '';
|
||||
for (i=0;i<carriers.length; i++)
|
||||
{
|
||||
var itemType = '';
|
||||
|
||||
if (i == 0)
|
||||
itemType = 'first_item ';
|
||||
else if (i == carriers.length-1)
|
||||
itemType = 'last_item ';
|
||||
if (i % 2)
|
||||
itemType = itemType + 'alternate_item';
|
||||
else
|
||||
itemType = itemType + 'item';
|
||||
|
||||
var name = carriers[i].name;
|
||||
if (carriers[i].img != '')
|
||||
name = '<img src="'+carriers[i].img+'" alt="" />';
|
||||
|
||||
if (carriers[i].is_module > 0 && !isLogged)
|
||||
var extraHtml = 'disabled="disabled"';
|
||||
else if (checkedCarrier == carriers[i].id_carrier)
|
||||
var extraHtml = 'checked="checked"';
|
||||
else
|
||||
var extraHtml = '';
|
||||
|
||||
if (carriers[i].price == 0)
|
||||
var price = txtFree;
|
||||
else
|
||||
{
|
||||
if (taxEnabled && displayPrice == 0)
|
||||
var price = '<span class="price">'+formatCurrency(carriers[i].price, currencyFormat, currencySign, currencyBlank)+'</span>';
|
||||
else
|
||||
var price = '<span class="price">'+formatCurrency(carriers[i].price_tax_exc, currencyFormat, currencySign, currencyBlank)+'</span>';
|
||||
}
|
||||
|
||||
html = html +
|
||||
'<tr class="'+itemType+'">'+
|
||||
'<td class="carrier_action radio"><input type="radio" name="id_carrier" value="'+carriers[i].id_carrier+'" id="id_carrier'+carriers[i].id_carrier+'" onclick="updateCarrierSelectionAndGift();" '+extraHtml+' /></td>'+
|
||||
'<td class="carrier_name"><label for="id_carrier'+carriers[i].id_carrier+'">'+name+'</label></td>'+
|
||||
'<td class="carrier_infos">'+(carriers[i].delay != null ? carriers[i].delay : '')+'</td>'+
|
||||
'<td class="carrier_price">'+price;
|
||||
if (carriers[i].price != 0)
|
||||
{
|
||||
if (taxEnabled && displayPrice == 0)
|
||||
html = html + ' ' + txtWithTax;
|
||||
else
|
||||
html = html + ' ' + txtWithoutTax;
|
||||
}
|
||||
html = html + '</td>'+
|
||||
'</tr>';
|
||||
}
|
||||
if (json.HOOK_EXTRACARRIER !== null && json.HOOK_EXTRACARRIER != undefined) html += json.HOOK_EXTRACARRIER;
|
||||
$('#noCarrierWarning').hide();
|
||||
$('#extra_carrier:hidden').show();
|
||||
$('table#carrierTable tbody').html(html);
|
||||
$('table#carrierTable:hidden').show();
|
||||
$('#recyclable_block:hidden').show();
|
||||
}
|
||||
if (json.HOOK_EXTRACARRIER !== null && json.HOOK_EXTRACARRIER != undefined)
|
||||
html += json.HOOK_EXTRACARRIER;
|
||||
|
||||
$('#carrier_area').replaceWith(html);
|
||||
|
||||
/* update hooks for carrier module */
|
||||
$('#HOOK_BEFORECARRIER').html(json.HOOK_BEFORECARRIER);
|
||||
@@ -139,7 +72,7 @@ function updateAddressSelection()
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCarrierList(jsonData);
|
||||
updateCarrierList(jsonData.carrier_data);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
@@ -193,13 +126,14 @@ function updateCarrierSelectionAndGift()
|
||||
var recyclablePackage = 0;
|
||||
var gift = 0;
|
||||
var giftMessage = '';
|
||||
var idCarrier = 0;
|
||||
|
||||
var delivery_option_radio = $('.delivery_option_radio');
|
||||
var delivery_option_params = '&';
|
||||
$.each(delivery_option_radio, function(i) {
|
||||
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
|
||||
});
|
||||
if (delivery_option_params == '&')
|
||||
delivery_option_params = '&delivery_option=&'
|
||||
|
||||
if ($('input#recyclable:checked').length)
|
||||
recyclablePackage = 1;
|
||||
@@ -209,12 +143,6 @@ function updateCarrierSelectionAndGift()
|
||||
giftMessage = encodeURIComponent($('textarea#gift_message').val());
|
||||
}
|
||||
|
||||
if ($('input[name=id_carrier]:checked').length)
|
||||
{
|
||||
idCarrier = $('input[name=id_carrier]:checked').val();
|
||||
checkedCarrier = idCarrier;
|
||||
}
|
||||
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
@@ -390,7 +318,7 @@ function updateNewAccountToAddressBlock()
|
||||
$('#opc_new_account').fadeIn('fast', function() {
|
||||
updateCartSummary(json.summary);
|
||||
updateAddressesDisplay(true);
|
||||
updateCarrierList(json.carrier_list);
|
||||
updateCarrierList(json.carrier_data);
|
||||
updatePaymentMethods(json);
|
||||
if ($('#gift-price').length == 1)
|
||||
$('#gift-price').html(json.gift_price);
|
||||
@@ -806,6 +734,6 @@ function multishippingMode(it)
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if (multishipping_mode)
|
||||
if (typeof(multishipping_mode) != 'undefined' && multishipping_mode)
|
||||
$('#multishipping_mode').click();
|
||||
});
|
||||
@@ -23,7 +23,7 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<div id="carrier_area">
|
||||
{if !$opc}
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
@@ -60,10 +60,10 @@
|
||||
<script type="text/javascript">
|
||||
{literal}
|
||||
// <![CDATA[
|
||||
$('document').ready( function(){
|
||||
$('document').ready( function(){
|
||||
if ($('input#gift').is(':checked'))
|
||||
$('p#gift_div').show();
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
{/literal}
|
||||
</script>
|
||||
@@ -240,3 +240,4 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user