From 59a4cc0ae1dbe16d017c4131a136a092d26e5f62 Mon Sep 17 00:00:00 2001 From: Octave Zangs Date: Sat, 22 Sep 2018 10:58:29 -0700 Subject: [PATCH 1/4] Use shipment manifest instead of line_items to handle replaced items --- app/views/spree/shipstation/export.xml.builder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/shipstation/export.xml.builder b/app/views/spree/shipstation/export.xml.builder index a1f26c5..7629114 100644 --- a/app/views/spree/shipstation/export.xml.builder +++ b/app/views/spree/shipstation/export.xml.builder @@ -29,7 +29,7 @@ xml.Orders(pages: (@shipments.total_count/50.0).ceil) { Spree::ExportHelper.address(xml, order, :ship) } xml.Items { - shipment.line_items.each do |line| + shipment.manifest.each do |line| variant = line.variant xml.Item { xml.SKU variant.sku From 55639cf234890abed6deb87eff9c596538d1df32 Mon Sep 17 00:00:00 2001 From: Octave Zangs Date: Sat, 22 Sep 2018 11:29:03 -0700 Subject: [PATCH 2/4] Improve syntax --- app/views/spree/shipstation/export.xml.builder | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/spree/shipstation/export.xml.builder b/app/views/spree/shipstation/export.xml.builder index 7629114..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.manifest.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 { From d63aa12006473e60a44ae66d09dfac789b1856a3 Mon Sep 17 00:00:00 2001 From: Octave Zangs Date: Tue, 23 Oct 2018 18:12:11 -0700 Subject: [PATCH 3/4] Use order.recalculate instead of deprecated order.update! --- lib/spree/shipment_notice.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 3d102243c8ffeb760a2020c7ed46b31c38c00c60 Mon Sep 17 00:00:00 2001 From: Octave Zangs Date: Tue, 12 Mar 2019 11:35:24 -0700 Subject: [PATCH 4/4] Don't fetch Easypost shipments --- app/models/spree/shipment_decorator.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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