newshopholder Posted May 29, 2016 Share Posted May 29, 2016 There is a topic on this forum about a count down until free shipping, but it is for older versions. The count down shows the remaining amount until the free shipping. For example: spend another 2 dollar to earn free shipping! Or, when people already have earned the free shipping: You earned free shipping! But i tried it on the 1.6 version and it worked! But there are a few problems..Does someone now how to fix them? When you are in the shopping cart, and you use the + / - buttons to modify the quantity of a product, or delete a product, the count down works very smooth! Really nice. But when you refresh the shopping cart page, he says: You earned free shipping! But that is incorrect, because you see it also when you are (far!) under that free shipping amount. Also, when you go from another page to the shopping cart he shows the wrong: 'you earned free shipping!' text. Why does it work with Ajax, and why does it not work with a normal page loading? This is what i have changed: Shoppingcart.tpl: <p id="amount_free_shipping"> <span class = "ajax_shipping_free_price_span {if ($amount_until_free_shipping_float) <= 0} hidden {/if}">{l s='Spend' mod="blockcart"} <span class="ajax_shipping_free_price">{$amount_until_free_shipping}</span> {l s='more for FREE SHIPPING!' mod="blockcart"}</span> <span class = "ajax_shipping_free_price_free_span {if ($amount_until_free_shipping_float) > 0} hidden {/if}">{l s='Buying more than' mod="blockcart"} <span class="ajax_shipping_free_price_free">{$shipping_free_price}</span> {l s='earned you FREE SHIPPING!!!' mod="blockcart"}</span> </p> In modules/blockcart/blockcart.php $shipping_free_price= Tools::convertPrice((float)(Configuration::get('PS_SHIPPING_FREE_PRICE')), $currency); $amount_until_free_shipping_float = ($shipping_free_price - $params['cart']->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING)); and also; 'shipping_free_price' => Tools::displayPrice($shipping_free_price), 'amount_until_free_shipping' => ($shipping_free_price - $params['cart']->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING)), 'amount_until_free_shipping_float' => (float)($amount_until_free_shipping_float), In blockcart-json.tpl: "amount_until_free_shipping" : "{$amount_until_free_shipping|html_entity_decode:2:'UTF-8'}", "product_total": "{$product_total|html_entity_decode:2:'UTF-8'}", "shipping_free_price": "{$shipping_free_price|html_entity_decode:2:'UTF-8'}", And in the themes/<your theme folder>/js/modules/blockcart/ajax-cart.js: $('.ajax_shipping_free_price').text(jsonData.amount_until_free_shipping); if (parseFloat(jsonData.amount_until_free_shipping) > 0) { $('.ajax_shipping_free_price_span').each( function() { $(this).removeClass('hidden'); }); $('.ajax_shipping_free_price_free_span').each( function() { $(this).addClass('hidden'); }); } else { $('.ajax_shipping_free_price_span').each( function() { $(this).addClass('hidden'); }); $('.ajax_shipping_free_price_free_span').each( function() { $(this).removeClass('hidden'); }); } Thanks in advance! Link to comment Share on other sites More sharing options...
Daresh Posted May 29, 2016 Share Posted May 29, 2016 Check out this module: https://www.prestashop.com/forums/topic/494147-free-module-spend-x-to-get-free-shipping/ Link to comment Share on other sites More sharing options...
newshopholder Posted May 29, 2016 Author Share Posted May 29, 2016 Wow, its great! Thanks! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now