I have created a quick and dirty way of restricting purchase of some products from certain zipcodes. In my case, I sell groceries online. If the customer is local I can deliver the products but if they are from far away I ship them. Now, I can sell Frozen foods to local customers because I can deliver them but if a customer from far of buys the frozen foods it is not possible to deliver and shipping them is a bad idea. So, I had the need to restrict the Frozen foods to customers from certain zipcodes that I can deliver. I did the following:
Copy the attached
ziprestrict.js to ~/catalog/view/javascript ( You will need to edit this file to update it with your zip codes )
ziprestrict.css to ~/catalog/view/theme/-yourtheme-/stylesheet
Edit the file /var/www/bhartimart/catalog/view/theme/default/template/common/header.tpl as:
After line: <script type="text/javascript" src="catalog/view/javascript/jquery/thickbox/thickbox-compressed.js"></script>
Add line: <script type="text/javascript" src="catalog/view/javascript/ziprestrict.js"></script>
After line: <link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/stylesheet.css" />
Add line: <link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/ziprestrict.css" />
In the description of the product/category that needs to be restricted, copy the following code ( it must be copied as source code i.e. click the Source button in the description in the admin panel before pasting it )
<div id="modalPage"><div class="modalBackground"></div><div class="modalContainer"><div class="box"><div class="top"><img alt="" src="catalog/view/theme/Desimart/image/shipping.png" /> Zip Code?</div><div class="middle" style="text-align: center;"><input id="zipCode" type="text" /> <a class="button" onclick="hideModal(document.getElementById('zipCode').value)"><span>Go</span></a> <br /><label id="sorryMessage"> </label> <br /><br /><a href="#"><<back>Back</back></a></div><div class="bottom"> </div></div></div></div><script language="javascript" type="text/javascript">document.getElementById('modalPage').style.display = "block";customerZipCode = GetCookie("customerZipCode");document.getElementById('zipCode').value = customerZipCode; hideModal(customerZipCode);</script>
That is it.
Pros:
It is quick.
Cons:
I am not a programmer. I put together pieces of code from different help forums on the internet and got it working. So, the code may not be clean/efficent.
The restriction is very basic. The zipcode they enter is not tied to any shipping etc. So, customers can bypass it by entering an allowed zipcode and then after adding the products to the cart, can simply try and ship it to some unallowed zipcode. So, update your Terms & Conditions to cover such unacceptable usage.
Customers can still add the restricted products to their cart using the quick add ( little + ) button. This post talks about removing the quick add button for all the products: http://forum.opencart.com/viewtopic.php?f=21&t=16412
Who is online
Users browsing this forum: No registered users and 8 guests