Skip to main content

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

More
11 years 5 months ago #197497 by ahacreative
-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.4.27
-- Browser(s) name and version -- : Firefox 36.0.4
-- Error-message(debug-mod must be tuned on) -- : N/A

Hi,

Is there a built-in function in HikaShop to display how much more a customer needs to spend in order to receive free shipping? All of our products are charged shipping according to weight. However, once they spend $75.00 or more, they receive free shipping.

Is there a way to add a status / progress bar that will alert customers they only have to spend X more to qualify for free shipping?

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

More
11 years 5 months ago #197510 by nicolas
Hi,

When you have free shipping over a certain amount, you have ( at least ) two different shipping methods.
One which is free for above the threshold, and one paying for below it. In the later, you could enter a static message to tell the user that he could get free shipping if purchasing at least $75 of goods.
That's the best you can do with the options available by default without any coding.
Then, if you want something closer to your needs, you can edit the file "step" of the view "checkout" via the menu Display>Views in order to add your custom code to display such dynamic message.
The following user(s) said Thank You: ahacreative

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

More
11 years 5 months ago #197618 by ahacreative
Thank you for your reply. I actually have the static message set up already. This will work fine for the time being. I will check out the Views to try and get something more dynamic going on.

Thanks again!

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

More
10 years 11 months ago #218407 by river

ahacreative wrote: Thank you for your reply. I actually have the static message set up already. This will work fine for the time being. I will check out the Views to try and get something more dynamic going on.

Thanks again!


Did you manage to create this dynamic message ? I would love to have this function too.

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

More
10 years 11 months ago #218410 by river
I found this code snippet from woocommere and how they did it there.

Link: businessbloomer.com/woocommerce-add-need...-shipping-cart-page/
Code:
// If your free shipping threshold is 1500 as per Woocommerce settings... // ...show a cart notice if order subtotal is less than 1500 function cart_notice() { $maximum = 1500; $current = WC()->cart->subtotal; if ( $current < $maximum ) { echo '<div class="woocommerce-message">Get free shipping if you order $' . ($maximum - $current) . ' more!</div>'; } } add_action( 'woocommerce_before_cart', 'cart_notice' );

Any suggestion on how we can modify it to use in Hikashop
To get free shipping in my store you have to buy for NOK 900 +++

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

More
10 years 11 months ago #218435 by Xavier
Hi,

You can edit the view "checkout / shipping" and add that code at the beginning between PHP tags:
Code:
$minQtyForFree = 900; $productQty = 0; foreach($this->order->products as $product){ $productQty += $product->cart_product_quantity; } if($productQty < $minQtyForFree){ $diffQty = $minQtyForFree - $productQty; $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty)); }

Then add this translation override in the language file:
Code:
MISSING_QTY_FOR_FREE_SHIPPING="Get free shipping if you order %s more!"

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

More
10 years 11 months ago #218653 by river
Tnx for reply

In configuration=>checkout workflow I have the following settings:

Cart | Payment
Login
Fields

So I added the code at the top of checkout/cart.php after the first <?php

Now the new message in the front-end is displaying just fine(at the top)

But it only removes 1 NOK for each product that I add to the cart.

I.e: I have added three products to my cart with a total amount of 698 NOK, and the message at the top says:

"Get free shipping if you order 897 more!"

The correct would be:

"Get free shipping if you order 222 more!"

Any soution ? Hope my explenation make sense.

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

More
10 years 11 months ago #218717 by Xavier
Hi,

My bad, I was thinking that you were talking about the quantity and not the price.
So here is the updated code:
Code:
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)); }

You can use "$this->full_total->prices[0]->price_value_without_shipping" instead if you want to do the check on a price without tax.
The following user(s) said Thank You: river

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

More
10 years 11 months ago #218750 by river
Tnx for reply.
It still ain't working.

I tried placing the code in both checkout / cart.php and shipping.php just below the first "<?php" like this:
Code:
<?php if($this->full_total->prices[0]->price_value_without_shipping < 900){ $diffQty = $minPriceForFree - $fullPrice; $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty)); } /** * @package HikaShop for Joomla! * @version 2.5.0 * @author hikashop.com * @copyright (C) 2010-2015 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */

....and now the message in the front-end says

Message:
"Get free shipping if you order 0 more!"

Any solution ?

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

More
10 years 11 months ago #218783 by nicolas
Hi,

Of course, in the code Xavier provided, you need to replace $minPriceForFree by the minimum price you want for the message to appear, and $fullPrice by the variable where the price is stored
So the line:
$diffQty = $minPriceForFree - $fullPrice;
should actually be:
$diffQty = 900 - $this->full_total->prices[0]->price_value_without_shipping;
The following user(s) said Thank You: river

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

More
10 years 11 months ago #218814 by river
Perfect ! it works !

