Jump to content

[1.6.0.14]: Update new variable in Cart Summary through cart-summary.js?


sting5

Recommended Posts

Hi everyone,

I've been having strange trouble with the code:

 

I need amount until free shipping to be shown in my order summary page, and if buyer adds or deducts products with UP and DOWN buttons, the amount would refresh automatically and give new value (or hide the message if order amount reaches free shipping).

I've edited the Cart.php file by adding new variable:

'until_free_shipping' => ((Tools::convertPrice((float)(Configuration::get('PS_SHIPPING_FREE_PRICE')))) - ($total_products_wt - $total_discounts)),

Then I've added changes in shopping-cart.tpl:

 <p class="free_shipping_line"> To get free shipping You need to spend additional {convertPrice price=$until_free_shipping}
 </p>

And at last I've changed the cart-summary.js file in [THEME_DIR]/js/ :

if (json.until_free_shipping > 0 && !json.is_virtual_cart)
{
$('#until_free_shipping').html(formatCurrency(json.until_free_shipping, currencyFormat, currencySign, currencyBlank));
$('.free_shipping_line').fadeIn();
}
else
$('.free_shipping_line').fadeOut();
The modification works somehow, but not properly - the text line in the frontpage reacts to amount until free shipping value, line disappears and appears when it should automatically after adding or removing products. But the value of the free shipping itself in the <p></p> line does not update.

 

Maybe someone can point out where I did the mistake? this drives me crazy!

Link to comment
Share on other sites

not sure but shouldnt this

$('#until_free_shipping').html(formatCurrency(json.until_free_shipping, currencyFormat, currencySign, currencyBlank));

be this 

$('.until_free_shipping').html(formatCurrency(json.until_free_shipping, currencyFormat, currencySign, currencyBlank));

Link to comment
Share on other sites

 

not sure but shouldnt this

$('#until_free_shipping').html(formatCurrency(json.until_free_shipping, currencyFormat, currencySign, currencyBlank));

be this 

$('.until_free_shipping').html(formatCurrency(json.until_free_shipping, currencyFormat, currencySign, currencyBlank));

 

Nope, because "#" defines variables and "." defines classes, or its the way all other amounts and objects are placed in the file...

  • Like 1
Link to comment
Share on other sites

Thanks anyways Mickeyboy, your willing to help means more than the actual help itself :)

 

I've found the solution, will post it when have time - problem was that the modifications go through blockcart aswell.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...