Hi Team,
I have all 3 of my products in the DEFAULT category and I have flat-rate shipping setup for this category at $5.00. I would like it so that if the cart quantity is greater than 1 then the shipping automatically gets zero-ed out. After looking at the wiki and a lot of forum posts, I have put the following code in my checkout template above the head tag however it still doesn't seem to be working. Can you help me find out what's going wrong? Thanks :-)
You can view my almost ready site at
http://dev.revolutiontrans63.com
function updateMyShippingCost() {
var shippingCost = FC.checkout.config.orderShipping;
for (i=0; i<fc_json.products.length;i++) {
if (fc_json.products[i].category == "DEFAULT") {
if (fc_json.product_count > 1) {
shippingCost = 0;
}
}
}
FC.checkout.config.orderShipping = shippingCost;
}
jQuery(document).ready(function(){
// set the custom function to run before the updatePriceDisplay function
FC.checkout.overload("updatePriceDisplay", "updateMyShippingCost", null);
});
You can actually do something much simpler than that for what you need:
Note that you'll also need to set your flat rate shipping setting in the administration to 0.
glad that worked for you!
Just checking in with you after a couple months of having the live site.
It turns out there have been a couple of customers who have managed to get by this javascript during checkout. I have no clue how that could be happening....
We were getting people with 1 item getting free shipping so I decided to set the default flat rate shipping setting in the administration to 5 instead of 0 to prevent.
Is there any reason the javascript would be failing or being ignored? I have not been able to replicate this behavior.
Yeah - including a second (or more) versions of jQuery definitely isn't a good thing and will more often than not cause follow on issues.
Just to note, make sure you set your flat rate setting back to 0 - as while the javascript will *appear* to make the shipping 0 on the checkout, if the setting in the admin is higher than that that's the figure that will get used.