Total Checkout - Post ID 275024

User 406146 Photo


Registered User
83 posts

Ok its a start and sorry about confusion i did state my changes probably should have just removed post and started over.
As for the code its starting to take shape and once i tested it gave me a price of first item but didn't adjust to more qty when selecting multiple items or when i changed filter type..? The form has the option to add 10 different items and seems like the code is only reading one.
User 187934 Photo


Senior Advisor
20,181 posts

Yes the code is only looking at the one drop down. I wasn't going to add anything else because I was afraid the form would change again.:lol:
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 406146 Photo


Registered User
83 posts

if you know any other better way of making the PF with all these options your opinion is welcomed but thats what i could come up with limited options and still trying to get it all to work??????? :|
User 187934 Photo


Senior Advisor
20,181 posts

Here's some to get you started. I heavily commented this code so you know where to place additional as needed.
This is for the first two items only.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);

// version 3
jQ( document ).ready(function() {
jQ('input[name="total"]').prop('readonly', true);
var qty1 = 0;
var Item_1 = 0.00;
var qty2 = 0;
var Item_2 = 0.00;
// add more qty# and Item_# as you add more calculations



jQ('select[name^="Item"],input[name^="Item"]').on('change', function() {

// Start of Item_1 calculation
var filter_type1 = jQ('select[name="Item_1_filter_type"]').val();

if(filter_type1 == "Pleated Filter 12pk (1-Inch Thick) $79.95"){
price1 = 79.95;
qty1 = jQ('input[name="Item_1_1inch_qty"]').val();
}
else if(filter_type1 == "Pleated Filter 12pk (2-Inch Thick) $89.95"){
price1 = 89.95;
qty1 = jQ('input[name="Item_1_2inch_qty"]').val();

}
else if(filter_type1 == "Pleated Filter 4pk (4-Inch Thick) $99.95"){
price1 = 99.95;
qty1 = jQ('input[name="Item_1_4inch_qty"]').val();
}
else if(filter_type1 == "Pleated Custom Size 12pk (1-Inch Thick) $85.95"){
price1 = 85.95;
qty1 = jQ('input[name="Item_1_1inch_custom_qty"]').val();
}
else if(filter_type1 == "Pleated Custom Size 12pk (2-Inch Thick) $95.95"){
price1 = 95.95;
qty1 = jQ('input[name="Item_1_2inch_custom_qty"]').val();
}
else if(filter_type1 == "Pleated Custom Size 4pk (4-Inch Thick) $105.95"){
price1 = 105.95;
qty1 = jQ('input[name="Item_1_4_custom_inch_qty"]').val();
}

if(jQ.isNumeric(qty1) && filter_type1 != ""){
Item_1 = price1 * parseInt(qty1) ;
calculate_total(Item_1,Item_2);// add more Item_# as you add more calculations
}

// End of Item_ 1 calculation


// Start of Item_2 calculation

var filter_type2 = jQ('select[name="Item_2_filter_type"]').val();

if(filter_type2 == "Pleated Filter 12pk (1-Inch Thick) $79.95"){
price2 = 79.95;
qty2 = jQ('input[name="Item_2_1inch_qty"]').val();
}
else if(filter_type2 == "Pleated Filter 12pk (2-Inch Thick) $89.95"){
price2 = 89.95;
qty2 = jQ('input[name="Item_2_2inch_qty"]').val();
}
else if(filter_type2 == "Pleated Filter 4pk (4-Inch Thick) $99.95"){
price2 = 99.95;
qty2 = jQ('input[name="Item_2_4inch_qty"]').val();
}
else if(filter_type2 == "Pleated Custom Size 12pk (1-Inch Thick) $85.95"){
price2 = 85.95;
qty2 = jQ('input[name="Item_2_1inch_custom_qty"]').val();
}
else if(filter_type2 == "Pleated Custom Size 12pk (2-Inch Thick) $95.95"){
price2 = 95.95;
qty2 = jQ('input[name="Item_2_2inch_custom_qty"]').val();
}
else if(filter_type2 == "Pleated Custom Size 4pk (4-Inch Thick) $105.95"){
price2 = 105.95;
qty2 = jQ('input[name="Item_2_4_custom_inch_qty"]').val();
}

if(jQ.isNumeric(qty2) && filter_type2 != ""){
Item_2 = price2 * parseInt(qty2) ;
calculate_total(Item_1,Item_2);// add more Item_# as you add more calculations
}
// End of Item_ 2 calculation

// Add more calculations for each dropdown here adjust Item_#, price#, qty#, and addjust filter_type#




// Add calculations above here.
});

//This calculates the total after changes have been made. Add more Item_#'s for each caculation added above
function calculate_total(Item_1,Item_2){
var Total_Cost_Raw = Item_1 + Item_2;
var Total_Cost = Total_Cost_Raw.toFixed(2);
console.log(Total_Cost);
jQ('input[name="total"]').val(parseFloat(Total_Cost));
}
});
</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 406146 Photo


Registered User
83 posts

Thank you for the code took it off the live site until I get it all working cause this website is live so don't want to interrupt purchasing.....

I just wish WFB had better way of listing items with options or custom user input and qty! With out having to work around it making so many tabs for each little thing. SMH

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.