Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Turn display off for subnode

    I have scripting that currently disables a C.O.D. option in a dropdown and disables a coupon code input box depending on login pulled from a cookie. I would like to use/modify this script to also disable a "free shipping" option depending on login with a condition of the cart subtotal (if ss_subtotal <= 199...) . I have all of the variables but cannot figure out the syntax to implement the modification. Here is the current script that disables the C.O.D. option and coupon box:

    Code:
     <script type="text/javascript">
    
    var LexiConn = {
        regCustomer: false,
        reg_cookie: /.*ss_reg_.*/,
        regGroup: null,
        restrictedCustomerGroups: /^wholesale$/,
        restrictedPaymentGroups: /^wholesale$/,
        restrictedPaymentOption: /^C\.O\.D\. $/,
        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)){
                        reg_ck_s = ck_name[0].split('=');
                        reg_ck_value = reg_ck_s[1];
                        var reg_ck = reg_ck_value.split('|');
                        if(reg_ck[2]=='yes'){ 
                            LexiConn.regCustomer = true;
                        }
                        LexiConn.regGroup = reg_ck[1];
                     }
                }
            }
        },
        restrictCouponBox: function(){
            document.order.coupon_code.parentNode.style.display = 'none';
        },
        enableCouponBox: function(){
            document.order.coupon_code.parentNode.style.display = 'block';
        },
        disableCOD: function(){
            var paytype = document.getElementById('selPaytype');
            var payopt = paytype.options;
            var option_count = payopt.length - 1;
            for(n=option_count; n>0; n--){ 
                if(LexiConn.restrictedPaymentOption.test(paytype[n].innerHTML)){
                    paytype.removeChild(payopt[n]);
                }
            }
        },
        restrictCouponReg: function(values){
            LexiConn.getCookie();
            if(LexiConn.regCustomer==true){
                if(LexiConn.restrictedCustomerGroups.test(LexiConn.regGroup)){
                    LexiConn.restrictCouponBox();
                } else{
                    LexiConn.enableCouponBox();
                }
    
                if(!LexiConn.restrictedPaymentGroups.test(LexiConn.regGroup)){
                        LexiConn.enableCOD();
                }
    
                
            } else{
                    LexiConn.enableCouponBox();
                    LexiConn.disableCOD();
            }
        }
    }
    
     </script>
    Here is the attempted modification:

    Code:
    		<script type="text/javascript">
    
    var LexiConn = {
        regCustomer: false,
        reg_cookie: /.*ss_reg_.*/,
        regGroup: null,
        restrictedCustomerGroups: /^wholesale$/,
        restrictedPaymentGroups: /^wholesale$/,
        restrictedPaymentOption: /^C\.O\.D\. $/,
        restrictedShippingOption: /^ss_free$/,
        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)){
                        reg_ck_s = ck_name[0].split('=');
                        reg_ck_value = reg_ck_s[1];
                        var reg_ck = reg_ck_value.split('|');
                        if(reg_ck[2]=='yes'){ 
                            LexiConn.regCustomer = true;
                        }
                        LexiConn.regGroup = reg_ck[1];
                     }
                }
            }
        },
        restrictCouponBox: function(){
            document.order.coupon_code.parentNode.style.display = 'none';
        },
        enableCouponBox: function(){
            document.order.coupon_code.parentNode.style.display = 'block';
        },
    disableFreeShipping: function(){
    	var ship = document.getElementByName("shipping");
        var shipopt = ship.options;
        var option_counter = shipopt.length - 1;
            for(n=option_counter; n>0; n--){ 
                if(LexiConn.restrictedShippingOption.test(ship[n].innerHTML)){
                    shipping.removeChild(shipopt[n]);
    				
    			}
    		}
    	},
        disableCOD: function(){
            var paytype = document.getElementById('selPaytype');
            var payopt = paytype.options;
            var option_count = payopt.length - 1;
            for(n=option_count; n>0; n--){ 
                if(LexiConn.restrictedPaymentOption.test(paytype[n].innerHTML)){
                    paytype.removeChild(payopt[n]);
                }
            }
        },
    restrictCouponReg: function(values){
    		int shippingtotal = 199;
    		LexiConn.getCookie();
            if(LexiConn.regCustomer==true){
                if(LexiConn.restrictedCustomerGroups.test(LexiConn.regGroup)){
    				if ('ss_subtotal' <= 'shippingtotal'){
    					LexiConn.disableFreeShipping();
    					LexiConn.restrictCouponBox();
    				} 
    				else{
    					LexiConn.restrictCouponBox();
    					}
    				}
    			else{
    				LexiConn.enableCouponBox();
    				}
    
    			if(!LexiConn.restrictedPaymentGroups.test(LexiConn.regGroup)){
                        LexiConn.enableCOD();
    					if ('ss_subtotal' <= 'shippingtotal'){
    					LexiConn.disableFreeShipping();
    				}
                }
    			} 
    		
    		else{
    					LexiConn.enableCouponBox();
    					LexiConn.disableCOD();
    			}
    		}
    
     </script>
    If the source code is needed i can post a shortened version of it.

    Any help would be greatly appreciated.

  • #2
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    60 views and not even a your post doesn't make sense response... Nice Forum

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Location
    Sweden
    Posts
    154
    Thanks
    1
    Thanked 22 Times in 22 Posts
    Maybe people are to lazy to shuffle your code blocks into a text diff tool to find out what you've changed... I know I am

  • #4
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ironboy View Post
    Maybe people are to lazy to shuffle your code blocks into a text diff tool to find out what you've changed... I know I am
    ctrl + c then ctrl + v was the biggest hurdle I surpassed when learning how to use this device most commonly known as a computer.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •