Active shipping basics

30 views
Skip to first unread message

ravenna

unread,
Nov 16, 2009, 10:39:23 AM11/16/09
to Active Merchant
Can someone outline where the code goes? I know this is a seriously
newb question but I am trying to learn. Working on my first ecommerce
site. I have active merchant setup with a test account at
Authorize.net but I need to calculate UPS shipping. Here is what I am
trying to learn:
-How to setup the code that intefaces with UPS.com. ( I already
have my account with them)
-I have a product with a parameter for weight. I need to calculate
the cost to ship from my default location to the customer.
-Should I add size parameters to my Product, for better accuracy to
the calculation?


I see in the github docs/readme, what looks like 2 new models, package
and Location... I think I just need someone to point me in the right
direction...

thanks so much

James MacAulay

unread,
Nov 16, 2009, 3:13:15 PM11/16/09
to Active Merchant
The code to use Active Shipping can go wherever you want in your
application. It could go in one of your controller actions if the
logic to interface your app with the library ends up being simple
enough. Otherwise, you might want to make some kind of model of your
own that encapsulates all of that.

In Shopify, we have an Order model which has a total weight associated
with it, along with a shipping address. The shop also has an origin
address. We construct ActiveMerchant::Shipping::Location objects out
of those addresses and pass them to UPS#find_rates along with an
ActiveMerchant::Shipping::Package object representing the order.

We just use the weight from the order and a fake set of dimensions to
construct the package, but if you want to use real dimensions then you
will want to come up with a packing algorithm of some kind to figure
out how exactly the line items are going to be bundled up into a
smaller number of containers.

The usage examples in the readme show how to construct Locations,
Packages, and Carriers, and how to use the find_rates method once
you've got all of that in place.

Is that any clearer?

-James
Reply all
Reply to author
Forward
0 new messages