Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kieckhafer
Copy link
Member

@kieckhafer kieckhafer commented Nov 21, 2018

Impact: major
Type: feature

Issue

Shops should be able to restrict available shipping methods based on shipping location and attributes of items inside an order (price, brand, type of item, etc).

Solution

Create both universal and per-method ways to allow or deny a shipping method based on the address attached to the an order, and attributes attached to items in an order. This is done by creating a FlatRateFulfillmentMethodRestrictions collection, and creating allow and deny restrictions for each method inside this collection.

Breaking changes

None. These are add-on features. If no Allow or Deny restrictions are found on a method, the method will be allowed in the same way it currently is. If no surcharges are found, nothing is different.

Testing

  • Use these mongo dumps to load various shipping methods and restrictions into the database. This will update your shipping methods to include 10 flat rate methods to check the restrictions against, as well as creating a FlatRateFulfillmentRestrictions database, that includes various restrictions.

Use the dumps with the following commands:

mongorestore --db reaction --collection Shipping Shipping.bson
mongorestore --db reaction --collection FlatRateFulfillmentRestrictions FlatRateFulfillmentRestrictions.bson

  • Change the vendor of the Basic Reaction Product to Reaction to see a universal restriction

This video shows using a California address (contiguous 48 states), a Hawaii address, an Alaska address, and a New York Address, combined with the vendor being Reaction, which creates a universal restriction:
shipping restrictions mov

Examples that are built in to the data in the mongo dump:
Destination restrictions go down to a zip code level. Try changing the newYorkReactionVendor restriction to the following to only restrict certain postal codes, instead of all of New York State:

destination: {
  postal: [
    "10001", 10019"
  ]
}

This is easiest to test in the existing app, as you can add multiple addresses and easily switch between them to see the options change, but this will also work on the starterkit, with a little more effort to change the location when checking out.

There are also new GraphQL queries / mutations to add, delete, update, and get restrictions from the database.

willopez and others added 30 commits October 19, 2018 10:51
@kieckhafer
Copy link
Member Author

kieckhafer commented Dec 4, 2018

@aldeed Round two of comments addressed, good for a look. Thanks!

Copy link
Contributor

@aldeed aldeed left a comment

Choose a reason for hiding this comment

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

@kieckhafer Just a couple minor straggler comments. Seems about ready.

@aldeed aldeed merged commit 02647f7 into release-2.0.0-rc.8 Dec 11, 2018
@aldeed aldeed deleted the feat-kieckhafer-shippingRestrictions branch December 11, 2018 00:13
@spencern spencern mentioned this pull request Jan 8, 2019
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.

6 participants