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 selecting admin-only shipping methods #2499

Merged
merged 9 commits into from
Jan 26, 2018

Conversation

jhawthorn
Copy link
Contributor

When calculating shipping rates, the standard behaviour is to calculate the rates using the Stock::Estimator and persist the results as ShippingRates. The user then selects their desired rate.

This behaviour falls apart when we want to have some shipping rates available only to admins. We don't want to persist those rates because it would make them available to users.

This PR solves the issue by introducing two new api endpoints:

GET /api/shipments/:id/estimated_rates
PUT /api/shipments/:id/select_shipping_method

The new estimated_rates endpoint will re-run the estimator and return the rates (including admin-only rates) without persisting them.

The select_shipping_method endpoint will re-run the estimator and persist only the specified rate, marking it as selected. This allows selecting admin-only rates.

The order shipments page has been updated to use these endpoints instead of relying on persisted shipping rates.

Fixes #1711

Copy link
Member

@gmacdougall gmacdougall left a comment

Choose a reason for hiding this comment

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

Great work on this John!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants