continuation of moving message gift to shipping cart

This commit is contained in:
Marion Muszynski 2017-07-05 13:15:51 +02:00
parent 40fe9a97b8
commit 5670e21fa3
7 changed files with 127 additions and 33 deletions

View File

@ -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;
}

View File

@ -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);}

View File

@ -322,28 +322,6 @@
<span class="my_gift">{l s='My message : '}</span><br>
<span id="my_gift_message">{nl2br($cart->gift_message)|escape:'UTF-8'}<span>
</p>
<p class="checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
<label for="gift">{l s='I would like the order to be gift-wrapped.'}</label>
</p>
<p id="gift_div" class="textarea">
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
<a id="cart_add_gift_message" class="exclusive">{l s='Enregistré'}</a> <a id="cart_remove_gift_message" class="exclusive">{l s='Supprimer'}</a>
<div class="clear"></div>
</p>
{if !$virtual_cart && $giftAllowed && $cart->gift == 1}
<script type="text/javascript">
{literal}
// <![CDATA[
$('document').ready( function(){
if ($('input#gift').is(':checked'))
$('p#gift_div').show();
});
//]]>
{/literal}
</script>
{/if}
{/if}
{if $site_version == 'es'}
@ -384,6 +362,31 @@
{/if}
<p class="shipping-calculate">{l s='Shipping calculated its step 3'}</p>
{if $giftAllowed}
<p class="checkbox gift_checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
<label for="gift">{l s='I would like the order to be gift-wrapped.'}</label>
</p>
<p id="gift_div" class="textarea">
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
{* <a id="cart_add_gift_message" class="exclusive">{l s='Enregistré'}</a> <a id="cart_remove_gift_message" class="exclusive">{l s='Supprimer'}</a> *}
<div class="clear"></div>
</p>
{if !$virtual_cart && $giftAllowed && $cart->gift == 1}
<script type="text/javascript">
{literal}
// <![CDATA[
$('document').ready( function(){
if ($('input#gift').is(':checked'))
$('p#gift_div').show();
});
//]]>
{/literal}
</script>
{/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 @@
</p> -->
<p class="cart_navigation">
{if !$opc}<a href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
{if !$opc}<a id="go_to_next_step" href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
<a href="{if (isset($smarty.server.HTTP_REFERER) && strstr($smarty.server.HTTP_REFERER, $link->getPageLink('order.php'))) || !isset($smarty.server.HTTP_REFERER)}{$link->getPageLink('index.php')}{else}{$smarty.server.HTTP_REFERER|escape:'htmlall':'UTF-8'|secureReferrer}{/if}" class="button_large" title="{l s='Continue shopping'}">{l s='Continue shopping'}</a>
</p>
<p class="clear"><br /><br /></p>

View File

@ -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;
}

View File

@ -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)

View File

@ -225,7 +225,7 @@
</table>
<div style="display: none;" id="extra_carrier"></div>
{if $giftAllowed}
{* {if $giftAllowed}
<h3 class="gift_title">{l s='Gift'}</h3>
<p class="checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
@ -242,7 +242,7 @@
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
</p>
{/if}
{/if} *}
{/if}
{/if}

View File

@ -156,7 +156,7 @@
<tfoot>
<tr class="cart_total_price{if $shippingCost <= 0} alone{/if}">
<td colspan="2" class="tright">
{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}
</td>
<td colspan="3" class="tleft">
<span class="price" id="total_product">{displayPrice price=$total_products_wt}</span>
@ -228,7 +228,7 @@
<span>{l s='Got voucher ?'}</span>
<span>{l s='Click here to use it'}</span>
</a>
</div>
</div>
<script type="text/javascript">
{literal}
$(function(){
@ -282,8 +282,34 @@
<i class="icon-frais"></i>
<span>{l s='Shipping cost will be calculated on the third step'}</span>
</div>
{if $giftAllowed}
<p class="checkbox gift_checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
<label for="gift">{l s='I would like the order to be gift-wrapped.'}</label>
</p>
<p id="gift_div" class="textarea">
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
<div class="clear"></div>
</p>
{if !$virtual_cart && $giftAllowed && $cart->gift == 1}
<script type="text/javascript">
{literal}
// <![CDATA[
$('document').ready( function(){
if ($('input#gift').is(':checked'))
$('p#gift_div').show();
});
//]]>
{/literal}
</script>
{/if}
{/if}
<div id="HOOK_SHOPPING_CART">{$HOOK_SHOPPING_CART}</div>
{* 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}*}
<p class="cart_navigation">
<a href="{if (isset($smarty.server.HTTP_REFERER) && strstr($smarty.server.HTTP_REFERER, $link->getPageLink('order.php'))) || !isset($smarty.server.HTTP_REFERER)}{$link->getPageLink('index.php')}{else}{$smarty.server.HTTP_REFERER|escape:'htmlall':'UTF-8'|secureReferrer}{/if}" class="button_large" title="{l s='Continue shopping'}">{l s='Continue shopping'}</a>
{if !$opc}<a href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
{if !$opc}<a id="go_to_next_step" href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
</p>
<div class="clear"></div>