...

View Full Version : Turn display off for subnode



wdmusicprod
10-07-2011, 07:03 PM
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:


<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:


<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.

wdmusicprod
10-07-2011, 10:24 PM
60 views and not even a your post doesn't make sense response... Nice Forum

ironboy
10-07-2011, 10:56 PM
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 :D

wdmusicprod
10-10-2011, 02:52 PM
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 :D

ctrl + c then ctrl + v was the biggest hurdle I surpassed when learning how to use this device most commonly known as a computer.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum