I am trying to modify my shipping category costs on checkout depending on the country and I have followed the instructions in http://wiki.foxycart.com/snippets/shipping/multiple_flat_rates
My shipping logic is simple:
If the shipment is going to Canada then set the prices in each category to certain values.
If the shipment is going to USA then set the prices in each category to different values.
Here is my custom shipping logic code:
(When the country changes on the checkout form, the alerts work fine...but any items in the cart that belong to those categories do not get their shipping costs updated.)
/* BEGIN CUSTOM SHIPPING LOGIC */
if (typeof(country_code) === "undefined")
country_code = "";
new_country_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : jQuery("#customer_country").val());
if (country_code != new_country_code) // The shipping country has changed!
country_code = new_country_code;
//removeCustomShippingContainer(); // This call will make sure that when it updates, it starts fresh.
if (country_code == "CA")
alert('Ship to Canada');
if (country_code == "US")
alert('Ship to USA');
/* END CUSTOM SHIPPING LOGIC */
My question is this... how/and where do I set the "code" parameter for the updateShippingOptionCost(code, cost) function.
Where do I set codes 1,2,&3? In my product links? Are these the actual "Category Codes" from my FoxyCart categories? Is this a custom parameter I need to include in my product links?
I have tried including it in my product links.
<a href="https://mygreatsite.foxycart.com/cart?name=My Great Product
<img id="buyNowButton" src="/images/global/buyNowButton.jpg" />
The docs say this needs to be an Integer...but when I use FireBug to look at fc_jason.products.code the value is listed as a string.
I think my problem is simply that I am not accessing the code parameter correctly.
Any help is appreciated.
Unfortunately I cannot provide access to the live site as it's behind a private development area.