Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
root 2017-07-06 17:30:46 +02:00
commit 2932eaf5d3
4 changed files with 45 additions and 14 deletions

View File

@ -303,9 +303,11 @@ class CartController extends CartControllerCore
}
if($giftMessage){
if(Tools::getValue('action') == 'remove_message'){
if(Tools::getValue('action') == 'remove_all'){
self::$cart->gift = 0;
self::$cart->gift_message = '';
} elseif(Tools::getValue('action') == 'remove_message'){
self::$cart->gift_message = '';
} elseif(Tools::getValue('action') == 'add_message'){
self::$cart->gift = 1;
self::$cart->gift_message = strip_tags(Tools::getValue('message'));

View File

@ -33,11 +33,9 @@ $(document).ready(function()
$('.cart_quantity_down').unbind('click').click(function(){ downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false; });
$('.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); });
// $('#cart_add_gift_message').unbind('click').click(function(){giftMessage(true); return false; });
// $('#cart_remove_gift_message').unbind('click').click(function(){giftMessage(false); return false; });
$('.remove_message_gift').unbind('click').click(function(){giftMessage(false,false); return false; });
$('#go_to_next_step').unbind('click').click(function(){giftMessage(true,true,false);});
$('.remove_message_gift').unbind('click').click(function(){giftMessage(false,false,true); return false; });
}
});
@ -478,10 +476,21 @@ function updateCartSummary(json)
ajaxCart.refresh();
}
function giftMessage(add, next){
function giftMessage(add, next, all){
var action = "add_message";
if(add == false || $('#gift_message').val()=='' || !$('input#gift').is(':checked')){
var action = "remove_message";
if(add == false ){
if(all == true || !$('input#gift').is(':checked')) {
action = "remove_all";
} else {
action = "remove_message";
}
}
if(add == true){
if(!$('input#gift').is(':checked')){
action = "remove_all";
} else {
action = "add_message";
}
}
$.ajax({
type: 'POST',
@ -513,12 +522,19 @@ function giftMessage(add, next){
message = escape($('#gift_message').val())
$('#my_gift_message').html($('#gift_message').val().replace(/\n/g, "<br/>"));
$('#my_gift').show();
} else {
if($('#gift_message').val()==''){
$('#my_gift').hide();
}
} else if (jsonData.action == "remove_all") {
$('#my_gift_message').html('');
$('#my_gift').hide();
$('#gift_message').val('');
$('#gift_div').hide();
$('#gift').removeAttr('checked');
} else if (jsonData.action == "remove_message") {
$('#my_gift_message').html('');
$('#my_gift').hide();
$('#gift_message').val('');
}
if(next==true){
return true;

View File

@ -317,7 +317,7 @@
</div>
{if $giftAllowed}
<p id="my_gift" {if $cart->gift == 0} style="display:none;" {/if}>
<p id="my_gift" {if $cart->gift == 0 || $cart->gift_message == ''} style="display:none;" {/if}>
<span class="remove_message_gift">X</span>
<span class="my_gift">{l s='My message : '}</span><br>
<span id="my_gift_message">{nl2br($cart->gift_message)|escape:'UTF-8'}<span>

View File

@ -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); });
$('#go_to_next_step').unbind('click').click(function(){giftMessage(true,true,false); });
}
});
@ -464,10 +464,21 @@ function updateCartSummary(json)
ajaxCart.refresh();
}
function giftMessage(add, next){
function giftMessage(add, next, all){
var action = "add_message";
if(add == false || $('#gift_message').val()=='' || !$('input#gift').is(':checked')){
var action = "remove_message";
if(add == false ){
if(all == true || !$('input#gift').is(':checked')) {
action = "remove_all";
} else {
action = "remove_message";
}
}
if(add == true){
if(!$('input#gift').is(':checked')){
action = "remove_all";
} else {
action = "add_message";
}
}
$.ajax({
type: 'POST',
@ -497,6 +508,8 @@ function giftMessage(add, next){
{
if(jsonData.action == "remove_message") {
$('#gift_message').val('');
}else if(jsonData.action == "remove_all"){
$('#gift_message').val('');
$('#gift_div').hide();
$('#gift').removeAttr('checked');
}