-
Notifications
You must be signed in to change notification settings - Fork 409
Shipping categories, methods and zones
This is a bit hard to explain but...
A product belongs_to a shipping_category Shipping_categories have_many shipping_rates shipping_rates belong_to shipping_method_id
So effectively a shipping_category will have_many shipping_methods, through shipping_rates
shipping_category
has_many shipping_methods, :through => :shipping_rates
So now There needs to be a shipping_method for every shipping_zone you ship to.
Lets say you have 2 shipping zones: Canada and USA
Now you have a desk that you are selling on your site. The desk might have a shipping_category of "large furniture".
The shipping_category now must have at least 2 shipping_methods (hence also 2 shipping_rates)
- one shipping_method must have shipping_zone === CANADA
- one shipping_method must have shipping_zone === USA
Most likely you will have a few more shipping_methods for each shipping_zone.
This is actually something I'll try to validate before you can activate a product soon.
The following is a scenario that could occur if you don't set this up correctly.
NoMethodError in Shopping::ShippingMethodsController#update
undefined method `each_pair' for nil:NilClass
Application Trace | Framework Trace | Full Trace
app/controllers/shopping/shipping_methods_controller.rb:29:in `update'
Request
Parameters:
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"99B/uYxlO68pfDNgPgFNuFxdkuwdGQkVGaMn057nyFI=",
"commit"=>"continue",
"id"=>"3"}
Response
Headers:
None