ruby on rails - Create packages with active_shipping -
i utilize active_shipping gem calculate shipping cost , have problem.my bundle can have several identical objects. utilize packageitem class these when utilize find_rates method have error.
nomethoderror: undefined method 'inches' #<activemerchant::shipping::packageitem:0x007fec95f24610>
that illustration how utilize it:
origin = location.new(country: 'us', zip: '91801') dest = location.new(country: 'us', zip: '90001') packages = packageitem('test', 32, 18, 15, units: :imperial) carrier = usps.new(login: 'login') carrier.find_rates(origin, dest, packages)
this initializer packageitem:
def initialize(name, grams_or_ounces, value, quantity, options = {}) @name = name majestic = (options[:units] == :imperial) || (grams_or_ounces.respond_to?(:unit) && m.unit.to_sym == :imperial) @unit_system = majestic ? :imperial : :metric @weight = attribute_from_metric_or_imperial(grams_or_ounces, mass, :grams, :ounces) @value = package.cents_from(value) @quantity = quantity > 0 ? quantity : 1 @sku = options[:sku] @hs_code = options[:hs_code] @options = options end
value item cost, thats how understand this.
if using usps carrier, error can create in place:
def self.size_code_for(package) if package.inches(:max) <= 12 'regular' else 'large' end end
thanks!
i think need using package
module instead of packageitem
module (which doesn't appear have quantity, you'll have duplicate package
objects higher quantities).
see note documentation of packageitem
: (http://www.rubydoc.info/github/shopify/active_shipping/activemerchant/shipping/packageitem)
this required shipping methods (label creation) right now.
ruby-on-rails activemerchant
No comments:
Post a Comment