Jump to content
Daresh

[Free Module] Spend X To Get Free Shipping

Recommended Posts

Update: If you want this module to work for the advanced EU shopping cart, you need to add 

<div id="HOOK_SHOPPING_CART">{$HOOK_SHOPPING_CART}</div> 

code in the shopping-cart-advanced.tpl just after the:

</div> <!-- end order-detail-content -->

post-653890-0-40470800-1451466129_thumb.png

  • Like 1

Share this post


Link to post
Share on other sites

Hello,

 

 

After, installing it, what do I do next to set it up?

 

 

Thanks

Share this post


Link to post
Share on other sites

Hello,

 

you need to have the "Free shipping starts at" configured in Shipping -> Preferences and that should be all, the module does not have any settings, you may only need to translate it to your language.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for your suggestions, I will consider extending the module, but for sure it will only inform about the free shipping, not "spend X to get discount", that should be a job for another module.

Share this post


Link to post
Share on other sites

Allright, so here's what I did to make that information visible in other places, you don't need a special module for it, just to modify your theme (I've tested it with blockart module version 1.6.0)

 

Edit blockcart.tpl

 

To have the information displayed in the blockart, insert the following code around line 191 (in default theme), just after the closing {/if} for $use_taxes condition, at the end of the .cart-prices div:

<p class="free_shipping_not_enough {if $free_shipping <= 0} hidden{/if}">{l s='Spend another' mod='blockcart'} <span class="free_shipping_float">{convertPrice price=$free_shipping}</span> {l s='to get free shipping for your order!' mod='blockcart'}</p>

To have the information displayed on the popup after adding the product to cart, insert the following code just before the .button-container div (around line 320 in the default theme:

<div class="layer_cart_row">
   <p class="free_shipping_not_enough {if $free_shipping <= 0} hidden{/if}">{l s='Spend another' mod='blockcart'} <span class="free_shipping_float">{convertPrice price=$free_shipping}</span> {l s='to get free shipping for your order!' mod='blockcart'}</p>
</div>

Edit ajax-cart.js

 

This is needed to have the block update while adding/removing products.

 

Add

ajaxCart.updateFreeShipping(jsonData);

just after the:

ajaxCart.refreshVouchers(jsonData);

And add the function:

updateFreeShipping : function(jsonData) {
      if (jsonData.freeShippingFloat > 0) {
         $('.free_shipping_not_enough').removeClass('hidden');
         $('.free_shipping_float').text($.trim(jsonData.freeShipping));
      } else {
         $('.free_shipping_not_enough').addClass('hidden');
         $('.ajax_cart_shipping_cost').html(freeShippingTranslation);
      }
   },

just after the:

$('.cart_block .products dt:last').addClass('last_item');
		}
	},

Please let me know if it works.

 

post-653890-0-06038400-1453026465_thumb.png

post-653890-0-46876500-1453026564_thumb.png

post-653890-0-05437200-1453026566_thumb.png

post-653890-0-77857700-1453026566_thumb.png

post-653890-0-95878200-1453026466_thumb.png

 

 

Share this post


Link to post
Share on other sites

Hi Daresh. 

 

Thanks for the great work !! 

I tried to add the code for adding the information to the popup, but it do not show the text in the popup, however it edit the shipping cost line to always says free shipping ?. 

 

after I tried to add the other code for the blockcart, and again I dont see the text. 

 

blockcart Version 1.6.0

PS Version 1.6.1.0

checkout page -> onepagecheckout module Version 2.3.8 by http://www.canin.sk/

 

Regards

Jesper

Dirtytime.dk

Share this post


Link to post
Share on other sites

Much depends on the specific theme that you are using, so you must treat it as an example and adapt, maybe your theme already has some modifications.

Share this post


Link to post
Share on other sites

Okay, I will try and work on it, however it is the default theme bootstrap. 

Share this post


Link to post
Share on other sites

So maybe I'll describe in more detail how it's done so you'll be able to make it work.

 

The blockcart module assigns the variable $free_shipping to smarty, that variable holds the difference between the free shipping threshold and current total. I display it in a paragraph, but first i check if it's <= 0, if so, I add a hidden class so it won't show.

 

In first step, you can only add the .tpl code and experiment in different places to make it visible. If it's visible, the JS adds dynamic updates when adding/removing products.

Share this post


Link to post
Share on other sites

Hello Mate,

 

Nice module,

 

Could you please tell me how i can change font/colour size  ?

Cant see CSS file for this module .

 

Regs

Share this post


Link to post
Share on other sites

Hello,

 

the message is inside a div with class "block_get_free_shipping", so you can customize it by adding some rules to the global.css.

Share this post


Link to post
Share on other sites

Hi Daresh,

 

Thanks for you module.

 

I uploaded the module but impossible to install it !

 

I tried 3 times but it's the same..

 

 

Prestashop 1.6.0.11 - Website is online

Share this post


Link to post
Share on other sites

Hi!

 

Thanks for the module!
I have a question, I use a carrier that varies expenses depending on the country, the free shipping option from a price is always fixed?

 

Thx! ^_^

Share this post


Link to post
Share on other sites

Yes it is fixed according to the free shipping setting, not specific carrier setting.

Share this post


Link to post
Share on other sites

Hi. 

 

I have installed your module, and it works great :) 

However I have 2 carriers with different prices. One more expensive than the other.

 

I want the cheap one to be "Free shipping" over 500 DKK

and the other one to be reduced in price over 500 DKK

 

Before I used the interval in carrier to create this scenario. However I found out that you module take the free shipping price from carrier - settings - free shipping from:

 

I tried editing your code in the file dirtytime.dk/modules/gmgetfreeshipping.php - see below

However it dont work, do you know a solution to this problem. 

 

Thanks :) 

Jesper Dirtytime.dk

    public function hookShoppingCart($params)
    {
        $free_shipping = 500;
        if ($free_shipping) {
            $free_shipping_price = Tools::convertPrice($free_shipping);
            $cart = $this->context->cart;
            $total_without_shipping = $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
            $remaining_to_spend = $free_shipping_price - $total_without_shipping;
            $this->context->smarty->assign(
                array(
                    'free_shipping_price' => $free_shipping_price,
                    'total_without_shipping' => $total_without_shipping,
                    'remaining_to_spend' => $remaining_to_spend
                )
            );
            return $this->display(__FILE__, 'gmgetfreeshipping.tpl');
        }
        return false;
    } 

