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

Make code work with one shipment per order (even if the DB still supports Spree's multi shipments per order model) #6433

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

luisramos0
Copy link
Contributor

What? Why?

This is a draft attempt at #6428

I thought this would not be obvious for other people, this is what I think we can do.

Even better would be to change has_many :shipments in order.rb to has_one :shipment but I dont know how to do that without changing the DB? (the spree_shipments table with an order_id and no shipment_id in the spree_orders table)

Even better would be to change the DB... :-)

What should we test?

Release notes

Changelog Category: Technical changes
Making OFN code simpler in the shipments domain.

# If the selection is successful, it persists it in the database by saving the shipment.
# If it fails, it does not clear the current shipping_method selection.
#
# @return [ShippingMethod] the selected shipping method, or nil if the given shipping_method_id is
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [102/100]

shipment.shipping_method
end

# Finds the shipment's shipping_rate for the given shipping_method_id and selects that shipping_rate.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [105/100]

end

private

def prioritize_packages(packages)
def prioritize_package(package)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UnusedMethodArgument: Unused method argument - package. If it's necessary, use _ or _package as an argument name to indicate that it won't be used. You can also write as prioritize_package(*) if you want the method to accept any arguments but don't care about them.

@luisramos0
Copy link
Contributor Author

ping @Matt-Yorkley I wonder if you are looking at similar things as you look at adjustments. I am not sure if I have pinged you already, you will like this draft.

@Matt-Yorkley
Copy link
Contributor

Matt-Yorkley commented Dec 8, 2020

Nice 👍 I think I found an upstream commit from 2-2-stable which also would also improve loading the correct selected shipping rate.

…DB still supports multiple shipments per order
…upports multiple shipments per order in OFN, one order only has one shipment
@Matt-Yorkley
Copy link
Contributor

Matt-Yorkley commented Feb 6, 2021

I think we should have a go at this. I need to start touching shipments elsewhere, and it'll be simpler if we do this first. I'll take a look at it, there's still a few build errors.

#empty? is used on enumerators, it's not plural now.
These methods need to explicitly return false if there's no shipment (as they did before).
@Matt-Yorkley
Copy link
Contributor

It feels like some of these obscure classes like Stock::Prioritizer are designed solely to handle things like packages being split across multiple shipments...?

@luisramos0
Copy link
Contributor Author

luisramos0 commented Feb 7, 2021 via email

@andrewpbrett
Copy link
Contributor

I'm going to move this back to the Tech Debt column unless we're still actively working on it, feel free to move it back if so.

@luisramos0
Copy link
Contributor Author

ok, I am not planning to pick this up now but it's still a valid PR that makes the core order code easier to work with.

@kirstenalarsen kirstenalarsen added the bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. label Aug 10, 2021
@sigmundpetersen sigmundpetersen removed the bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: All the things 💤
Development

Successfully merging this pull request may close these issues.

5 participants