Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow refreshing rates for unshipped complete orders #1906

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Solidus 2.3.0 (master, unreleased)

- Allow refreshing shipping rates for unshipped shipments on completed orders [\#1906](https://github.com/solidusio/solidus/pull/1906) ([mamhoff](https://github.com/mamhoff))
- Renamed `PaymentMethod#method_type` into `partial_name` [\#1978](https://github.com/solidusio/solidus/pull/1978) ([tvdeyen](https://github.com/tvdeyen))
- Order#outstanding_balance now uses reimbursements instead of refunds to calculate the amount that should be paid on an order. [#2002](https://github.com/solidusio/solidus/pull/2002) (many contributors :heart:)

Expand Down
7 changes: 7 additions & 0 deletions backend/spec/features/admin/orders/shipments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@ def ship_shipment
expect(page).to have_css("#shipment_#{shipment1.id} tr.stock-item", count: 4)
shipment2 = (order.reload.shipments.to_a - [shipment1]).first
expect(page).to have_css("#shipment_#{shipment2.id} tr.stock-item", count: 1)
within "#shipment_#{shipment2.id}" do
expect(page).to have_content("UPS Ground")
end

within_row(2) { click_icon 'arrows-h' }
complete_split_to("LA(#{shipment2.number})")
expect(page).to have_css("#shipment_#{shipment2.id} tr.stock-item", count: 2)
expect(page).to have_css("#shipment_#{shipment1.id} tr.stock-item", count: 3)

within "#shipment_#{shipment2.id}" do
expect(page).to have_content("UPS Ground")
end
end

context "with a ready-to-ship order" do
Expand Down
3 changes: 2 additions & 1 deletion core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def ready_or_pending?
end

def refresh_rates
return shipping_rates if shipped? || order.completed?
return shipping_rates if shipped?
return [] unless can_get_rates?

# StockEstimator.new assigment below will replace the current shipping_method
Expand Down Expand Up @@ -333,6 +333,7 @@ def transfer_to_location(variant, quantity, stock_location)
order.contents.add(variant, quantity, { shipment: new_shipment })

refresh_rates
new_shipment.refresh_rates
save!
new_shipment.save!
end
Expand Down