[-] MO : Update cart function was not functionning + optis
This commit is contained in:
Vendored
+3
-3
@@ -546,7 +546,7 @@
|
||||
'StateCore' => 'classes/State.php',
|
||||
'StatisticsController' => 'override/controllers/front/StatisticsController.php',
|
||||
'StatisticsControllerCore' => 'controllers/front/StatisticsController.php',
|
||||
'Stock' => 'override/classes/stock/Stock.php',
|
||||
'Stock' => 'override/classes/Stock.php',
|
||||
'StockAvailable' => 'override/classes/stock/StockAvailable.php',
|
||||
'StockAvailableCore' => 'classes/stock/StockAvailable.php',
|
||||
'StockCore' => 'classes/stock/Stock.php',
|
||||
@@ -557,9 +557,9 @@
|
||||
'StockManagerInterface' => 'classes/stock/StockManagerInterface.php',
|
||||
'StockManagerModule' => 'override/classes/stock/StockManagerModule.php',
|
||||
'StockManagerModuleCore' => 'classes/stock/StockManagerModule.php',
|
||||
'StockMvt' => 'override/classes/stock/StockMvt.php',
|
||||
'StockMvt' => 'override/classes/StockMvt.php',
|
||||
'StockMvtCore' => 'classes/stock/StockMvt.php',
|
||||
'StockMvtReason' => 'override/classes/stock/StockMvtReason.php',
|
||||
'StockMvtReason' => 'override/classes/StockMvtReason.php',
|
||||
'StockMvtReasonCore' => 'classes/stock/StockMvtReason.php',
|
||||
'StockMvtWS' => 'override/classes/stock/StockMvtWS.php',
|
||||
'StockMvtWSCore' => 'classes/stock/StockMvtWS.php',
|
||||
|
||||
@@ -23,19 +23,42 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
var ajaxQueries = new Array();
|
||||
|
||||
function resetAjaxQueries()
|
||||
function PS_SE_HandleEvent()
|
||||
{
|
||||
for (i = 0; i < ajaxQueries.length; ++i)
|
||||
ajaxQueries[i].abort();
|
||||
$(document).ready(function() {
|
||||
|
||||
ajaxQueries = new Array();
|
||||
$('#id_country').change(function() {
|
||||
resetAjaxQueries();
|
||||
updateStateByIdCountry();
|
||||
});
|
||||
if (SE_RefreshMethod == 0)
|
||||
{
|
||||
$('#id_state').change(function() {
|
||||
resetAjaxQueries();
|
||||
updateCarriersList();
|
||||
});
|
||||
$('#zipcode').bind('blur keyup',function(e) {
|
||||
if (e.type == 'blur' || e.keyCode == '13')
|
||||
{
|
||||
resetAjaxQueries();
|
||||
updateCarriersList();
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#update_carriers_list').click(function() {
|
||||
updateCarriersList();
|
||||
});
|
||||
$('#carriercompare_submit').click(function() {
|
||||
resetAjaxQueries();
|
||||
saveSelection();
|
||||
return false;
|
||||
});
|
||||
updateStateByIdCountry();
|
||||
});
|
||||
}
|
||||
|
||||
function displayWaitingAjax(type, message)
|
||||
{
|
||||
|
||||
$('#SE_AjaxDisplay').find('p').html(message);
|
||||
$('#SE_AjaxDisplay').css('display', type);
|
||||
}
|
||||
@@ -72,63 +95,67 @@ function updateStateByIdCountry()
|
||||
|
||||
function updateCarriersList()
|
||||
{
|
||||
$('#carriers_list').children().remove();
|
||||
$('#availableCarriers').slideUp('fast');
|
||||
$('#noCarrier').slideUp('fast');
|
||||
displayWaitingAjax('block', SE_RetrievingInfoTS);
|
||||
|
||||
var query = $.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(),
|
||||
data: 'method=getCarriers&id_country=' + $('#id_country').val() + '&id_state=' + $('#id_state').val() + '&zipcode=' + $('#zipcode').val(),
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
if (json.length)
|
||||
{
|
||||
for (carrier in json)
|
||||
$('#carriercompare_errors_list').children().remove();
|
||||
$('#availableCarriers').slideUp('normal', function(){
|
||||
$(this).find(('tbody')).children().remove();
|
||||
$('#noCarrier').slideUp('fast');
|
||||
displayWaitingAjax('block', SE_RetrievingInfoTS);
|
||||
|
||||
var query = $.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(),
|
||||
data: 'method=getCarriers&id_country=' + $('#id_country').val() + '&id_state=' + $('#id_state').val() + '&zipcode=' + $('#zipcode').val(),
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
if (json.length)
|
||||
{
|
||||
var html = '<tr class="'+(carrier % 2 ? 'alternate_' : '')+'item">'+
|
||||
'<td class="carrier_action radio">'+
|
||||
'<input type="radio" name="id_carrier" value="'+json[carrier].id_carrier+'" id="id_carrier'+json[carrier].id_carrier+'" '+(id_carrier == json[carrier].id_carrier ? 'checked="checked"' : '')+'/>'+
|
||||
for (carrier in json)
|
||||
{
|
||||
var html = '<tr class="'+(carrier % 2 ? 'alternate_' : '')+'item">'+
|
||||
'<td class="carrier_action radio">'+
|
||||
'<input type="radio" name="id_carrier" value="'+json[carrier].id_carrier+'" id="id_carrier'+json[carrier].id_carrier+'" '+(id_carrier == json[carrier].id_carrier ? 'checked="checked"' : '')+'/>'+
|
||||
'</td>'+
|
||||
'<td class="carrier_name">'+
|
||||
'<label for="id_carrier'+json[carrier].id_carrier+'">'+
|
||||
(json[carrier].img ? '<img src="'+json[carrier].img+'" alt="'+json[carrier].name+'" />' : json[carrier].name)+
|
||||
'</label>'+
|
||||
'</td>'+
|
||||
'<td class="carrier_name">'+
|
||||
'<label for="id_carrier'+json[carrier].id_carrier+'">'+
|
||||
(json[carrier].img ? '<img src="'+json[carrier].img+'" alt="'+json[carrier].name+'" />' : json[carrier].name)+
|
||||
'</label>'+
|
||||
'</td>'+
|
||||
'<td class="carrier_infos">'+((json[carrier].delay != null) ? json[carrier].delay : '') +'</td>'+
|
||||
'<td class="carrier_price">';
|
||||
|
||||
if (json[carrier].price)
|
||||
{
|
||||
html += '<span class="price">'+(displayPrice == 1 ? formatCurrency(json[carrier].price_tax_exc, currencyFormat, currencySign, currencyBlank) : formatCurrency(json[carrier].price, currencyFormat, currencySign, currencyBlank))+'</span>';
|
||||
'<td class="carrier_infos">'+((json[carrier].delay != null) ? json[carrier].delay : '') +'</td>'+
|
||||
'<td class="carrier_price">';
|
||||
|
||||
if (json[carrier].price)
|
||||
{
|
||||
html += '<span class="price">'+(displayPrice == 1 ? formatCurrency(json[carrier].price_tax_exc, currencyFormat, currencySign, currencyBlank) : formatCurrency(json[carrier].price, currencyFormat, currencySign, currencyBlank))+'</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
html += txtFree;
|
||||
}
|
||||
html += '</td>'+
|
||||
'</tr>';
|
||||
$('#carriers_list').append(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
html += txtFree;
|
||||
}
|
||||
html += '</td>'+
|
||||
'</tr>';
|
||||
$('#carriers_list').append(html);
|
||||
displayWaitingAjax('none', '');
|
||||
$('#availableCarriers').slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
displayWaitingAjax('none', '');
|
||||
$('#noCarrier').slideDown();
|
||||
}
|
||||
$('#availableCarriers').slideDown('fast');
|
||||
}
|
||||
else
|
||||
$('#noCarrier').slideDown('fast');
|
||||
displayWaitingAjax('none', '');
|
||||
}
|
||||
});
|
||||
ajaxQueries.push(query);
|
||||
});
|
||||
ajaxQueries.push(query);
|
||||
}
|
||||
|
||||
|
||||
function saveSelection()
|
||||
{
|
||||
$('#carriercompare_errors').slideUp();
|
||||
$('#carriercompare_errors_list').children().remove();
|
||||
$('#carriercompare_errors').slideUp('fast');
|
||||
displayWaitingAjax('block', SE_RedirectTS);
|
||||
$('#carriercompare_submit').attr('disabled', true);
|
||||
|
||||
|
||||
var query = $.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
@@ -140,9 +167,8 @@ function saveSelection()
|
||||
{
|
||||
for (error in json)
|
||||
$('#carriercompare_errors_list').append('<li>'+json[error]+'</li>');
|
||||
$('#carriercompare_errors').slideDown('fast');
|
||||
$('#carriercompare_errors').slideDown();
|
||||
displayWaitingAjax('none', '');
|
||||
$('#carriercompare_submit').removeAttr('disabled');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -155,35 +181,10 @@ function saveSelection()
|
||||
return false;
|
||||
}
|
||||
|
||||
function PS_SE_HandleEvent()
|
||||
var ajaxQueries = new Array();
|
||||
function resetAjaxQueries()
|
||||
{
|
||||
$(document).ready(function() {
|
||||
$('#id_country').change(function() {
|
||||
resetAjaxQueries();
|
||||
updateStateByIdCountry();
|
||||
});
|
||||
|
||||
if (SE_RefreshMethod == 0)
|
||||
{
|
||||
$('#id_state,#zipcode').change(function() {
|
||||
resetAjaxQueries();
|
||||
updateCarriersList();
|
||||
});
|
||||
$('#zipcode').keyup(function() {
|
||||
resetAjaxQueries();
|
||||
updateCarriersList();
|
||||
});
|
||||
}
|
||||
|
||||
$('#update_carriers_list').click(function() {
|
||||
updateCarriersList();
|
||||
});
|
||||
|
||||
$('#carriercompare_submit').click(function() {
|
||||
resetAjaxQueries();
|
||||
saveSelection();
|
||||
return false;
|
||||
});
|
||||
updateStateByIdCountry();
|
||||
});
|
||||
}
|
||||
for (i = 0; i < ajaxQueries.length; ++i)
|
||||
ajaxQueries[i].abort();
|
||||
ajaxQueries = new Array();
|
||||
}
|
||||
@@ -204,8 +204,17 @@ class CarrierCompare extends Module
|
||||
$this->context->cookie->id_state = $id_state;
|
||||
$this->context->cookie->postcode = $zipcode;
|
||||
$this->context->cart->id_carrier = $id_carrier;
|
||||
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
|
||||
|
||||
$delivery_option = reset($delivery_option_list);
|
||||
$id_carrier = (string)$id_carrier;
|
||||
$id_carrier .= ',';
|
||||
foreach ($delivery_option_list as $id_address => $options)
|
||||
if (isset($options[$id_carrier]))
|
||||
$this->context->cart->setDeliveryOption(array($id_address => $id_carrier));
|
||||
|
||||
if (!$this->context->cart->update())
|
||||
return array($this->l('Cannot update the cart'));
|
||||
return array($this->l('Cannot update the cart'));
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -254,8 +263,8 @@ class CarrierCompare extends Module
|
||||
* If visitor is logged, the module isn't available on Front office,
|
||||
* we use the account informations for carrier selection and taxes.
|
||||
*/
|
||||
if (Context::getContext()->customer->id)
|
||||
return false;
|
||||
/*if (Context::getContext()->customer->id)
|
||||
return false;*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
{*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
**}
|
||||
|
||||
{if !$opc}
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
var taxEnabled = "{$use_taxes}";
|
||||
var displayPrice = "{$priceDisplay}";
|
||||
var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}';
|
||||
var currencyRate = '{$currencyRate|floatval}';
|
||||
var currencyFormat = '{$currencyFormat|intval}';
|
||||
var currencyBlank = '{$currencyBlank|intval}';
|
||||
var id_carrier = '{$id_carrier|intval}';
|
||||
var id_state = '{$id_state|intval}';
|
||||
|
||||
var txtFree = "{l s='Free!' mod='carriercompare'}";
|
||||
//]]>
|
||||
</script>
|
||||
<form class="std" id="compare_shipping_form" method="post" action="#" >
|
||||
<fieldset id="compare_shipping">
|
||||
<h3>{l s='Estimate your shipping & taxes' mod='carriercompare'}</h3>
|
||||
|
||||
<p id="carriercompare_errors" style="display: none;">
|
||||
<ul id="carriercompare_errors_list">
|
||||
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="id_country">{l s='Country' mod='carriercompare'}</label>
|
||||
<select name="id_country" id="id_country">
|
||||
{foreach from=$countries item=country}
|
||||
<option value="{$country.id_country}" {if $id_country == $country.id_country}selected="selected"{/if}>{$country.name|escape:'htmlall':'UTF-8'}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p id="states" style="display: none;">
|
||||
<label for="id_state">{l s='State' mod='carriercompare'}</label>
|
||||
<select name="id_state" id="id_state">
|
||||
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="zipcode">{l s='Zipcode' mod='carriercompare'}</label>
|
||||
<input type="text" name="zipcode" id="zipcode" value="{$zipcode|escape:'htmlall':'UTF-8'}"/> ({l s='Needed for certain carriers' mod='carriercompare'})
|
||||
</p>
|
||||
|
||||
<div id="availableCarriers" style="display: none;">
|
||||
<table cellspacing="0" cellpadding="0" id="availableCarriers_table" class="std">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="carrier_action first_item"></th>
|
||||
<th class="carrier_name item">{l s='Carrier' mod='carriercompare'}</th>
|
||||
<th class="carrier_infos item">{l s='Information' mod='carriercompare'}</th>
|
||||
<th class="carrier_price last_item">{l s='Price' mod='carriercompare'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="carriers_list">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="warning center" id="noCarrier" style="display: none;">{l s='No carrier is available for this selection' mod='carriercompare'}</p>
|
||||
|
||||
<p class="center">
|
||||
<input class="exclusive_large" id="carriercompare_submit" type="submit" name="carriercompare_submit" value="{l s='Refresh' mod='carriercompare'}"/>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
{/if}
|
||||
@@ -21,40 +21,30 @@
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
**}
|
||||
*}
|
||||
|
||||
{if !$opc}
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
var taxEnabled = "{$use_taxes}";
|
||||
var displayPrice = "{$priceDisplay}";
|
||||
var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}';
|
||||
var currencyRate = '{$currencyRate|floatval}';
|
||||
var currencyFormat = '{$currencyFormat|intval}';
|
||||
var currencyBlank = '{$currencyBlank|intval}';
|
||||
var id_carrier = '{$id_carrier|intval}';
|
||||
var id_state = '{$id_state|intval}';
|
||||
var SE_RedirectTS = "{l s='Refreshing page and updating cart...' mod='carriercompare'}";
|
||||
var SE_RefreshStateTS = "{l s='Checking available states...' mod='carriercompare'}";
|
||||
var SE_RetrievingInfoTS = "{l s='Retrieving information...' mod='carriercompare'}";
|
||||
var SE_RefreshMethod = {$refresh_method};
|
||||
|
||||
var txtFree = "{l s='Free!' mod='carriercompare'}";
|
||||
|
||||
PS_SE_HandleEvent();
|
||||
//]]>
|
||||
// <![CDATA[
|
||||
var taxEnabled = "{$use_taxes}";
|
||||
var displayPrice = "{$priceDisplay}";
|
||||
var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}';
|
||||
var currencyRate = '{$currencyRate|floatval}';
|
||||
var currencyFormat = '{$currencyFormat|intval}';
|
||||
var currencyBlank = '{$currencyBlank|intval}';
|
||||
var id_carrier = '{$id_carrier|intval}';
|
||||
var id_state = '{$id_state|intval}';
|
||||
var SE_RedirectTS = "{l s='Refreshing page and updating cart...' mod='carriercompare'}";
|
||||
var SE_RefreshStateTS = "{l s='Checking available states...' mod='carriercompare'}";
|
||||
var SE_RetrievingInfoTS = "{l s='Retrieving information...' mod='carriercompare'}";
|
||||
var SE_RefreshMethod = {$refresh_method};
|
||||
var txtFree = "{l s='Free!' mod='carriercompare'}";
|
||||
PS_SE_HandleEvent();
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<form class="std" id="compare_shipping_form" method="post" action="#" >
|
||||
<fieldset id="compare_shipping">
|
||||
<h3>{l s='Estimate your shipping & taxes' mod='carriercompare'}</h3>
|
||||
|
||||
<p id="carriercompare_errors" style="display: none;">
|
||||
<ul id="carriercompare_errors_list">
|
||||
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="id_country">{l s='Country' mod='carriercompare'}</label>
|
||||
<select name="id_country" id="id_country">
|
||||
@@ -63,24 +53,23 @@
|
||||
{/foreach}
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p id="states" style="display: none;">
|
||||
<label for="id_state">{l s='State' mod='carriercompare'}</label>
|
||||
<select name="id_state" id="id_state">
|
||||
|
||||
<option></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="zipcode">{l s='Zipcode' mod='carriercompare'}</label>
|
||||
<input type="text" name="zipcode" id="zipcode" value="{$zipcode|escape:'htmlall':'UTF-8'}"/> ({l s='Needed for certain carriers' mod='carriercompare'})
|
||||
</p>
|
||||
|
||||
<div id="carriercompare_errors" style="display: none;">
|
||||
<ul id="carriercompare_errors_list"></ul><br />
|
||||
</div>
|
||||
<div id="SE_AjaxDisplay">
|
||||
<img src="{$new_base_dir}loader.gif" /><br />
|
||||
<p></p>
|
||||
</div>
|
||||
|
||||
<div id="availableCarriers" style="display: none;">
|
||||
<table cellspacing="0" cellpadding="0" id="availableCarriers_table" class="std">
|
||||
<thead>
|
||||
@@ -97,7 +86,6 @@
|
||||
</table>
|
||||
</div>
|
||||
<p class="warning center" id="noCarrier" style="display: none;">{l s='No carrier is available for this selection' mod='carriercompare'}</p>
|
||||
|
||||
<p class="SE_SubmitRefreshCard">
|
||||
<input class="exclusive_large" id="carriercompare_submit" type="submit" name="carriercompare_submit" value="{l s='Update Cart' mod='carriercompare'}"/>
|
||||
<input id="update_carriers_list" type="button" class="exclusive_large" value="{l s='Update carrier list' mod='carriercompare'}" />
|
||||
|
||||
Reference in New Issue
Block a user