When I'm using free shipping Magento displays "$0.00" as the shipping amount. I would like to replace the "$0.00" with some custom text. How do I do that?
Solved! Go to Solution.
HI @david_barnhart,
You can change the $0 amount as per the below steps.
1. Edit the below template file of your current theme.
template/checkout/onepage/shipping_method/available.phtml
or copy from base theme to your current theme folder.
app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml
2. In the available.phtml file, look for the following code (around line 56):
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?> <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?> <?php echo $_excl; ?> <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>) <?php endif; ?> </label
3. Replace it with the following:
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <?php if($_rate->getPrice() > 0) : ?> <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?> <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?> <?php echo $_excl; ?> <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>) <?php endif; ?> <?php else : ?> (<?php echo $this->__('Free Shipping'); ?>) <?php endif; ?> </label>
4. Save available.phtml, and clear your Magento caches. "Free Shipping" will now appear next to all methods containing a $0 amount on the One-Page-Checkout shipping section or you can also add your if condition to check shipping method code as well.
The file for the calculate shipping block is app/design/frontend/[theme_path]/template/checkout/cart/shipping.phtml. For future reference, you can determine the exact template paths loaded on the frontend by enabling Template Path Hints in the Magento configuration. You can find a quick tutorial on how to do this here:
https://support.magerewards.com/article/1534-how-do-i-turn-on-template-path-hints
Reference: https://stackoverflow.com/questions/19015759/magento-show-free-shipping-text
I hope it will help you.
Thank you Vimal. There is another place I need to make the same change. The sidebar contains "You Checkout Progress". There is "SHIPPING METHOD" there and it also displays the "$0.00"
How do I remove it from there as well?
Hi @david_barnhart,
Good to hear that it works well for you.
You can edit the phtml for that block as well.
You can get template path link from admin configuration settings change.
For more info to edit template path link, please follow below link.
https://support.magerewards.com/article/1534-how-do-i-turn-on-template-path-hints
I Hope it will help you.
Thank you vimal but I think I did it wrong.
FIle I updated:
app/design/frontend/base/default/template/checkout/onepage/shipping_method.phtml
Original code:
<?php if ($this->getShippingMethod()): ?> <?php echo $this->getShippingDescription() ?> <?php $_excl = $this->getShippingPriceExclTax(); ?> <?php $_incl = $this->getShippingPriceInclTax(); ?> <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?> <?php echo $_incl; ?> <?php else: ?> <?php echo $_excl; ?> <?php endif; ?> <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>) <?php endif; ?> <?php else: ?> <?php echo $this->__('Shipping method has not been selected yet') ?> <?php endif; ?>
I changed it to:
<?php if ($this->getShippingMethod()): ?> <?php echo $this->getShippingDescription() ?> <?php $_excl = $this->getShippingPriceExclTax(); ?> <?php $_incl = $this->getShippingPriceInclTax(); ?> <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?> <?php echo $_incl; ?> <?php else: ?> <?php echo $_excl; ?> <?php endif; ?> <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>) <?php endif; ?> <?php else : ?> (<?php echo $this->__('Free Shipping'); ?>) <?php endif; ?> <?php else: ?> <?php echo $this->__('Shipping method has not been selected yet') ?> <?php endif; ?>
Hi @david_barnhart
Try once the following code:
<?php if ($this->getShippingMethod()): ?> <?php echo $this->getShippingDescription() ?> <?php $_excl = $this->getShippingPriceExclTax(); ?> <?php $_incl = $this->getShippingPriceInclTax(); ?> <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?> if($_incl == 0) { (<?php echo $this->__('Free Shipping'); ?>) }else{ <?php echo $_incl; ?> } <?php else: ?> if($_excl == 0) { (<?php echo $this->__('Free Shipping'); ?>) }else{ <?php echo $_excl; ?> } <?php endif; ?> <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> if($_incl == 0) { (<?php echo $this->__('Free Shipping'); ?>) }else{ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>); } <?php endif; ?> <?php else: ?> <?php echo $this->__('Shipping method has not been selected yet') ?> <?php endif; ?>
I hope it will help you!
It is working!
Thank you Vimal!