This is a good function. You should make it a standard function in Hikashop.

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

More
10 years 5 months ago #237924 by cesarlab69
Hikashop 2.6.2
Joomla 3.4.8

Hi, I try to do this in my shop but I can`t. I customize the shipping view and my code is this:

$comanda = $this->full_total->prices[0]->price_value_without_shipping;
$preciomin = 200;

if($comanda < $preciomin){
$diffQty = $preciomin - $comanda;
echo "<h3>Te faltan " . $diffQty . "€ para conseguir el ENVÍO GRATIS!<h3>"
}

The variable $comanda is zero everytime, I don't know if $comanda = $this->full_total->prices[0]->price_value_without_shipping; is correct

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

More
10 years 5 months ago #237926 by nicolas
Hi,

The value price_value_without_shipping will only be available if there is already shipping applied to the cart.
So you can use price_value instead:
Code:
$comanda = $this->full_total->prices[0]->price_value; $preciomin = 200; if($comanda < $preciomin){ $diffQty = $preciomin - $comanda; echo "<h3>Te faltan " . $diffQty . "€ para conseguir el ENVÍO GRATIS!<h3>" }

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

More
10 years 5 months ago #238153 by kyratn
Hi,

I do have code like this:
Code:
<?php if($this->full_total->prices[0]->price_value_without_shipping < 20){ $diffQty = 20 - $this->full_total->prices[0]->price_value_without_shipping; $text = JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty); echo '<td colspan="3" class="hidden-phone hikashop_cart_empty_footer"><span class="free_shipping_alert">'.$text.'</span></td>'; } else echo $td; ?>

It works fine but how to have coupon not applied to this? I mean if someone has in cart product for 21eur and enter coupon for discount -10eur it would give message. I do have free shipping on orders over 20eur...

Thanks

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

More
10 years 5 months ago #238175 by nicolas
Hi,

Instead of:
Code:
$this->full_total->prices[0]->price_value_without_shipping
you can try using:
Code:
$this->full_total->prices[0]->price_value_without_discount

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

More
10 years 5 months ago - 10 years 5 months ago #238363 by kyratn
Hi,

Well it didn't work. Code would work as expected only if discount is entered...else it shows u need to add 20eur.....
So I tried to add something like this but it didn't work too:
Code:
<?php if($this->full_total->prices[0]->price_value_without_shipping < 20){ $diffQty = 20 - $this->full_total->prices[0]->price_value_without_shipping; $diffQtydisc = 20 - $this->full_total->prices[0]->price_value_without_discount; $text = JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty); $text2 = JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQtydisc); echo '<td colspan="3" class="hidden-phone hikashop_cart_empty_footer"><span class="free_shipping_alert">'.$text.'</span></td>'; } elseif ($this->full_total->prices[0]->price_value_without_discount < 20){ echo '<td colspan="3" class="hidden-phone hikashop_cart_empty_footer"><span class="free_shipping_alert">'.$text2.'</span></td>'; } else echo $td; ?>

Am I on correct way?

Thanks
Last edit: 10 years 5 months ago by kyratn.

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

More
10 years 5 months ago #238378 by nicolas
Hi,

It's simpler. Just add such line at the beginning:
Code:
if(empty($this->full_total->prices[0]->price_value_without_discount)) $this->full_total->prices[0]->price_value_without_discount = $this->full_total->prices[0]->price_value_without_shipping;
And that way, when price_value_without_discount is missing, it will be filled with the value from price_value_without_shipping so that you can do your test on price_value_without_discount like before.
The following user(s) said Thank You: kyratn

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

More
10 years 5 months ago #238558 by kyratn
Hi,

So added this and it does work:
Code:
<?php if(empty($this->full_total->prices[0]->price_value_without_discount)) $this->full_total->prices[0]->price_value_without_discount = $this->full_total->prices[0]->price_value_without_shipping; if($this->full_total->prices[0]->price_value_without_discount < 20){ $diffQty = 20 - $this->full_total->prices[0]->price_value_without_discount; $text = JText::sprintf('MISSING_QTY_FOR_FREE_SHIPPING',$diffQty); echo '<td colspan="3" class="hidden-phone hikashop_cart_empty_footer"><span class="free_shipping_alert">'.$text.'</span></td>'; } else echo $td; ?>

I am learning from you everyday Nicolas.
Thank you

Regards

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

More
10 years 4 months ago #239756 by kyratn
Hi,

One more thing. How can i round price_value?
Now if product added to cart has 19.99 it will display something like this: 0.010000000000002 €. Would be good to have 0.01 only

Thanks

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

More
10 years 4 months ago #239757 by nicolas
Hi,

You can use the PHP round function:
php.net/manual/en/function.round.php

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

Time to create page: 0.510 seconds
Powered by Kunena Forum