Free Shipping Calculator For United States Only

General ShopSite user discussion

Free Shipping Calculator For United States Only

Postby koryb1 » Tue Feb 04, 2014 10:49 am

I added a Free Shipping Calculator on our shopping cart page awhile back and it's been successful. The script I am using is:

<td align="right"><script language="javascript" type="text/javascript">
free_limit = 100.00;
amount_left_tmp = free_limit - ss_subtotal;
amount_left = amount_left_tmp.toFixed(2);
if (amount_left > 0){document.write('U.S. Orders - Purchase $' + amount_left + ' more for FREE shipping!');}
</script>

We are now expanding our sales outside the U.S., so I'd like this feature to appear only if the Ship To country is the United States (and "disappear" if a different country is selected.

Is that an easy "If/Then" function?

Any guidance would be greatly appreciated. Thanks in advance!
koryb1
 
Posts: 88
Joined: Tue Feb 14, 2012 7:10 pm

Re: Free Shipping Calculator For United States Only

Postby ShopSite Lauren » Tue Feb 04, 2014 11:29 am

In ShopSite you can set the free shipping countries, and only allow free shipping to be available to specific countries. However, the code you mentioned is separate from the ShopSite shipping, so you would need to modify your code as well. You could put all of your javascript in an IF statement that checks the country pull down menu. For example, if (document.order.country.value == "US") {}
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: Free Shipping Calculator For United States Only

Postby koryb1 » Tue Feb 04, 2014 11:43 am

Hi Lauren, and thanks so much for the quick reply.

I do have the Free Shipping options available only for the U.S. But it's the coding part to make the calculator feature appear only for U.S. orders that I'm just not expert enough at. Would it be this:

if (document.order.country.value = "United States")
{
<td align="right"><script language="javascript" type="text/javascript">
free_limit = 100.00;
amount_left_tmp = free_limit - ss_subtotal;
amount_left = amount_left_tmp.toFixed(2);
if (amount_left > 0){document.write('U.S. Orders - Purchase $' + amount_left + ' more for FREE shipping!');}
</script>
}
koryb1
 
Posts: 88
Joined: Tue Feb 14, 2012 7:10 pm

Re: Free Shipping Calculator For United States Only

Postby ShopSite Lauren » Tue Feb 04, 2014 12:57 pm

That looks correct. I didn't test it, but it should be right.
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: Free Shipping Calculator For United States Only

Postby koryb1 » Tue Feb 04, 2014 1:56 pm

That scripting wasn't working for me.

For the benefit of others who may see this and need ideas, the great folks at Lexiconn helped me with this and came up with the following which works perfectly (at least for my site):

<span id="free_limit"></span>
<script language="javascript" type="text/javascript">
free_limit = 100.00;
amount_left_tmp = free_limit - ss_subtotal;
amount_left = amount_left_tmp.toFixed(2);
if (amount_left > 0){
var free_limit_html = 'U.S. Orders - Purchase $' + amount_left + ' more for FREE shipping!';
var domestic_regex = /^US$|^PR$|^GU$|^VG$|^VI$/;
if(domestic_regex.test(document.order.country.value)){
document.getElementById("free_limit").innerHTML = free_limit_html;
} else{
document.getElementById("free_limit").innerHTML = "";
}
} else{
document.getElementById("free_limit").innerHTML = "";
}
</script>

If you're ever considering a new ShopSite host and are not already using Lexiconn, time and time again I am amazed at their outstanding service. I could not recommend them highly enough! Best ShopSite host out there!
koryb1
 
Posts: 88
Joined: Tue Feb 14, 2012 7:10 pm


Return to User Forum

Who is online

Users browsing this forum: No registered users and 49 guests