- Posts: 344
- Thank you received: 3
How to display "Only X more to get free shipping"?
Hikashop 2.6.3
So right now I am using this code in the checkout / cart.php file
But now I have just started adding tax to my products, and now the above code is displaying the message with prices based on the price without tax.
I need the message to be displayed based on the price with tax( price_value_with_tax;). So somewhere in the code above I need to place this: "price_value_with_tax;"
Any advice on how I can get it right ?
Please Log in or Create an account to join the conversation.
Instead of price_value_without_shipping, you want to use price_value_without_shipping_with_tax
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
You can use almost the same code.
Instead of $this->full_total you need to use $this->total
The rest should be the same.
Please Log in or Create an account to join the conversation.
In which php. file to I need to place the code ?
Please Log in or Create an account to join the conversation.
No in a PHP file, in a view.
Do not edit HikaShop PHP files !
They are two views for the carts "checkout / cart" and "product / cart".
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Any advice?
Please Log in or Create an account to join the conversation.
They are two views for the carts "checkout / cart" and "product / cart"
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Hikashop 2.6.3
This is the code I am using in the checkout / cart.php file:
I've discovered something strange with the code.
I have free freight when a customers buys for more than NOK 900,-
When the price of the products in the checkout is below NOK 1 125 the message in the checkout says.
"Message
If you shop for NOK -224 more you get free shipping!"
I have noticed that there is a minus in front of the value.
NOTE: The NOK minus price varies. I.e if the total price is NOK 967, the message says: If you shop for NOK -67,- more you get free shipping!"
If the price of the products is NOK 1125 av above the message don't display and working just fine.
I know that this has some to do with the tax. Because the tax rate in Norway is 25%, ....and NOK 900 x 1,25 = 1125
Any advice on how to fix this ?
Please Log in or Create an account to join the conversation.
I was just browsing through this post, you may have the prices with and without tax mixed up.
In the first line you check the price_value_without_shipping_with_tax against 900, but then in the second line you still use the price_value_without_shipping (so not with tax) to subtract from 900.
Make sure you use the same price value everywhere, it should work correctly.
Regards,
Please Log in or Create an account to join the conversation.
Tnx man ..... I didn't notice. so now I used the code:
And now it works !
Please Log in or Create an account to join the conversation.
Hikashop 2.6.4
Until now I only have displayed this message in the checkout.
So now I want it also to display above each product.
So I placed this code in the view/product / show_default file:
It display fine, but that's all.
Now the message is just static and says (even if a customer ads products to the basket):
"Message
If you buy for NOK 900, - you get free shipping!"
I need the message to display (before the customers ads products to the basket)
"If you buy for NOK 900, - or more you get free shipping!"
And after the customer ads product to the basket (i.e value of products is NOK 399,-) I need it to say:
"If you buy for NOK 501,- more you get free shipping!"
And after the customers ads products to the value of NOK 900 or above the message disappears.
Any advice on how to adjust the code to work like this ?
Please Log in or Create an account to join the conversation.
$this->full_total is not defined on that view file.
You need to add that code before:
Please Log in or Create an account to join the conversation.
So i added this code
But there's a small problem.
It only works after I add a product to the basket and proceed to checkout, and after that go back to a product.
Then it displays correct.
Any advice on how to make it display correctly after I just adding a product to the basket ? (without going to the checkout, and back to a product page)
Hope my explenation makes sense
Please Log in or Create an account to join the conversation.
if I understand correctly you mean the cart is automatically updated through Ajax when someone adds a product, while the message is not updated since it is static content only generated on pageload.
One possible solution would be to simply disable Ajax in your Hikashop configuration. That way the page will always refresh when the "Add to cart" button is clicked and the message will also be updated.
It would probably be possible to do what you want without page refresh by creating a plugin using something like the trigger "onAfterCartUpdate", though it would also be possible by just adding some Javascript that gets executed when the "Add to cart" button is pressed, which is what we use. It's perhaps not the most elegant solution, but this way would also allow you update the message to always display correctly.
Let me know if you're interested in the Javascript solution.
Kind regards,
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
below is the Javascript code we used, I'll give some explanation further down. You can add the code for example all the way at the end of your show_default view:
It looks more complicated than it is.
First we register the click event when someone clicks on the "Add to cart button":
Then we have a simple if-else to hide the system message if the total cart value is above 900, or otherwise modify the value in the message. To grab the price in your message with jQuery, the easiest way is to put a span with a unique class or id around the price value in your MISSING_QTY_FOR_FREE_SHIPPING constant, so change it to something like:
And that's it, for us this works fine.
Please Log in or Create an account to join the conversation.
I will try it out.
I'll give you a feedback when I've tested it.
Regards
Please Log in or Create an account to join the conversation.
river wrote: Tnx for reply
So i added this code
It works fine.Code:<?php $class = hikashop_get('class.cart'); $cart = $class->loadFullCart(); $this->full_total =& $cart->full_total; 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)); }
But there's a small problem.
It only works after I add a product to the basket and proceed to checkout, and after that go back to a product.
Then it displays correct.
Any advice on how to make it display correctly after I just adding a product to the basket ? (without going to the checkout, and back to a product page)
Hope my explenation makes sense
Unfortunately the Javascript soulution dosent work
.
Any advice from you Hikashop guys on how to solve this without Javascript ?
Please Log in or Create an account to join the conversation.
The javascript solution looks good to me.
If it doesn't work, it might be because of the way HikaShop is configured in your way which isn't compatible with that.
Or maybe you didn't add it properly to the page.
But I still see a javascript solution as the way to go, even though it might require some adaptation for your case.
Please Log in or Create an account to join the conversation.