Share this post


Link to post
Share on other sites

This is a very simple module, based on that general free shipping setting.

 

Making it carrier dependent would require a whole different approach, so maybe you can change the message to something indicating that the customer will get a reduced shipping cost.

Share this post


Link to post
Share on other sites

Hi. 

 

That could be a solution.

 

just a suggestion for a future version:

It could be smart if it was possible to manually specify the free shipping limit in the module, instead of using the free shipping parameter that are general for all carriers. 

that would be a workaround for my problem.

 

thanks anyway :) 

Regards

Jesper 

Share this post


Link to post
Share on other sites

This is a real nice module!

 

But 1 have one problem: when you use a voucher code then the calculation isn't correct.

 

Free shipping is available from 15 €.

But when my total product amount is: 15,34, and there is a discount code used of 0,45, he says: spend another 0,11 to get free shipping :)

 

But offcourse that is also a problem of prestashop.

Because 15,34 - 0,45 discount = lower then the 15 euro free shipping.

Share this post


Link to post
Share on other sites

But does Prestashop apply free shipping when the price drops below 15 € after a voucher?

Share this post


Link to post
Share on other sites

I'm afraid I don't, probably it would require some more core changes.

Share this post


Link to post
Share on other sites

Thanks you Daresh ;) 
 
Your module "Spend X To Get Free Shipping" is really a nice and useful module.
 
Cherry on the cake, it was easy to install, and all the information to add the (same) script on the "Block Cart" module were easy to understand (and to apply)

 

Ciao

 

Takio

Edited by Takio
  • Like 1

Share this post


Link to post
Share on other sites

Hello,

 

the message is inside a div with class "block_get_free_shipping", so you can customize it by adding some rules to the global.css.

Hi, 

 

can you please help me with customizing the message. I can't find "block_get_free_shipping" in global.css file.

Thank you

Share this post


Link to post
Share on other sites

Can you please advice me what to add and where should i add it?

Thank you

Share this post


Link to post
Share on other sites
.block_get_free_shipping {
    color: red;
    font-weight: bold
    padding: 5px;
    background: yellow;
}

For example in global.css. And then set what you want, font size, color, maybe some background color and additional padding...

Share this post


Link to post
Share on other sites

Hi Daresh,

 

Nice module, just what I was looking for, thank you for that!

I'm encountering just one problem, the amount is not updated when I remove/add products to the cart?

 

I've added the code to ajax-cart.js in modules/blockcart/ but nothing is happening? When I have some products

sitting in the cart and I add a new one the amount in the pop-up and blockcart remains the same (it only changes when refreshing the page).

 

I'm doing someting wrong?

if (jsonData.hasError)
		{
			var errors = '';
			for (error in jsonData.errors)
				//IE6 bug fix
				if (error != 'indexOf')
					errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
			alert(errors);
		}
		else
		{
			ajaxCart.updateCartEverywhere(jsonData);
			ajaxCart.hideOldProducts(jsonData);
			ajaxCart.displayNewProducts(jsonData);
			ajaxCart.refreshVouchers(jsonData);
			ajaxCart.updateFreeShipping(jsonData);


			//update 'first' and 'last' item classes
			$('#cart_block .products dt').removeClass('first_item').removeClass('last_item').removeClass('item');
			$('#cart_block .products dt:first').addClass('first_item');
			$('#cart_block .products dt:not(:first,:last)').addClass('item');
			$('#cart_block .products dt:last').addClass('last_item');
			
			//reset the onlick events in relation to the cart block (it allow to bind the onclick event to the new 'delete' buttons added)
			ajaxCart.overrideButtonsInThePage();
		}
	},
	
	updateFreeShipping : function(jsonData) {
      if (jsonData.freeShippingFloat > 0) {
         $('.free_shipping_not_enough').removeClass('hidden');
         $('.free_shipping_float').text($.trim(jsonData.freeShipping));
      } else {
         $('.free_shipping_not_enough').addClass('hidden');
         $('.ajax_cart_shipping_cost').html(freeShippingTranslation);
      }
   },

Share this post


Link to post
Share on other sites

Custom theme, but I was editing the wrong ajax-cart.js file. You must edit the one

defined at theme-level, not the one found in root module folder.

 

It's now working properly for the pop-up and cartblock. But I noticed the text under the productlist in the

order overview screen is not updated when changing the product quantities?

Edited by JeroenDW

Share this post


Link to post
Share on other sites

Weird, that text is in a hook, maybe you have some error in your theme, ajax should update all of it.

Share this post


Link to post
Share on other sites

hi, if i have 200euro for free shipping and need only to see the advide up to 100 euro ... is possible?
thanks  :-)

Share this post


Link to post
Share on other sites

How i can change the language of advice text? I need to show it in italian

 

Thanks in advance

Edited by effemix

Share this post


Link to post
Share on other sites

Hi ,

I tested this solution I did everything what You write but modification not work in developed block cart ... The sam module works great. :D

 

 

*************UPDATE********************

Everything works ! Excellent ! Prestashop 1.6.1.6

Edited by RSI-SHOP

Share this post


Link to post
Share on other sites
good contribution thanks.

 

PS 1.6.1.6 and ajax it does not work.

 

appears the amount but not hancen Simply update when change in the quantities of the product

 

some help?

Share this post


Link to post
Share on other sites

 

good contribution thanks.
 
PS 1.6.1.6 and ajax it does not work.
 
appears the amount but not hancen Simply update when change in the quantities of the product
 
some help?

 

 

If Ajax not works please edit .js file  in You theme ( no module block cart ) edit js in your_theme/js/modules/bolckart/ajax-cart.js ). In this post You have instruction.

Share this post


Link to post
Share on other sites

Thank you so much! This is a great module! I installed on 1.6.1.6 with no problems, and could follow your advice to adapt it to my custom theme, showing up in an extra cart page they have.

 

Thanks again!

Share this post


