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

  • Posts: 9
  • Thank you received: 0
4 years 2 months ago #315658

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.

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 2 months ago #315672

Hi,

The code is wrong.
It should be:

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.

  • Posts: 9
  • Thank you received: 0
4 years 2 months ago #315698

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.

  • Posts: 9
  • Thank you received: 0
4 years 2 months ago #315699

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.

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 2 months ago #315704

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.

  • Posts: 41
  • Thank you received: 4
2 years 7 months ago #335121

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.

<?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

Attachments:

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
2 years 7 months ago #335123

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:

<?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:
{hkshow maxcart=35}Get free shipping if you order for at least £35{/hkshow}
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.

  • Posts: 41
  • Thank you received: 4
2 years 7 months ago #335376

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)

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

Attachments:

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

  • Posts: 41
  • Thank you received: 4
2 years 7 months ago #335377

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!

<?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.

  • Posts: 357
  • Thank you received: 24
  • Hikaserial Standard Hikashop Business
2 years 4 months ago #337931

Thank you for this code!

What does your "MISSING_QTY_FOR_FREE_SHIPPING" say?


EDIT: Found a solution!

Last edit: 2 years 4 months ago by Thrane.

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

Time to create page: 0.117 seconds
Powered by Kunena Forum