Skip to main content

How to display "Only X more to get free shipping"?

More
6 years 7 months ago #315658 by pbander
I would like to ask for help. I have pasted the code at www.termeszeteskutyavilag.hu . A warning window appears in the cart, but does not calculate the remaining amount. What might be the problem? Thanks for the help! Paste code:
<?php
if($this->full_total->prices[0]->price_value_without_shipping_with_tax < 900){
$diffQty = $minPriceForFree - $fullPrice;
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty));
}

Andras

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #315672 by nicolas
Hi,

The code is wrong.
It should be:
Code:
if($this->full_total->prices[0]->price_value_without_shipping_with_tax < 900){ $diffQty = 900 - $this->full_total->prices[0]->price_value_without_shipping_with_tax; $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty)); }
The following user(s) said Thank You: pbander

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #315698 by pbander
Thanks!
it does not count, nor does it deduct the value of the products in the cart

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #315699 by pbander
Thanks!
it does not count, nor does it deduct the value of the products in the cart

Please Log in or Create an account to join the conversation.

More
6 years 7 months ago #315704 by nicolas
Hi,

Then where are you adding this code exactly ? And what do you want it to display and on which condition exactly ?

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #335121 by jasmine247
Hi!
I've been reading through this thread and trying to implement something like this myself, as I've just added a minimum order requirement of £35 to get free delivery.

I have tried to use this code in my checkout/cart view and I'm not getting it to display anything on the frontend.
Code:
<?php if($this->full_total->prices[0]->price_value_without_shipping_with_tax < 35){ $diffQty = 35 - $this->full_total->prices[0]->price_value_without_shipping_with_tax; $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty)); ?>

I have ensured that my language has the override in it also, but it is still not displaying anything at the checkout



I have read through the thread a couple of times and am still not seeing that I am missing anything.
Could use a little bit of help, cheers!

This message contains confidential information

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #335123 by nicolas
Hi,

The view checkout / cart.php was used for the legacy checkout. This has been removed from recent versions of HikaShop.
If you want to add such modification, you need to do them in checkout / show_block_cart.php
You can use the "Display view files" setting of the HikaShop configuration to easily find out which view file is used where:
www.hikashop.com/support/documentation/1...-display.html#layout
Note that there, you'll need to add that code at the beginning of your code:
Code:
<?php $cart = $this->checkoutHelper->getCart(); $this->full_total =& $cart->full_total; ?>

Please note that since then we've added content tags which can allow you to do this easily:
www.hikashop.com/home/blog/471-hikashop-4-4-3.html#tags
For example you could have:
Get free shipping if you order for at least £35
And you could add that in a view override or using the "text" view of the "checkout workflow" of the HikaShop configuration, avoiding doing any override or any coding.

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #335376 by jasmine247
Hey Nicolas!

Thanks for this reply! I've just gotten around to implementing this and it works fine!

( after I realized the typo in this line)
Code:
if($this->full_total->prices[0]->price_value_without_shipping_with_tax < 35){
It was supposed to have a semi colon at the end and was returning a syntax error (for anyone who might end up using this)
Code:
if($this->full_total->prices[0]->price_value_without_shipping_with_tax < 35);


However it does not seem to be limited by the price, even if the amount is over £35 it will still display the message, like so..


I assumed that if it did not meet the "if" requirement of being below 35 then it would not show the message.

Any help would be amazing!

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #335377 by jasmine247
Sorry!

Just realized the error myself!

That wasn't a typo, the typo was not having the closing parenthesis as the end of it! :lol:
So it should have been like this!
Code:
<?php $cart = $this->checkoutHelper->getCart(); $this->full_total =& $cart->full_total; if($this->full_total->prices[0]->price_value_without_shipping_with_tax < 35){ $diffQty = 35 - $this->full_total->prices[0]->price_value_without_shipping_with_tax; $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty)); } ?>

Sorry for bumping the thread, but that works perfectly now!
Hopefully at the very least that snippet will help someone in the same position :lol:

Cheers
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

More
4 years 9 months ago - 4 years 9 months ago #337931 by Thrane
Thank you for this code!

What does your "MISSING_QTY_FOR_FREE_SHIPPING" say?


EDIT: Found a solution!
Last edit: 4 years 9 months ago by Thrane.

Please Log in or Create an account to join the conversation.

Time to create page: 0.239 seconds
Powered by Kunena Forum