Link to post
Share on other sites

yes, I know, but I was surprised by the length. I guess that is the image that is generated in the backoffice about your contact details.

Share this post


Link to post
Share on other sites

This module just informs the user, it does not affect shipping costs. If you have a problem with setting up your shipping configuration, create a separate topic for it.

  • Like 1

Share this post


Link to post
Share on other sites

This module just informs the user, it does not affect shipping costs. If you have a problem with setting up your shipping configuration, create a separate topic for it.

OK, got it. I'll remove the posts about the shipping configuration and keep them in the other tutorial post. :)

 

Your module is so easy to use! 

Thank you!

  • Like 1

Share this post


Link to post
Share on other sites

This module displays the "Spend another X to get free shipping for your order" message in the cart just below the product's list, updates the value while adding / substracting product quantity.

 

Works for Prestashop 1.5.x and 1.6.x.

Very nice, easy to install free module!

  • Like 1

Share this post


Link to post
Share on other sites

I've been using this module and it works great. I also used your code to display the message in blockcart and I have no problems there, it updates just as it is supposed to. I additionally added a line of code to product.tpl to display the message under the add to cart button, and it worked without problems as well just until I moved the site to another server. This is the code I inserted to my product.tpl file :

<p class="free_shipping_not_enough {if $free_shipping <= 0} hidden{/if}">{l s='Spend another'} <span class="free_shipping_float">{convertPrice price=$free_shipping}</span> {l s='to get free shipping for your order!'}</p>

Now the message on product page displays only when I update the cart while on this product page. It used to be displayed all the time when the total price of my products in cart was too low to qualify for free shipping. 

 

Is this some server issue since it began after moving the site, or am I missing some code? I would really appreciate your help.

Edited by Bilq

Share this post


Link to post
Share on other sites

Hard to tell, if anything on the store requires page refresh to update, it may be something wrong with the javascript. Maybe you can spot some js error in the console.

Share this post


Link to post
Share on other sites

I don't see any message, but: Attention ce site n'assure les livraisons que dans la zone EURO

Share this post


Link to post
Share on other sites

I've been using this module and it works great. I also used your code to display the message in blockcart and I have no problems there, it updates just as it is supposed to. I additionally added a line of code to product.tpl to display the message under the add to cart button, and it worked without problems as well just until I moved the site to another server. This is the code I inserted to my product.tpl file :

<p class="free_shipping_not_enough {if $free_shipping <= 0} hidden{/if}">{l s='Spend another'} <span class="free_shipping_float">{convertPrice price=$free_shipping}</span> {l s='to get free shipping for your order!'}</p>

Now the message on product page displays only when I update the cart while on this product page. It used to be displayed all the time when the total price of my products in cart was too low to qualify for free shipping. 

 

Is this some server issue since it began after moving the site, or am I missing some code? I would really appreciate your help.

 

I found a solution to my problem. It was probably caused by different file loading order, i don't really know why. But after adding this code at the end of product.tpl file, its tarted working again :)

<script>
$(document).ready(function(){
	ajaxCart.refresh();
});
</script>

Share this post


Link to post
Share on other sites

I have this error : tools.js:63 Uncaught TypeError: price.toFixed is not a function(…)

Do you have an idea ? Thanks,

Share this post


Link to post
Share on other sites

Ok I solve the problem :

I modify in tool.js l 63 : 

price = parseFloat((price*1).toFixed(10));

Thanks :)

 

Share this post


Link to post
Share on other sites

Ho installato il modulo e cambiato lingua. ma nel mio tema il modulo blockart.tlp non trovo dove inserire la stringa . Allego files blockart

{** 2007-2012 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-2012 PrestaShop SA*  @version  Release: $Revision: 6594 $*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free 
License (AFL 3.0)*  International Registered Trademark & Property of PrestaShop SA*}
 
{*************************************************************************************************************************************}
{* IMPORTANT : If you change some data here, you have to report these changes in the ./blockcart-json.js (to let ajaxCart available) *}
{*************************************************************************************************************************************}
 
{if $ajax_allowed}
<script type="text/javascript">var CUSTOMIZE_TEXTFIELD = {$CUSTOMIZE_TEXTFIELD};var customizationIdMessage = '{l s='Customization #' mod='blockcart' js=1}';var removingLinkText = '{l s='remove this product from my cart' mod='blockcart' js=1}';var freeShippingTranslation = '{l s='Free shipping!' mod='blockcart' js=1}';var freeProductTranslation = '{l s='Free!' mod='blockcart' js=1}';var delete_txt = '{l s='Delete' mod='blockcart'}';var img_dir = '{$img_dir}';</script>
{/if}
 
<!-- MODULE Block cart -->
 
<div id="cart_block" class="block exclusive">
<div class="details-border"></div>
<h4>
<a href="{$link->getPageLink("$order_process", true)}">{l s='Cart' mod='blockcart'}</a>
{if $ajax_allowed}
<span id="block_cart_expand" {if isset($colapseExpandStatus) && $colapseExpandStatus eq 'expanded' || !isset($colapseExpandStatus)}class="hidden"{/if}> </span>
<span id="block_cart_collapse" {if isset($colapseExpandStatus) && $colapseExpandStatus eq 'collapsed'}class="hidden"{/if}> </span>
{/if}
</h4>
 
<div class="block_content">
 
<!-- block summary -->
 
<div id="cart_block_summary" class="{if isset($colapseExpandStatus) && $colapseExpandStatus eq 'expanded' || !$ajax_allowed || !isset($colapseExpandStatus)}collapsed{else}expanded{/if}">
<span class="ajax_cart_quantity" {if $cart_qties <= 0}style="display:none;"{/if}>{$cart_qties}</span>
<span class="ajax_cart_product_txt_s" {if $cart_qties <= 1}style="display:none"{/if}>{l s='products' mod='blockcart'}</span>
<span class="ajax_cart_product_txt" {if $cart_qties > 1}style="display:none"{/if}>{l s='product' mod='blockcart'}</span>
<span class="ajax_cart_total" {if $cart_qties <= 0}style="display:none"{/if}>{if $priceDisplay == 1}{convertPrice price=$cart->getOrderTotal(false)}{else}{convertPrice price=$cart->getOrderTotal(true)}{/if}</span>
<span class="ajax_cart_no_product" {if $cart_qties != 0}style="display:none"{/if}>{l s='(empty)' mod='blockcart'}</span>
</div>
 
