Permalink
Browse files

Merge pull request #34 from jsqu99/usps_first_class_parcel_calculator

[Fixes #31] Missing USPS First Class Mail
  • Loading branch information...
2 parents b5db6e0 + a49dd71 commit d1bd602b795be4602e13596a3f8b512c9d7541ea @jumph4x jumph4x committed Oct 3, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 app/models/spree/calculator/usps/first_class_mail_parcels.rb
@@ -0,0 +1,23 @@
+require_dependency 'spree/calculator'
+
+module Spree
+ class Calculator < ActiveRecord::Base
+ module Usps
+ class FirstClassMailParcels < Calculator::Usps::Base
+
+ def self.description
+ "USPS First-Class Mail Parcel"
+ end
+
+ def available?(order)
+ multiplier = Spree::ActiveShipping::Config[:unit_multiplier]
+ weight = order.line_items.inject(0) do |weight, line_item|
+ weight + (line_item.variant.weight ? (line_item.quantity * line_item.variant.weight * multiplier) : 0)
+ end
+ #if weight in ounces > 13, then First Class Mail is not available for the order
+ weight > 13 ? false : true
+ end
+ end
+ end
+ end
+end

0 comments on commit d1bd602

Please sign in to comment.