Hiding payment options in the ShopSite cart

Forum Forums Tutorials Hiding payment options in the ShopSite cart

This topic contains 0 replies, has 1 voice, and was last updated by  Anonymous 12 years, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #48701

    Anonymous
    Participant

    Many merchants find that they need to offer special payment options to small group of their customers while restricting them from the others. Since ShopSite offers the same payment options to all customers, you will need to use Javascript to hide or show specific payment options. Here are a few Javascript examples that can be used to hide payment options in the cart (note that the examples are set in the LexiConn namespace to prevent any interference with Javascript variables and function you may already have on your page):

    Payment Options Restricted to Registered Customers

    The following example will restrict a set of payment options for registered customers only. You will need to include the following Javascript on your Shopping cart and Checkout pages in the “Text at the top of the
    Shopping Cart screen:” and “Text at the top of the Checkout screen:” fields:

     

    <script type="text/javascript"> 
     var LexiConn = { 
         regCustomer: false, 
         reg_cookie: /.*ss_reg_.*/, 
         restrictedCustomerValues: /^8$|^9$/, 
         getCookie: function(){ 
             if (document.cookie.length>0){ 
                 var ck = document.cookie.split(';'); 
                 for(n=0; n<ck.length; n++){ 
                      var ck_name = ck[n].split(','); 
                      if(LexiConn.reg_cookie.test(ck_name)){ 
                         LexiConn.regCustomer = true; 
                      } 
                 } 
             } 
         }, 
         restrictPaymentReg: function(values){ 
             var p_type = document.getElementById("selPaytype"); 
             var opt = p_type.options; 
             
             LexiConn.getCookie(); 
             if(LexiConn.regCustomer != true){ 
                 var option_count = opt.length - 1; 
                 for(n=option_count; n>0; n--){ 
                     if(LexiConn.restrictedCustomerValues.test(opt[n].value)){ 
                             p_type.removeChild(opt[n]); 
                     } 
                 } 
             } 
         } 
     } 
     </script> 
    

     

    Then, view the source of your Shopping Cart page, find the payment options on the page and note the value attributes of the payment options you would like to offer only to registered customers (who are logged in):

     

    <select class="paytype" name="paytype" id="selPaytype"> 
       <option selected value="-1" >Choose a Payment option</option> 
       <option  value=0 >Visa</option> 
       <option  value=1 >MasterCard</option> 
       <option  value=2 >Discover</option> 
       <option  value=8 >Check</option> 
       <option  value=9 >Purchase Order</option> 
       <option  value=14 >PayPal</option> 
     </select> 
    

     

    Next, enter the values of the options you would like to restrict next to the restrictedCustomerValues definition in the following format:

    Format–> /^[value 1]$|^[value 2]$|^[value 3]$/

    Or, in our example:

     

    restrictedCustomerValues: /^8$|^9$/,
    
    

     

    Finally, call the restriction function in the “Text at the bottom of the Shopping Cart screen:” and “Text at the bottom of the Checkout screen:” for the Shopping Cart and Checkout Pages respectively:

     

    <script type="text/javascript">
    LexiConn.restrictPaymentReg()
    </script>
    

     

    Payment Options Restricted to Customers Using a Coupon or Group of Coupons

    If you would like to go a step further, you could restrict payment options based upon whether a specific coupon or group of coupons are being used in the cart. This works well where you have a specific customer registration group that gets auto assigned a coupon, like a group of wholesalers or privileged customers.

    As with the previous example, you will You will need to include the following Javascript on your Shopping cart and Checkout pages in the “Text at the top of the Shopping Cart screen:” and “Text at the top of the Checkout screen:” fields:

     

    var LexiConn = { 
         restrictedCouponNames: /^test$|^new$/i, 
         restrictedCouponOptions: /^8$|^9$/, 
         restrictPaymentCoupon: function(){ 
             var p_type = document.getElementById("selPaytype"); 
             var opt = p_type.options; 
     
             if(number_coupons >= 1){ 
               for(n=0; n<ss_coupon_name.length; n++){ 
                 if(LexiConn.restrictedCouponNames.test(ss_coupon_name[n])){ 
                     var option_count = opt.length - 1; 
                     for(m=option_count; m>0; m--){ 
                         if(LexiConn.restrictedCouponOptions.test(opt[m].value)){ 
                                 p_type.removeChild(opt[m]); 
                         } 
                     } 
                 } 
               } 
             } 
         } 
     } 
    
    

     

    Next, enter the names of the coupons you allow to access the payment options you will restrict into the restrictedCouponNames line using the following format (make sure you leave on the trailing ‘i’ after your list of values so that the script performs a case-insensitive test of the coupon values):

    Format–> /^[value 1]$|^[value 2]$|^[value 3]$/i

    For example:

     

    restrictedCouponNames: /^test$|^new$/i,
    
    

     

    Again, view the source of your Shopping Cart page, find the payment options on the page and note the value attributes of the payment options you would like to offer only to customers using a specific coupon or group of coupons:

     

    <select class="paytype" name="paytype" id="selPaytype"> 
       <option selected value="-1" >Choose a Payment option</option> 
       <option  value=0 >Visa</option> 
       <option  value=1 >MasterCard</option> 
       <option  value=2 >Discover</option> 
       <option  value=8 >Check</option> 
       <option  value=9 >Purchase Order</option> 
       <option  value=14 >PayPal</option> 
     </select> 
    
    

     

    Next, enter the values of the options you would like to restrict next to the restrictedCouponOptions definition in the following format:

    Format–> /^[value 1]$|^[value 2]$|^[value 3]$/

    Or, in our example (make sure you do not use single or double quotes):

     

    restrictedCouponOptions: /^8$|^9$/,
    
    

     

    Finally, call the restriction function in the “Text at the bottom of the Shopping Cart screen:” and “Text at the bottom of the Checkout screen:” for the Shopping Cart and Checkout Pages respectively:

     

    <script type="text/javascript">
    LexiConn.restrictPaymentCoupon()
    </script>
    

     

    Payment Options Restricted to Customers Visiting through an Associate / Affiliate Link

    The following example will restrict a set of payment options only for those who enter your site through an associate or affiliate link (using the ShopSite Associate program):

     

    var LexiConn = { 
         restrictedAssociateValues: /^8$|^9$/, 
         restrictPaymentAssociate: function(values){ 
             LexiConn.restrictedAssociateValues = '/^'+values.replace('|', '$|^')+'$/'; 
             var p_type = document.getElementById("selPaytype"); 
             var opt = p_type.options; 
             
             if(ss_associate == ""){ 
                 var option_count = opt.length - 1; 
                 for(n=option_count; n>0; n--){ 
                     if(LexiConn.restrictedCustomerValues.test(opt[n].value)){ 
                             p_type.removeChild(opt[n]); 
                     } 
                 } 
             } 
         } 
     } 
    
    

     

    Then, view the source of your Shopping Cart page, find the payment options on the page and note the value attributes of the payment options you would like to offer only to customers arriving through a ShopSite Associate / Affiliate link:

     

    <select class="paytype" name="paytype" id="selPaytype"> 
       <option selected value="-1" >Choose a Payment option</option> 
       <option  value=0 >Visa</option> 
       <option  value=1 >MasterCard</option> 
       <option  value=2 >Discover</option> 
       <option  value=8 >Check</option> 
       <option  value=9 >Purchase Order</option> 
       <option  value=14 >PayPal</option> 
     </select> 
    
    

     

    Again, enter the values of the options you would like to restrict next to the restrictedAssociateValues definition in the following format:

    Format–> /^[value 1]$|^[value 2]$|^[value 3]$/

    Or, in our example:

     

    restrictedAssociateValues: /^8$|^9$/,
    
    

     

    Finally, call the function in the “Text at the bottom of the Shopping Cart screen:” and “Text at the bottom of the Checkout screen:” for the Shopping Cart and Checkout Pages respectively:

     

    <script type="text/javascript">
    LexiConn.restrictPaymentAssociate()
    </script>
    
    

     

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.