<!-- block list of products -->
 
<div id="cart_block_list" class="{if isset($colapseExpandStatus) && $colapseExpandStatus eq 'expanded' || !$ajax_allowed || !isset($colapseExpandStatus)}expanded{else}collapsed{/if}">
{if $products}
<dl class="products">
{foreach from=$products item='product' name='myLoop'}
{assign var='productId' value=$product.id_product}
{assign var='productAttributeId' value=$product.id_product_attribute}
 
<dt id="cart_block_product_{$product.id_product}_{if $product.id_product_attribute}{$product.id_product_attribute}{else}0{/if}_{if $product.id_address_delivery}{$product.id_address_delivery}{else}0{/if}" class="clearfix {if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}">
 
 
 
<span style="display: inline-block; float:left"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small')}" alt=""></span>
 
<div id="resume">
 
<span class="quantity-formated"><span class="quantity">{$product.cart_quantity}</span>x</span>
 
<a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}">
{$product.name|truncate:20:'...'|escape:html:'UTF-8'}</a>
<span class="remove_link">{if !isset($customizedDatas.$productId.$productAttributeId) && ($product.total > 0)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&id_product={$product.id_product}&ipa={$product.id_product_attribute}&id_address_delivery={$product.id_address_delivery}&token={$static_token}", true)}" title="{l s='remove this product from my cart' mod='blockcart'}"> </a>{/if}</span>
<span class="price">
{if $product.total > 0}
{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}
{else}
<b>{l s='Free!' mod='blockcart'}</b>
{/if}
</span>
 
</div>
 
 
</dt>
 
 
 
 
{/foreach}
</dl>
{/if}
 
<p {if $products}class="hidden"{/if} id="cart_block_no_products">{l s='No products' mod='blockcart'}</p>
{if $discounts|@count > 0}
 
<table id="vouchers">
<tbody>
{foreach from=$discounts item=discount}
{if $discount.value_real > 0}
<tr class="bloc_cart_voucher" id="bloc_cart_voucher_{$discount.id_discount}">
<td class="quantity">1x</td>
<td class="name" title="{$discount.description}">{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|escape:'htmlall':'UTF-8'}</td>
<td class="price">-{if $priceDisplay == 1}{convertPrice price=$discount.value_tax_exc}{else}{convertPrice price=$discount.value_real}{/if}</td>
<td class="delete">
{if strlen($discount.code)}
<a class="delete_voucher" href="{$link->getPageLink('$order_process.php', true)}?deleteDiscount={$discount.id_discount}" title="{l s='Delete' mod='blockcart'}"><img src="{$img_dir}icon/delete.gif" alt="{l s='Delete' mod='blockcart'}" class="icon" /></a>
{/if}
</td>
</tr>
{/if}
{/foreach}
</tbody>
</table>
{/if}
 
<p id="cart-prices">
 
<span id="cart_block_shipping_cost" class="price ajax_cart_shipping_cost">{$shipping_cost}</span>
<span>{l s='Shipping' mod='blockcart'}</span>
<br/>
{if $show_wrapping}
{assign var='cart_flag' value='Cart::ONLY_WRAPPING'|constant}
<span id="cart_block_wrapping_cost" class="price cart_block_wrapping_cost">{if $priceDisplay == 1}{convertPrice price=$cart->getOrderTotal(false, $cart_flag)}{else}{convertPrice price=$cart->getOrderTotal(true, $cart_flag)}{/if}</span>
<span>{l s='Wrapping' mod='blockcart'}</span>
<br/>
{/if}
{if $show_tax && isset($tax_cost)}
<span id="cart_block_tax_cost" class="price ajax_cart_tax_cost">{$tax_cost}</span>
<span>{l s='Tax' mod='blockcart'}</span>
<br/>
{/if}
<span id="cart_block_total" class="price ajax_block_cart_total">{$total}</span>
<span>{l s='Total' mod='blockcart'}</span>
 
</p>
 
{if $use_taxes && $display_tax_label == 1 && $show_tax}
{if $priceDisplay == 0}
 
<p id="cart-price-precisions">
{l s='Prices are tax included' mod='blockcart'}
</p>
 
{/if}
{if $priceDisplay == 1}
 
<p id="cart-price-precisions">
{l s='Prices are tax excluded' mod='blockcart'}
</p>
 
{/if}
{/if}
 
<p id="cart-buttons">
{if $order_process == 'order'}
<a href="{$link->getPageLink("$order_process.php", true)}" class="button_small" title="{l s='Cart' mod='blockcart'}">{l s='Cart' mod='blockcart'}</a>
{/if}
<a href="{$link->getPageLink("$order_process.php", true)}" id="button_order_cart" class="exclusive{if $order_process == 'order-opc'}_large{/if}" title="{l s='Check out' mod='blockcart'}"><span></span>{l s='Check out' mod='blockcart'}</a>
</p>
 
</div>
 
</div>
</div>
 
<!-- /MODULE Block cart -->

Share this post


Link to post
Share on other sites

Hello, thanks for the module!
I was looking for this function for a few weeks :)

