PrestaShop Quick Tip: Hide Shipping Cost for Non-Registered Users

In this quick tip, we will see how to hide the shipping cost, or misleading free shipping label for non-registered customers.

Watch The Screencast (text below)

Prestashop Quick Tip: hide shipping cost for non registered users

You might have come across this issue if you setup zones so that carriers have a different price depending on the customer’s address: a default shipping price, or even worse a free shipping label is shown for everybody who has not login yet.

This can be misleading at times, and some of your customers will definitely get angry if the price rises after adding shipping address details. Moreover, we do not want this.

First, let’s disable our carrier (remember to do it for all carriers if you use many) for visitors in the back office. Go to Shipping -> Carriers and click on a carrier. Then, disable it for visitors.

Disable carrier for visitors

You can also do it for guests if you disabled the guest checkout.

Refresh and see it says free shipping! This is even more misleading but now we can target that label and still have the total match the products total price.

Let’s go to modules/blockcart and copy blockcart.tpl in the theme folder modules/blockcart. Open it and locate the second script block:


<script type="text/javascript">
var customizationIdMessage = '{l s='Customization #' mod='blockcart' js=1}';
var removingLinkText = '{l s='Please remove this product from my cart.' mod='blockcart' js=1}';
var freeShippingTranslation = '{l s='Free shipping!' mod='blockcart' js=1}';
var freeProductTranslation = '{l s='Free!' mod='blockcart' js=1}';
var delete_txt = '{l s='Delete' mod='blockcart' js=1}';
</script>

See where it reads free shipping? We need to change the block as follows


<script type="text/javascript">
var customizationIdMessage = '{l s='Customization #' mod='blockcart' js=1}';
var removingLinkText = '{l s='Please remove this product from my cart.' mod='blockcart' js=1}';

var freeProductTranslation = '{l s='Free!' mod='blockcart' js=1}';
var delete_txt = '{l s='Delete' mod='blockcart' js=1}';

//<![CDATA[[

	{if !$logged AND !$cart->id_customer}
		var freeShippingTranslation = '{l s='Login to see the shipping cost!' mod='blockcart' js=1}';
	{else}
		var freeShippingTranslation = '{l s='Free shipping!' mod='blockcart' js=1}';
	{/if}

//]]>
</script>

As you can see, we removed the free shipping text and added it below. We used a small trick to target the unregistered customer. So, If the customer is not logged in, nor has added any shipping information (that is, no customer id exists for him), then show a different text. Else, it is okay to display the free shipping label.

It looks a bit ugly now, because the cart block is still displaying the shipping label. Let’s hide that as well! Locate the following at about line 154 of the same file:

<span>{l s='Shipping' mod='blockcart'}</span>

And change it the following way

{if $logged OR $cart->id_customer}
	<span>{l s='Shipping' mod='blockcart'}</span>
{/if}

This time, the text will only be shown if the customer is logged or has already added shipping information.

As a finishing touch, we can add the little information to shopping cart.tpl as well (you can find it in the theme folder once again). Locate this:


<tr class="cart_total_delivery" style="{if !isset($carrier->id) || is_null($carrier->id)}display:none;{/if}">
	<td colspan="5">{l s='Shipping'}</td>
	<td colspan="2" class="price" id="total_shipping">{l s='Free Shipping!'}</td>
</tr>

And change it this way

<tr class="cart_total_delivery">
	<td colspan="5">{l s='Shipping'}</td>
	<td colspan="2" class="price" id="total_shipping">

		{if !$logged AND !$cart->id_customer}
			{l s='Login for the correct price'}
		{else}
			{l s='Free Shipping!'}
		{/if}

	</td>
</tr>

Note that other than adding the same condition as before, we also removed the display:none style. There is a little downside to this, as that block will always be shown, even if there are no carriers available for the destination. However, this won’t happen if you setup zones, countries and states the correct way.

Need Prestashop Modules? Have a look at my Prestashop Addons Store!

Looking for quality PrestaShop Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , , , | Posted under PrestaShop, Video | RSS 2.0

Author Spotlight

Fabio Porta

Fabio Porta

Fabio has been involved in web development and design since 2005, when launched his first website at the age of 16. He’s now highly skilled in both client and server side development, along with design, and since August 2012 runs a successful website about PrestaShop tutorials and Prestashop Modules called Nemo’s Post Scriptum, at http://nemops.com

Leave a Reply

Your email address will not be published. Required fields are marked *


2 + 8 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>