

<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>LexiConn News  &#187;  Topic: Restricting Shipping Options in ShopSite using JavaScript</title>
		<atom:link href="https://support.lexiconn.com/news/forums/topic/restricting-shipping-options-in-shopsite-using-javascript/feed" rel="self" type="application/rss+xml" />
		<link>https://support.lexiconn.com/news/forums/topic/restricting-shipping-options-in-shopsite-using-javascript/feed</link>
		<description></description>
		<pubDate>Mon, 06 Apr 2026 10:40:46 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.5.3-5249</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://support.lexiconn.com/news/forums/topic/restricting-shipping-options-in-shopsite-using-javascript/#post-48628</guid>
					<title><![CDATA[Restricting Shipping Options in ShopSite using JavaScript]]></title>
					<link>https://support.lexiconn.com/news/forums/topic/restricting-shipping-options-in-shopsite-using-javascript/#post-48628</link>
					<pubDate>Mon, 02 Jun 2008 18:28:02 +0000</pubDate>
					<dc:creator>Anonymous</dc:creator>

					<description>
						<![CDATA[
						<p>In previous tutorials, we looked at various ways of using JavaScript in ShopSite, specifically on the cart and checkout screens. The focus of this tutorial is to provide you with a way of stopping customers from choosing an incorrect shipping method. The CheckIt function of ShopSite Pro can stop shoppers from selecting (either intentionally or unintentionally) an option that does not apply to them.</p>
<p>Here is some example JavaScript you can enter in under <strong>Commerce Setup -&gt; Order System -&gt; Shopping Cart: JavaScript added at start of built-in CheckIt function:</strong></p>
<p>Restricting a Single Shipping Option:</p>
<p>&nbsp;</p>
<pre>try{ 
 if(typeof document.order.shipping[0] != "undefined") { 
    if (document.order.shipping[0].type == "radio") { 
      for (var i=0; i &lt; document.order.shipping.length; i++){ 
        if (document.order.shipping[i].checked){ 
         var rad_val = document.order.shipping[i].value; 
       } 
      } 
     } else { 
        var rad_val = document.order.shipping.value; 
     } 
 
     if (button == "8" &amp;&amp; document.order.country.value != "US" &amp;&amp; rad_val == "XXX"){                                      
         alert("International customers cannot choose USA ONLY shipping options"); 
            return(false); 
     } 
   } 
 } catch(err){  } 
</pre>
<p>&nbsp;</p>
<p>Restricting Two Shipping Options:</p>
<p>&nbsp;</p>
<pre>try{ 
 if(typeof document.order.shipping[0] != "undefined") { 
    if (document.order.shipping[0].type == "radio") { 
      for (var i=0; i &lt; document.order.shipping.length; i++){ 
        if (document.order.shipping[i].checked){ 
          var rad_val = document.order.shipping[i].value; 
        } 
      } 
     } else { 
           var rad_val = document.order.shipping.value; 
     } 
 
     if (button == "8" &amp;&amp; document.order.country.value != "US" &amp;&amp; (rad_val == "XXX" || rad_val == "YYY")) {                                      
       alert("International customers cannot choose USA ONLY shipping options"); 
          return(false); 
     } 
    } 
 } catch(err){  } 
</pre>
<p>&nbsp;</p>
<p>The above scenario assumes you have one or two shipping options that are only available for US customers. In order to find out what to replace &#8216;XXX&#8217; and &#8216;YYY&#8217; with, you would view the page source of your cart screen in your browser and search for the shipping options. Once you locate them in the source code, the variable values you are looking for are contained in the</p>
<p>&nbsp;</p>
<pre>value = "XXX"</pre>
<p>portion of the code.</p>
<p>You can go a step further and use Javascript to hide a particular shipping method (once again replacing the XXX and YYY with the value attribute of the shipping options you are restricting):</p>
<p>Restricting / Hiding a Single Shipping Option:</p>
<p>&nbsp;</p>
<pre>try{ 
 if(typeof document.order.shipping[0] != "undefined") { 
    if (document.order.shipping[0].type == "radio"){ 
      for (var i=0; i &lt; document.order.shipping.length; i++){ 
        if(document.order.shipping[i].value == "XXX"){ 
         document.order.shipping[i].parentNode.parentNode.style.display = 'none'; 
        } 
        if (document.order.shipping[i].checked){ 
         var rad_val = document.order.shipping[i].value; 
        } 
       } 
      } else { 
         for (var i=0; i &lt; document.order.shipping.length; i++){ 
             if(document.order.shipping[i].value == "XXX"){ 
               document.order.shipping[i].style.display = 'none'; 
             } 
         } 
         var rad_val = document.order.shipping.value; 
       } 
 
       if (button == "8" &amp;&amp; document.order.country.value != "US" &amp;&amp; rad_val == "XXX"){                                      
          alert("International customers cannot choose USA ONLY shipping options"); 
       } 
     } 
 } catch(err){  } 
</pre>
<p>&nbsp;</p>
<p>Restricting / Hiding Two Shipping Options:</p>
<p>&nbsp;</p>
<pre>try{ 
 if(typeof document.order.shipping[0] != "undefined") { 
     if (document.order.shipping[0].type == "radio"){ 
       for (var i=0; i &lt; document.order.shipping.length; i++){ 
           if(document.order.shipping[i].value == "XXX" || document.order.shipping[i].value == "YYY"){ 
           document.order.shipping[i].parentNode.parentNode.style.display = 'none'; 
        } 
        if (document.order.shipping[i].checked){ 
          var rad_val = document.order.shipping[i].value; 
        } 
      } 
     } else { 
         for (var i=0; i &lt; document.order.shipping.length; i++){ 
            if(document.order.shipping[i].value == "XXX" || document.order.shipping[i].value == "YYY"){ 
         document.order.shipping[i].style.display = 'none'; 
         } 
      } 
      var rad_val = document.order.shipping.value; 
     } 
     
     if (button == "8" &amp;&amp; document.order.country.value != "US" &amp;&amp; (rad_val == "XXX" || rad_val == "YYY")){                                      
        alert("International customers cannot choose USA ONLY shipping options"); 
     } 
    } 
 } catch(err){  } 
</pre>
<p>&nbsp;</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