However, I still have a problem with popup after adding the product to cart. The amount left until free shipping is not changing. ( http://prntscr.com/ddycdl )
Free shipping starts at 60 €, after adding the product to cart, the amount in the text is incorrect. It should show 24,09 €.

I changed the ajax-cart in my theme. What else could I do?

 

Share this post


Link to post
Share on other sites

Maybe your theme has some modifications and you need to adapt the code that needs to be changed in the ajax-cart. The code is an example for the default theme.

Share this post


Link to post
Share on other sites

   /*

* 2007-2016 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:
* 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-2016 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
 
// Retrocompatibility with 1.4
if (typeof baseUri === "undefined" && typeof baseDir !== "undefined")
baseUri = baseDir;
 
//JS Object : update the cart by ajax actions
var ajaxCart = {
nb_total_products: 0,
 
//override every button in the page in relation to the cart
overrideButtonsInThePage : function(){
//for every 'add' buttons...
$('.ajax_add_to_cart_button').unbind('click').click(function(){
var idProduct =  $(this).attr('rel').replace('nofollow', '').replace('ajax_id_product_', '');
if ($(this).attr('disabled') != 'disabled')
ajaxCart.add(idProduct, null, false, this);
return false;
});
//for product page 'add' button...
$('#add_to_cart input').unbind('click').click(function(){
ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
return false;
});
 
//for 'delete' buttons in the cart block...
$('#cart_block_list .ajax_cart_block_remove_link').unbind('click').click(function(){
// Customized product management
var customizationId = 0;
var productId = 0;
var productAttributeId = 0;
var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]");
 
if (customizableProductDiv && $(customizableProductDiv).length)
{
$(customizableProductDiv).each(function(){
var ids = $(this).attr('id').split('_');
if (typeof(ids[1]) != 'undefined')
{
customizationId = parseInt(ids[1]);
productId = parseInt(ids[2]);
if (typeof(ids[3]) != 'undefined')
productAttributeId = parseInt(ids[3]);
return false;
}
});
}
 
// Common product management
if (!customizationId)
{
//retrieve idProduct and idCombination from the displayed product in the block cart
var firstCut = $(this).parent().parent().attr('id').replace('cart_block_product_', '');
firstCut = firstCut.replace('deleteCustomizableProduct_', '');
ids = firstCut.split('_');
productId = parseInt(ids[0]);
if (typeof(ids[1]) != 'undefined')
productAttributeId = parseInt(ids[1]);
}
 
var idAddressDelivery = $(this).parent().parent().attr('id').match(/.*_\d+_\d+_(\d+)/)[1];
 
// Removing product from the cart
ajaxCart.remove(productId, productAttributeId, customizationId, idAddressDelivery);
return false;
});
},
 
// try to expand the cart
expand : function(){
if ($('#cart_block_list').hasClass('collapsed'))
{
$('#cart_block_summary').slideUp(200, function(){
$(this).addClass('collapsed').removeClass('expanded');
$('#cart_block_list').slideDown({
duration: 450,
complete: function(){$(this).addClass('expanded').removeClass('collapsed');}
});
});
// toogle the button expand/collapse button
$('#block_cart_expand').fadeOut('slow', function(){
$('#block_cart_collapse').fadeIn('fast');
});
 
// save the expand statut in the user cookie
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
async: true,
cache: false,
data: 'ajax_blockcart_display=expand'
});
 
 
}
},
// Fix display when using back and previous browsers buttons
refresh : function(){
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseUri + '?rand=' + new Date().getTime(),
async: true,
cache: false,
dataType : "json",
data: 'controller=cart&ajax=true&token=' + static_token,
success: function(jsonData)
{
ajaxCart.updateCart(jsonData);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
},
 
// try to collapse the cart
collapse : function(){
 
if ($('#cart_block_list').hasClass('expanded'))
{
$('#cart_block_list').slideUp('slow', function(){
$(this).addClass('collapsed').removeClass('expanded');
$('#cart_block_summary').slideDown(450, function(){
$(this).addClass('expanded').removeClass('collapsed');
});
});
$('#block_cart_collapse').fadeOut('slow', function(){
$('#block_cart_expand').fadeIn('fast');
});
 
// save the expand statut in the user cookie
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
async: true,
cache: false,
data: 'ajax_blockcart_display=collapse' + '&rand=' + new Date().getTime()
});
}
},
 
// Update the cart information
updateCartInformation : function (jsonData, addedFromProductPage)
{
ajaxCart.updateCart(jsonData);
 
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled');
else
$('.ajax_add_to_cart_button').removeAttr('disabled');
},
 
// add a product in the cart via ajax
add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, wishlist){
if (addedFromProductPage && !checkCustomizations())
{
alert(fieldRequired);
return ;
}
emptyCustomizations();
//disabled the button when adding to not double add if user double click
if (addedFromProductPage)
{
$('#add_to_cart input').attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
$('.filled').removeClass('filled');
}
else
$(callerElement).attr('disabled', true);
 
if ($('#cart_block_list').hasClass('collapsed'))
this.expand();
//send the ajax request to the server
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseUri + '?rand=' + new Date().getTime(),
async: true,
cache: false,
dataType : "json",
data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
success: function(jsonData,textStatus,jqXHR)
{
// add appliance to wishlist module
if (wishlist && !jsonData.errors)
WishlistAddProductCart(wishlist[0], idProduct, idCombination, wishlist[1]);
 
// add the picture to the cart
var $element = $(callerElement).parent().parent().find('a.product_image img,a.product_img_link img');
if (!$element.length)
$element = $('#bigpic');
var $picture = $element.clone();
var pictureOffsetOriginal = $element.offset();
pictureOffsetOriginal.right = $(window).innerWidth() - pictureOffsetOriginal.left - $element.width();
 
if ($picture.length)
{
$picture.css({
position: 'absolute',
top: pictureOffsetOriginal.top,
right: pictureOffsetOriginal.right
});
}
 
var pictureOffset = $picture.offset();
var cartBlock = $('#cart_block');
if (!$('#cart_block')[0] || !$('#cart_block').offset().top || !$('#cart_block').offset().left)
cartBlock = $('#shopping_cart');
var cartBlockOffset = cartBlock.offset();
cartBlockOffset.right = $(window).innerWidth() - cartBlockOffset.left - cartBlock.width();
 
// Check if the block cart is activated for the animation
if (cartBlockOffset != undefined && $picture.length)
{
$picture.appendTo('body');
$picture
.css({
position: 'absolute',
top: pictureOffsetOriginal.top,
right: pictureOffsetOriginal.right,
zIndex: 4242
})
.animate({
width: $element.attr('width')*0.66,
height: $element.attr('height')*0.66,
opacity: 0.2,
top: cartBlockOffset.top + 30,
right: cartBlockOffset.right + 15
}, 1000)
.fadeOut(100, function() {
ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
$(this).remove();
});
}
else
ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert("Impossible to add the product to the cart.\n\ntextStatus: '" + textStatus + "'\nerrorThrown: '" + errorThrown + "'\nresponseText:\n" + XMLHttpRequest.responseText);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled');
else
$(callerElement).removeAttr('disabled');
}
});
},
 
//remove a product from the cart via ajax
remove : function(idProduct, idCombination, customizationId, idAddressDelivery){
//send the ajax request to the server
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseUri + '?rand=' + new Date().getTime(),
async: true,
cache: false,
dataType : "json",
data: 'controller=cart&delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
success: function(jsonData) {
ajaxCart.updateCart(jsonData);
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
deleteProductFromSummary(idProduct+'_'+idCombination+'_'+customizationId+'_'+idAddressDelivery);
},
error: function() {alert('ERROR: unable to delete the product');}
});
},
 
//hide the products displayed in the page but no more in the json data
hideOldProducts : function(jsonData) {
//delete an eventually removed product of the displayed cart (only if cart is not empty!)
if ($('#cart_block_list dl.products').length > 0)
{
var removedProductId = null;
var removedProductData = null;
var removedProductDomId = null;
//look for a product to delete...
$('#cart_block_list dl.products dt').each(function(){
//retrieve idProduct and idCombination from the displayed product in the block cart
var domIdProduct = $(this).attr('id');
var firstCut =  domIdProduct.replace('cart_block_product_', '');
var ids = firstCut.split('_');
 
//try to know if the current product is still in the new list
var stayInTheCart = false;
for (aProduct in jsonData.products)
{
//we've called the variable aProduct because IE6 bug if this variable is called product
//if product has attributes
if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1]))
{
stayInTheCart = true;
// update the product customization display (when the product is still in the cart)
ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], domIdProduct);
}
}
//remove product if it's no more in the cart
if (!stayInTheCart)
{
removedProductId = $(this).attr('id');
if (removedProductId != null)
{
var firstCut =  removedProductId.replace('cart_block_product_', '');
var ids = firstCut.split('_');
 
$('#'+removedProductId).addClass('strike').fadeTo('slow', 0, function(){
$(this).slideUp('slow', function(){
$(this).remove();
// If the cart is now empty, show the 'no product in the cart' message and close detail
if($('#cart_block dl.products dt').length == 0)
{
$("#header #cart_block").stop(true, true).slideUp(200);
$('#cart_block_no_products:hidden').slideDown(450);
$('#cart_block dl.products').remove();
}
});
});
$('#cart_block_combination_of_' + ids[0] + (ids[1] ? '_'+ids[1] : '') + (ids[2] ? '_'+ids[2] : '')).fadeTo('fast', 0, function(){
$(this).slideUp('fast', function(){
$(this).remove();
});
});
}
}
});
}
},
 
hideOldProductCustomizations : function (product, domIdProduct)
{
var customizationList = $('#customization_' + product['id'] + '_' + product['idCombination']);
if(customizationList.length > 0)
{
$(customizationList).find("li").each(function(){
$(this).find("div").each(function() {
var customizationDiv = $(this).attr('id');
var tmp = customizationDiv.replace('deleteCustomizableProduct_', '');
var ids = tmp.split('_');
if ((parseInt(product.idCombination) == parseInt(ids[2])) && !ajaxCart.doesCustomizationStillExist(product, ids[0]))
$('#' + customizationDiv).parent().addClass('strike').fadeTo('slow', 0, function(){
$(this).slideUp('slow');
$(this).remove();
});
});
});
}
 
var removeLinks = $('#' + domIdProduct).find('.ajax_cart_block_remove_link');
if (!product.hasCustomizedDatas && !removeLinks.length)
$('#' + domIdProduct + ' span.remove_link').html('<a class="ajax_cart_block_remove_link" rel="nofollow" href="' + baseUri + '?controller=cart&delete=1&id_product=' + product['id'] + '&ipa=' + product['idCombination'] + '&token=' + static_token + '"> </a>');
if (product.is_gift)
$('#' + domIdProduct + ' span.remove_link').html('');
},
 
doesCustomizationStillExist : function (product, customizationId)
{
var exists = false;
 
$(product.customizedDatas).each(function() {
if (this.customizationId == customizationId)
{
exists = true;
// This return does not mean that we found nothing but simply break the loop
return false;
}
});
return (exists);
},
 
//refresh display of vouchers (needed for vouchers in % of the total)
refreshVouchers : function (jsonData) {
if (typeof(jsonData.discounts) == 'undefined' || jsonData.discounts.length == 0)
$('#vouchers').hide();
else
{
$('#vouchers tbody').html('');
for (i=0; i < jsonData.discounts.length; i++)
{
if (parseFloat(jsonData.discounts.price_float) > 0)
{
var delete_link = '';
if (jsonData.discounts.code.length)
delete_link = '<a class="delete_voucher" href="'+jsonData.discounts.link+'" title="'+delete_txt+'"><img src="'+img_dir+'icon/delete.gif" alt="'+delete_txt+'" class="icon" /></a>';
$('#vouchers tbody').append($(
'<tr class="bloc_cart_voucher" id="bloc_cart_voucher_'+jsonData.discounts.id+'">'
+ '<td class="quantity">1x</td>'
+ '<td class="name" title="'+jsonData.discounts.description+'">'+jsonData.discounts.name+'</td>'
+ '<td class="price">-'+jsonData.discounts.price+'</td>'
+ '<td class="delete">' + delete_link + '</td>'
+ '</tr>'
));
}
}
$('#vouchers').show();
}
 
},
 
// Update product quantity
updateProductQuantity : function (product, quantity) {
 
$('#cart_block_product_' + product.id + '_' + (product.idCombination ? product.idCombination : '0')+ '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + ' .quantity').fadeTo('fast', 0, function() {
$(this).text(quantity);
$(this).fadeTo('fast', 1, function(){
$(this).fadeTo('fast', 0, function(){
$(this).fadeTo('fast', 1, function(){
$(this).fadeTo('fast', 0, function(){
$(this).fadeTo('fast', 1);
});
});
});
});
});
},
 
 
//display the products witch are in json data but not already displayed
displayNewProducts : function(jsonData) {
 
//add every new products or update displaying of every updated products
$(jsonData.products).each(function(){
//fix ie6 bug (one more item 'undefined' in IE6)
if (this.id != undefined)
{
//create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty)
 
if ($('#cart_block dl.products').length == 0)
{
$('#cart_block_no_products').before('<dl class="products"></dl>');
$('#cart_block_no_products').hide();
}
//if product is not in the displayed cart, add a new product's line
var domIdProduct = this.id + '_' + (this.idCombination ? this.idCombination : '0') + '_' + (this.idAddressDelivery ? this.idAddressDelivery : '0');
var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');
if ($('#cart_block_product_'+ domIdProduct).length == 0)
{
var productId = parseInt(this.id);
var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
var content =  '<dt class="hidden" id="cart_block_product_' + domIdProduct + '">';
content += '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>x</span>';
var name = $('<span />').html(this.name).text();
name = (name.length > 12 ? name.substring(0, 10) + '...' : name);
content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a>';
 
if (typeof(this.is_gift) == 'undefined' || this.is_gift == 0)
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&token=' + static_token + (this.hasAttributes ? '&ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
else
content += '<span class="remove_link"></span>';
if (typeof(freeProductTranslation) != 'undefined')
content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span>';
content += '</dt>';
if (this.hasAttributes)
 content += '<dd id="cart_block_combination_of_' + domIdProduct + '" class="hidden"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a>';
if (this.hasCustomizedDatas)
content += ajaxCart.displayNewCustomizedDatas(this);
if (this.hasAttributes) content += '</dd>';
 
$('#cart_block dl.products').append(content);
}
//else update the product's line
else
{
var jsonProduct = this;
if($.trim($('#cart_block_product_' + domIdProduct + ' .quantity').html()) != jsonProduct.quantity || $.trim($('#cart_block_product_' + domIdProduct + ' .price').html()) != jsonProduct.priceByLine)
{
// Usual product
if (!this.is_gift)
$('#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine);
else
$('#cart_block_product_' + domIdProduct + ' .price').html(freeProductTranslation);
ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.quantity);
 
// Customized product
if (jsonProduct.hasCustomizedDatas)
{
customizationFormatedDatas = ajaxCart.displayNewCustomizedDatas(jsonProduct);
if (!$('#customization_' + domIdProductAttribute).length)
{
if (jsonProduct.hasAttributes)
$('#cart_block_combination_of_' + domIdProduct).append(customizationFormatedDatas);
else
$('#cart_block dl.products').append(customizationFormatedDatas);
}
else
{
$('#customization_' + domIdProductAttribute).html('');
$('#customization_' + domIdProductAttribute).append(customizationFormatedDatas);
}
}
}
}
$('#cart_block dl.products .hidden').slideDown(450).removeClass('hidden');
 
var removeLinks = $('#cart_block_product_' + domIdProduct).find('a.ajax_cart_block_remove_link');
if (this.hasCustomizedDatas && removeLinks.length)
$(removeLinks).each(function() {
$(this).remove();
});
}
});
},
 
displayNewCustomizedDatas : function(product)
{
var content = '';
var productId = parseInt(product.id);
var productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
var hasAlreadyCustomizations = $('#customization_' + productId + '_' + productAttributeId).length;
 
if (!hasAlreadyCustomizations)
{
if (!product.hasAttributes)
content += '<dd id="cart_block_combination_of_' + productId + '" class="hidden">';
if ($('#customization_' + productId + '_' + productAttributeId).val() == undefined)
content += '<ul class="cart_block_customizations" id="customization_' + productId + '_' + productAttributeId + '">';
}
 
$(product.customizedDatas).each(function()
{
var done = 0;
customizationId = parseInt(this.customizationId);
productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
content += '<li name="customization"><div class="deleteCustomizableProduct" id="deleteCustomizableProduct_' + customizationId + '_' + productId + '_' + (productAttributeId ?  productAttributeId : '0') + '"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&ipa=' + productAttributeId + '&id_customization=' + customizationId + '&token=' + static_token + '"></a></div><span class="quantity-formated"><span class="quantity">' + parseInt(this.quantity) + '</span>x</span>';
 
// Give to the customized product the first textfield value as name
$(this.datas).each(function(){
if (this['type'] == CUSTOMIZE_TEXTFIELD)
{
$(this.datas).each(function(){
if (this['index'] == 0)
{
content += ' ' + this.truncatedValue.replace(/<br \/>/g, ' ');
done = 1;
return false;
}
})
}
});
 
// If the customized product did not have any textfield, it will have the customizationId as name
if (!done)
content += customizationIdMessage + customizationId;
if (!hasAlreadyCustomizations) content += '</li>';
// Field cleaning
if (customizationId)
{
$('#uploadable_files li div.customizationUploadBrowse img').remove();
$('#text_fields textarea').val('');
}
});
 
if (!hasAlreadyCustomizations)
{
content += '</ul>';
if (!product.hasAttributes) content += '</dd>';
}
return (content);
},
 
 
//genarally update the display of the cart
updateCart : function(jsonData) {
//user errors display
if (jsonData.hasError)
{
var errors = '';
for (error in jsonData.errors)
//IE6 bug fix
if (error != 'indexOf')
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors);
}
else
{
ajaxCart.updateCartEverywhere(jsonData);
ajaxCart.hideOldProducts(jsonData);
ajaxCart.displayNewProducts(jsonData);
ajaxCart.refreshVouchers(jsonData);
 
//update 'first' and 'last' item classes
$('#cart_block .products dt').removeClass('first_item').removeClass('last_item').removeClass('item');
$('#cart_block .products dt:first').addClass('first_item');
$('#cart_block .products dt:not(:first,:last)').addClass('item');
$('#cart_block .products dt:last').addClass('last_item');
 
//reset the onlick events in relation to the cart block (it allow to bind the onclick event to the new 'delete' buttons added)
ajaxCart.overrideButtonsInThePage();
}
},
 
//update general cart informations everywhere in the page
updateCartEverywhere : function(jsonData) {
$('.ajax_cart_total').text($.trim(jsonData.productTotal));
 
if (parseFloat(jsonData.shippingCostFloat) > 0 || jsonData.nbTotalProducts < 1)
$('.ajax_cart_shipping_cost').text(jsonData.shippingCost);
else if (typeof(freeShippingTranslation) != 'undefined')
$('.ajax_cart_shipping_cost').html(freeShippingTranslation);
$('.ajax_cart_tax_cost').text(jsonData.taxCost);
$('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
$('.ajax_block_cart_total').text(jsonData.total);
 
this.nb_total_products = jsonData.nbTotalProducts;
 
if (parseInt(jsonData.nbTotalProducts) > 0)
{
$('.ajax_cart_no_product').hide();
$('.ajax_cart_quantity').text(jsonData.nbTotalProducts);
$('.ajax_cart_quantity').fadeIn('slow');
$('.ajax_cart_total').fadeIn('slow');
 
if (parseInt(jsonData.nbTotalProducts) > 1)
{
$('.ajax_cart_product_txt').each( function () {
$(this).hide();
});
 
$('.ajax_cart_product_txt_s').each( function () {
$(this).show();
});
}
else
{
$('.ajax_cart_product_txt').each( function () {
$(this).show();
});
 
$('.ajax_cart_product_txt_s').each( function () {
$(this).hide();
});
}
}
else
{
$('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each(function(){
$(this).hide();
});
$('.ajax_cart_no_product').show('slow');
}
}
};
 
function HoverWatcher(selector){
this.hovering = false;
var self = this;
 
this.isHoveringOver = function() {
return self.hovering;
}
 
$(selector).hover(function() {
self.hovering = true;
}, function() {
self.hovering = false;
})
}
 
//when document is loaded...
$(document).ready(function(){
// expand/collapse management
$('#block_cart_collapse').click(function(){
ajaxCart.collapse();
});
$('#block_cart_expand').click(function(){
ajaxCart.expand();
});
ajaxCart.overrideButtonsInThePage();
 
var cart_qty = 0;
var current_timestamp = parseInt(new Date().getTime() / 1000);
 
if (typeof $('.ajax_cart_quantity').html() == 'undefined' || (typeof generated_date != 'undefined' && generated_date != null && (parseInt(generated_date) + 30) < current_timestamp))
ajaxCart.refresh();
else
cart_qty = parseInt($('.ajax_cart_quantity').html());
 
/* roll over cart */
var cart_block = new HoverWatcher('#header #cart_block');
var shopping_cart = new HoverWatcher('#shopping_cart');
 
$("#shopping_cart a:first").hover(
function() {
$(this).css('border-radius', '3px 3px 0px 0px');
if (ajaxCart.nb_total_products > 0 || cart_qty > 0)
$("#header #cart_block").stop(true, true).slideDown(450);
},
function() {
$('#shopping_cart a').css('border-radius', '3px');
setTimeout(function() {
if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
$("#header #cart_block").stop(true, true).slideUp(450);
}, 200);
}
);
 
$("#header #cart_block").hover(
function() {
$('#shopping_cart a').css('border-radius', '3px 3px 0px 0px');
},
function() {
$('#shopping_cart a').css('border-radius', '3px');
setTimeout(function() {
if (!shopping_cart.isHoveringOver())
$("#header #cart_block").stop(true, true).slideUp(450);
}, 200);
}
);
 
$(document).on('click', '.delete_voucher', function(){
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
async: true,
cache: false,
url:$(this).attr('href') + '?rand=' + new Date().getTime(),
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
$(this).parent().parent().remove();
ajaxCart.refresh();
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
{
if (typeof(updateAddressSelection) != 'undefined')
updateAddressSelection();
else
location.reload();
}
return false;
});
 
$('#cart_navigation input').click(function(){
$(this).attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
$(this).closest("form").get(0).submit();
});
});

