Merge branch 'ticket-13564-giftOnShoppingCart' into develop
This commit is contained in:
commit
39b9fe9a8f
@ -37,7 +37,7 @@ class OrderHistory extends OrderHistoryCore {
|
||||
|
||||
if (isset($result['template']) AND Validate::isEmail($result['email']))
|
||||
{
|
||||
if($lastOrderState->id == 17 && $this->id_order_state == 4) {
|
||||
if($lastOrderState && $lastOrderState->id == 17 && $this->id_order_state == 4) {
|
||||
$result['template'] .= '_complete';
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class CartController extends CartControllerCore
|
||||
$add = Tools::getIsset('add') ? 1 : 0;
|
||||
$delete = Tools::getIsset('delete') ? 1 : 0;
|
||||
$removeAll = Tools::getIsset('removeall') ? 1 : 0;
|
||||
$giftMessage = Tools::getValue('giftmessage');
|
||||
$giftMessage = Tools::getIsset('giftmessage') ? 1 : 0;
|
||||
|
||||
if (Configuration::get('PS_TOKEN_ENABLE') == 1
|
||||
&& strcasecmp(Tools::getToken(false), strval(Tools::getValue('token')))
|
||||
@ -61,12 +61,6 @@ class CartController extends CartControllerCore
|
||||
if ($add){
|
||||
$current_sale = array();
|
||||
foreach(self::$cart->getProducts() as $product) {
|
||||
/*$current_sale = Db::getInstance()->getRow('
|
||||
SELECT ps.`delivery_delay`, ps.`id_sale`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache` psc
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps ON (ps.`id_sale` = psc.`id_sale`)
|
||||
WHERE psc.`id_product` = '.(int) $product['id_product']
|
||||
);*/
|
||||
|
||||
$sale = Sale::getSaleFromCategory((int)$product['id_category_default'], false);
|
||||
$current_sale = array(
|
||||
@ -77,12 +71,6 @@ class CartController extends CartControllerCore
|
||||
// Only one delivery id per cart, so we can break now
|
||||
break;
|
||||
}
|
||||
/*$adding_sale = Db::getInstance()->getRow('
|
||||
SELECT ps.`delivery_delay`, ps.`id_sale`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache` psc
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps ON (ps.`id_sale` = psc.`id_sale`)
|
||||
WHERE psc.`id_product` = '.(int) $idProduct
|
||||
);*/
|
||||
$current_product = new Product((int) $idProduct);
|
||||
$sale2 = Sale::getSaleFromCategory($current_product->id_category_default, false);
|
||||
$adding_sale = array(
|
||||
@ -91,8 +79,6 @@ class CartController extends CartControllerCore
|
||||
'shipping' => Sale::getShippingSale((int)$sale2->id)
|
||||
);
|
||||
|
||||
//die('{"hasError" : true,"popup_error_cart": true, "errors" : [" '.implode(' , ',$current_sale).' - '.implode(' , ',$adding_sale).'"]}');
|
||||
|
||||
if (!empty($current_sale)) {
|
||||
global $smarty;
|
||||
// Only classic/Noel delivery sales can be added together or product of the same sale or philea sales with same delivery delay
|
||||
@ -301,12 +287,15 @@ class CartController extends CartControllerCore
|
||||
}
|
||||
}
|
||||
}
|
||||
// @End adding Antadis
|
||||
|
||||
// @Adding Antadis - gift message
|
||||
if($giftMessage){
|
||||
if(Tools::getValue('action') == 'remove_all'){
|
||||
self::$cart->gift = 0;
|
||||
self::$cart->gift_message = '';
|
||||
} elseif(Tools::getValue('action') == 'remove_message'){
|
||||
self::$cart->gift = 1;
|
||||
self::$cart->gift_message = '';
|
||||
} elseif(Tools::getValue('action') == 'add_message'){
|
||||
self::$cart->gift = 1;
|
||||
@ -319,6 +308,8 @@ class CartController extends CartControllerCore
|
||||
|
||||
if(self::$cart->update()){
|
||||
die('{"hasError" : false, "action" : "'.Tools::getValue('action').'"}');
|
||||
} else {
|
||||
die('{"hasError" : true, "errors" : ["'.Tools::displayError('Invalid gift message.', false).'"]}');
|
||||
}
|
||||
}
|
||||
// @End adding Antadis
|
||||
|
@ -34,7 +34,7 @@ $(document).ready(function()
|
||||
$('.cart_quantity_delete' ).unbind('click').click(function(){ deletProductFromSummary($(this).attr('id')); return false; });
|
||||
$('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: updateQty });
|
||||
|
||||
$('#go_to_next_step').unbind('click').click(function(){giftMessage(true,true,false);});
|
||||
$('.cart_navigation a#go_to_next_step').click(function(){ return giftMessage(true,true,false); });
|
||||
$('.remove_message_gift').unbind('click').click(function(){ giftMessage(false,false,true); return false; });
|
||||
}
|
||||
});
|
||||
@ -477,6 +477,8 @@ function updateCartSummary(json)
|
||||
}
|
||||
|
||||
function giftMessage(add, next, all){
|
||||
var async = true;
|
||||
var got_next = false;
|
||||
var action = "add_message";
|
||||
if(add == false){
|
||||
if(all == true || !$('input#gift').is(':checked')) {
|
||||
@ -490,17 +492,18 @@ function giftMessage(add, next, all){
|
||||
action = "remove_all";
|
||||
} else {
|
||||
action = "add_message";
|
||||
async = false; // jquery 1.4.4, we have to wait for the response before going to next step
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: baseDir + 'cart.php',
|
||||
async: true,
|
||||
url: baseDir + 'cart.php?giftmessage=1',
|
||||
async: async,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
'ajax':true,
|
||||
'giftmessage' : 1,
|
||||
'action': action,
|
||||
'message': $('#gift_message').val(),
|
||||
'token': static_token
|
||||
@ -510,10 +513,12 @@ function giftMessage(add, next, all){
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(error in jsonData.errors)
|
||||
for(error in jsonData.errors){
|
||||
//IE6 bug fix
|
||||
if(error != 'indexOf')
|
||||
if(error != 'indexOf'){
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
}
|
||||
}
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
@ -537,12 +542,15 @@ function giftMessage(add, next, all){
|
||||
$('#gift_message').val('');
|
||||
}
|
||||
if(next==true){
|
||||
return true;
|
||||
got_next = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {}
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
console.log("ERROR\n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus + "\n" + 'errorThrown: ' + errorThrown);
|
||||
}
|
||||
});
|
||||
return got_next;
|
||||
}
|
||||
|
||||
function updateCustomizedDatas(json)
|
||||
|
@ -34,7 +34,7 @@ $(document).ready(function()
|
||||
$('.cart_quantity_delete' ).unbind('click').click(function(){ deletProductFromSummary($(this).attr('id')); return false; });
|
||||
$('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: updateQty });
|
||||
|
||||
$('#go_to_next_step').unbind('click').click(function(){giftMessage(true,true,false); });
|
||||
$('.cart_navigation a#go_to_next_step').click(function(){ return giftMessage(true,true,false); });
|
||||
}
|
||||
});
|
||||
|
||||
@ -465,6 +465,8 @@ function updateCartSummary(json)
|
||||
}
|
||||
|
||||
function giftMessage(add, next, all){
|
||||
var async = true;
|
||||
var got_next = false;
|
||||
var action = "add_message";
|
||||
if(add == false){
|
||||
if(all == true || !$('input#gift').is(':checked')) {
|
||||
@ -478,17 +480,18 @@ function giftMessage(add, next, all){
|
||||
action = "remove_all";
|
||||
} else {
|
||||
action = "add_message";
|
||||
async = false; // jquery 1.4.4, we have to wait for the response before going to next step
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: baseDir + 'cart.php',
|
||||
async: true,
|
||||
url: baseDir + 'cart.php?giftmessage=1',
|
||||
async: async,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
'ajax':true,
|
||||
'giftmessage' : 1,
|
||||
'action': action,
|
||||
'message': $('#gift_message').val(),
|
||||
'token': static_token
|
||||
@ -514,7 +517,7 @@ function giftMessage(add, next, all){
|
||||
$('#gift').removeAttr('checked');
|
||||
}
|
||||
if(next==true){
|
||||
return true;
|
||||
got_next = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -522,6 +525,7 @@ function giftMessage(add, next, all){
|
||||
//alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
return got_next;
|
||||
}
|
||||
|
||||
function updateCustomizedDatas(json)
|
||||
|
Loading…
Reference in New Issue
Block a user