diff --git a/app/models/spree/shipment_decorator.rb b/app/models/spree/shipment_decorator.rb index 6c41db0..c41877e 100644 --- a/app/models/spree/shipment_decorator.rb +++ b/app/models/spree/shipment_decorator.rb @@ -1,6 +1,11 @@ Spree::Shipment.class_eval do def self.exportable - query = order(:updated_at).joins(:order).merge(Spree::Order.complete).where.not(spree_shipments: { state: 'canceled' }) + easypost = Spree::StockLocation.find_by_name('Easypost') + if easypost.present? + query = order(:updated_at).joins(:order).merge(Spree::Order.complete).where.not(spree_shipments: { state: 'canceled', stock_location_id: easypost.id }) + else + query = order(:updated_at).joins(:order).merge(Spree::Order.complete).where.not(spree_shipments: { state: 'canceled' }) + end query = query.ready unless Spree::Config.shipstation_capture_at_notification query end diff --git a/app/views/spree/shipstation/export.xml.builder b/app/views/spree/shipstation/export.xml.builder index a1f26c5..945e707 100644 --- a/app/views/spree/shipstation/export.xml.builder +++ b/app/views/spree/shipstation/export.xml.builder @@ -29,16 +29,16 @@ xml.Orders(pages: (@shipments.total_count/50.0).ceil) { Spree::ExportHelper.address(xml, order, :ship) } xml.Items { - shipment.line_items.each do |line| - variant = line.variant + shipment.manifest.each do |item| + variant = item.variant xml.Item { xml.SKU variant.sku xml.Name [variant.product.name, variant.options_text].join(' ') xml.ImageUrl variant.images.first.try(:attachment).try(:url) xml.Weight variant.weight.to_f xml.WeightUnits Spree::Config.shipstation_weight_units - xml.Quantity line.quantity - xml.UnitPrice line.price + xml.Quantity item.quantity + xml.UnitPrice item.line_item.price if variant.option_values.present? xml.Options { diff --git a/lib/spree/shipment_notice.rb b/lib/spree/shipment_notice.rb index 1114b96..afef2a6 100644 --- a/lib/spree/shipment_notice.rb +++ b/lib/spree/shipment_notice.rb @@ -62,7 +62,7 @@ def ship_it! unless shipment.shipped? shipment.reload.ship! shipment.touch :shipped_at - shipment.order.update! + shipment.order.recalculate end true