1999 Posts in 530 Topics by 433 members
E-Commerce Modules
SilverStripe Forums » E-Commerce Modules » Calculate Shipping Rate based on Shipping Zip Code
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1457 Views |
-
Calculate Shipping Rate based on Shipping Zip Code

14 April 2010 at 7:30am Last edited: 14 April 2010 7:30am
I'm working on a (US) zip code based shipping module for Ecommerce v.6.
First, I added a field named 'ShippingZip' to the OrderForm class. There's a list of 10 zip codes (set in config file similar to Simple Shipping Modifier) that get one rate, and any other zip code gets the default rate.
The problem is, I'm so far unable to read the value of the entered ShippingZip value in the form to pull into the modifier and check against the list. I've disabled the JS based validation, leaving the server side enabled (so I can see if the shipping cost updates in the order form). When the page reloads after submitting with a value for ShippingZip, the value is being populated in the field by javascript (i believe) but not in the value attribute of the input in the HTML source.
I thought I was on to something with the populate defaults recipe but still no luck.
If anyone can point me in the right direction on this I'd greatly appreciate it.
-
Re: Calculate Shipping Rate based on Shipping Zip Code

14 April 2010 at 9:17am
Figured it out:
Needed to use the AJAX update field functionality (for the country drop down) in the OrderForm and Shopping Cart classes, so set the value of ShippingZip in the session. Shipping Modifier gets updated on AJAX change and reads the value from the session (defined in shopping cart). Also needed to add the input onchange code for ShippingZip to the ecommerce.js file so it would update the form fields on change.
Now that I see how it's setup, it's actually some very nice code behind that functionality.
Hope this helps someone else.
| 1457 Views | ||
|
Page:
1
|
Go to Top |

