From 5670e21fa3ae222e1ca29dc62eb1d95e3e2b4b01 Mon Sep 17 00:00:00 2001
From: Marion Muszynski
Date: Wed, 5 Jul 2017 13:15:51 +0200
Subject: [PATCH] continuation of moving message gift to shipping cart
---
themes/site/css/style.css | 3 ++
themes/site/js/cart-summary.js | 15 +++++---
themes/site/shopping-cart.tpl | 49 ++++++++++++++-------------
themes/site_mobile/css/style.css | 10 ++++++
themes/site_mobile/js/cart-summary.js | 47 +++++++++++++++++++++++++
themes/site_mobile/order-carrier.tpl | 4 +--
themes/site_mobile/shopping-cart.tpl | 32 +++++++++++++++--
7 files changed, 127 insertions(+), 33 deletions(-)
diff --git a/themes/site/css/style.css b/themes/site/css/style.css
index 9366ead6..a80192a1 100755
--- a/themes/site/css/style.css
+++ b/themes/site/css/style.css
@@ -7285,6 +7285,9 @@ table#carrierTable tbody td {
z-index: 800;
}
+#order .gift_checkbox{
+ padding-left: 7px;
+}
#order #center_column #gift_div textarea {
margin-bottom: 5px;
}
diff --git a/themes/site/js/cart-summary.js b/themes/site/js/cart-summary.js
index 8ac8b697..fc8254fe 100755
--- a/themes/site/js/cart-summary.js
+++ b/themes/site/js/cart-summary.js
@@ -33,9 +33,11 @@ $(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 });
- $('#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); return false; });
+ $('#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; });
}
});
@@ -476,9 +478,9 @@ function updateCartSummary(json)
ajaxCart.refresh();
}
-function giftMessage(add){
+function giftMessage(add, next){
var action = "add_message";
- if(add == false){
+ if(add == false || $('#gift_message').val()=='' || !$('input#gift').is(':checked')){
var action = "remove_message";
}
$.ajax({
@@ -518,6 +520,9 @@ function giftMessage(add){
$('#gift_div').hide();
$('#gift').removeAttr('checked');
}
+ if(next==true){
+ return true;
+ }
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
diff --git a/themes/site/shopping-cart.tpl b/themes/site/shopping-cart.tpl
index 873db872..8753ace1 100755
--- a/themes/site/shopping-cart.tpl
+++ b/themes/site/shopping-cart.tpl
@@ -322,28 +322,6 @@
{l s='My message : '}
{nl2br($cart->gift_message)|escape:'UTF-8'}
-
- gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
- {l s='I would like the order to be gift-wrapped.'}
-
-
- {l s='If you wish, you can add a note to the gift:'}
-
- {l s='Enregistré'} {l s='Supprimer'}
-
-
- {if !$virtual_cart && $giftAllowed && $cart->gift == 1}
-
- {/if}
{/if}
{if $site_version == 'es'}
@@ -384,6 +362,31 @@
{/if}
{l s='Shipping calculated its step 3'}
+{if $giftAllowed}
+
+ gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
+ {l s='I would like the order to be gift-wrapped.'}
+
+
+ {l s='If you wish, you can add a note to the gift:'}
+
+ {* {l s='Enregistré'} {l s='Supprimer'} *}
+
+
+ {if !$virtual_cart && $giftAllowed && $cart->gift == 1}
+
+ {/if}
+{/if}
+
{* Define the style if it doesn't exist in the PrestaShop version*}
{* Will be deleted for 1.5 version and more *}
{if !isset($addresses_style)}
@@ -463,7 +466,7 @@
-->
- {if !$opc}{l s='Next'} {/if}
+ {if !$opc}{l s='Next'} {/if}
{l s='Continue shopping'}
diff --git a/themes/site_mobile/css/style.css b/themes/site_mobile/css/style.css
index dfc39a9b..f0b52461 100755
--- a/themes/site_mobile/css/style.css
+++ b/themes/site_mobile/css/style.css
@@ -2640,9 +2640,11 @@ body#order #safety-payment{
}
body#order #shipping_cost_third_step{
border-top: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
color:#434D52;
font-family:Tahoma;
font-size:12px;
+ margin-bottom: 15px;
}
body#order #safety-payment{
border-bottom: 1px solid #ccc;
@@ -3431,6 +3433,7 @@ span.video_wrapper iframe{
}
body#order div#HOOK_SHOPPING_CART {
border-top: 1px solid #E1DDD5;
+ margin-top: 10px;
}
body#order div#HOOK_SHOPPING_CART #invite_credit
{
@@ -5245,3 +5248,10 @@ h3.gift_title {
width: 100%;
margin-bottom: 10px;
}
+
+/***** gift message on shopping cart *****/
+.gift_checkbox input#gift{
+ margin-right: 5px;
+}
+
+
diff --git a/themes/site_mobile/js/cart-summary.js b/themes/site_mobile/js/cart-summary.js
index 6e63f714..3d92eaf5 100755
--- a/themes/site_mobile/js/cart-summary.js
+++ b/themes/site_mobile/js/cart-summary.js
@@ -33,6 +33,8 @@ $(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); });
}
});
@@ -462,6 +464,51 @@ function updateCartSummary(json)
ajaxCart.refresh();
}
+function giftMessage(add, next){
+ var action = "add_message";
+ if(add == false || $('#gift_message').val()=='' || !$('input#gift').is(':checked')){
+ var action = "remove_message";
+ }
+ $.ajax({
+ type: 'POST',
+ url: baseDir + 'cart.php',
+ async: true,
+ cache: false,
+ dataType: 'json',
+ data: {
+ 'ajax':true,
+ 'giftmessage' : 1,
+ 'action': action,
+ 'message': $('#gift_message').val(),
+ 'token': static_token
+ },
+ success: function(jsonData)
+ {
+ if (jsonData.hasError)
+ {
+ var errors = '';
+ for(error in jsonData.errors)
+ //IE6 bug fix
+ if(error != 'indexOf')
+ errors += jsonData.errors[error] + "\n";
+ alert(errors);
+ }
+ else
+ {
+ if(jsonData.action == "remove_message") {
+ $('#gift_message').val('');
+ $('#gift_div').hide();
+ $('#gift').removeAttr('checked');
+ }
+ if(next==true){
+ return true;
+ }
+ }
+ },
+ error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
+ });
+}
+
function updateCustomizedDatas(json)
{
for(i in json)
diff --git a/themes/site_mobile/order-carrier.tpl b/themes/site_mobile/order-carrier.tpl
index 3e5dde95..970fbe8a 100755
--- a/themes/site_mobile/order-carrier.tpl
+++ b/themes/site_mobile/order-carrier.tpl
@@ -225,7 +225,7 @@
- {if $giftAllowed}
+ {* {if $giftAllowed}
{l s='Gift'}
gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
@@ -242,7 +242,7 @@
{l s='If you wish, you can add a note to the gift:'}
- {/if}
+ {/if} *}
{/if}
{/if}
diff --git a/themes/site_mobile/shopping-cart.tpl b/themes/site_mobile/shopping-cart.tpl
index 3b4c6606..5aed96ed 100755
--- a/themes/site_mobile/shopping-cart.tpl
+++ b/themes/site_mobile/shopping-cart.tpl
@@ -156,7 +156,7 @@
- {l s='Total products'}{if $display_tax_label} {l s='(tax incl.)'}{/if}
+ {l s='Total products'}{if $display_tax_label} {l s='(tax incl.)'}{/if}
{displayPrice price=$total_products_wt}
@@ -228,7 +228,7 @@
{l s='Got voucher ?'}
{l s='Click here to use it'}
-
+
+ {/if}
+{/if}
+
{$HOOK_SHOPPING_CART}
+
{* Define the style if it doesn't exist in the PrestaShop version*}
{* Will be deleted for 1.5 version and more *}
{if !isset($addresses_style)}
@@ -354,7 +380,7 @@
{/if}*}
{l s='Continue shopping'}
- {if !$opc}{l s='Next'} {/if}
+ {if !$opc}{l s='Next'} {/if}