Elliot,
I actually did just get it working last weekend. I ended up actually
putting a shipping_address form on the cart form. Then I had to do a few
things:
1. Decorate the orders controller edit method to properly generate a
shipping address. I set everything but country, state, and zipcode to
"quote". Turns out you only need those 3 when calculating shipping.
2. On the shipping_address form I used hidden fields for all of the
fields I didn't want to show.
3. I had to expand the checkout coffeescript to include the quote fields
in the state mapping/setting and properly target the update-cart form.
4. Decorate the orders controller update method to check to see if the
get quote button is pressed. If it is, I remove the line item params so
they don't get updated. If it wasn't the quote button, you need to remove
the shipping_address_attributes params otherwise the order update will
throw an error.
5. Decorate the checkout controllers before_address method to remove the
quotes from the shipping_address if they are there.
6. Add logic to the view for showing rates. When the ship address is
present and valid, I show the values from the rates_hash method and hide
the shipping quote fields.
The advantage of using the shipping_address are many:
- The data persists across page loads so the user enters it once and
then each time the cart is updated the new shipping quote is displayed
- The country/state/zip code data is already there when the user enters
the billing/shipping addresses on checkout.
- If the user enters addresses in checkout and then goes back to the
cart, the system will user those checkout addresses for the shipping quote.
Right now this is bundled with my theme, but I will break it out into a
plugin w/ tests soon. It's heavily tied in at the moment and I am not sure
how useful it will be to you if you use the standard theme. I can send you
the code off list if you want.
Regards,
Nate
On Thursday, January 3, 2013 10:55:03 PM UTC-5, Elliot Gage wrote:Did you have any luck with getting something to work? I'm looking to do
the same as well.
Before I start hacking out a solution, thought I'd check ;)
On Saturday, December 15, 2012 10:12:09 AM UTC-8, Nate Lowrie wrote:
I want to be able to provide estimated shipping quote to people using a
country/zip code field entry. I am not sure how to continue. I see that
the rate_hash method passes in the order object and the calculators use the
shipping_address attribute on the order for the address. That said, is
there a way I can just pass in the country and zip code to get back the
rates hash?
I guess I can have the user enter a whole address, but the point is to
provide a quick method for calculating a shipping quote.
Regards,
Nate
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/spree-user/-/pjnOr_DHElQJ.To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/spree-user?hl=en.