Share this post


Link to post
Share on other sites

This module works great, Daresh. Thank you letting us show our customers they can have free shipping after spending certain amount.

Share this post


Link to post
Share on other sites

Hello,

 

First of all, a big THANK YOU Daresh for this module !

The main feature works great (the message displayed under the cart summary)

If we use the + and - signs to add an item, the amount left is updated via ajax but the snippet inserted in the upper cart block and in the layer cart aren't.
I tried adding the javascript you added in the 
ajax-cart.js but it doesn't seem to have an effect on updating the prices via ajax.

Any idea on what's wrong or how to fix this ?

 

Thanks again !

Share this post


Link to post
Share on other sites

Awesome module. Excellent Job! Everything works, for those who say is not working, if using default bootstrap, make sure you are editing /themes/default-bootstrap/js/modules/blockcart/ajax-cart.js...

 

Is there a way I can modify the files, I just want that once the free shipping is reached the message says " spend X to get 10% off".....

 

the discount is obtained automatically using cart rules

 

but I don´t know how to change the message to offer discount instead of free shipping after X amount

Share this post


Link to post
Share on other sites

This is a real nice module!

 

But 1 have one problem: when you use a voucher code then the calculation isn't correct.

 

Free shipping is available from 15 €.

But when my total product amount is: 15,34, and there is a discount code used of 0,45, he says: spend another 0,11 to get free shipping :)

 

But offcourse that is also a problem of prestashop.

Because 15,34 - 0,45 discount = lower then the 15 euro free shipping.

 

Hello,

You found a solution with a voucher ??

 

Thank you ! 

Share this post


Link to post
Share on other sites

First thanks for the module.
My question is, how can I change the color of the text and where?
Thank you very much.

  • Like 1

Share this post


Link to post
Share on other sites

Just add some css rule for .block_get_free_shipping

Share this post


Link to post
Share on other sites

I'm looking around, but I do not know exactly where it is. Themes / default-bootstrap / css / global.css

Share this post


Link to post
Share on other sites

It isn't anywhere, that's why I wrote that you need to add it. global.css would be fine.

  • Like 1

Share this post


Link to post
Share on other sites

Hi, I have 1.6.1.7 version and I use tha standard theme... I have tried to make all you wrote, but it doesn't work!

 

[EDIT] I have solved!

Edited by ExMiliteIgnudo

Share this post


Link to post
Share on other sites

Does this work with ps 1.7

 

thanks Daresh as it looks very interesting.

Share this post


Link to post
Share on other sites