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

fix: allow restrictions on nested properties #6578

Merged
merged 2 commits into from
Oct 20, 2022

Conversation

range123
Copy link
Contributor

Resolves #6501
Impact: minor
Type: bugfix

Issue

The checks for shipping restrictions based on an item's properties only work top for level properties in the item. It doesn't work for nested properties such as price.amount or subtotal.amount.

Steps to reproduce:

  1. Create a product, create a variant with the price attribute set.
  2. Create a shipping method.
  3. Create a "deny" shipping restriction with the attribute price.amount which would exclude the shipping method for the product if it was applied.
  4. See that the shipping method is available for the cart in checkout process even when it shouldn't be (based on restriction price value).

Solution

Can be solved by using lodash _.get() for getting the nested property from the item, instead of using the default javascript getter. This would make sure the restrictions work with both nested and non-nested attributes.

Testing

  1. Create a product, create a variant with the weight and price attribute set.
  2. Create a shipping method.
  3. Create "deny" shipping restriction with the attribute weight which would exclude the shipping method for the product if it was applied.
  4. Create another "deny" shipping restriction with the attribute price.amount which would exclude the shipping method for the product if it was applied.
  5. See that the shipping method is available/unavailable for the cart in checkout process (based on the restrictions).

Signed-off-by: Jayaraman N R <jayaraman17064@cse.ssn.edu.in>
@changeset-bot
Copy link

changeset-bot bot commented Oct 19, 2022

🦋 Changeset detected

Latest commit: 769c218

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@reactioncommerce/api-plugin-shipments-flat-rate Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brent-hoover
Copy link
Collaborator

@range123 I would like to see a test case for this

@brent-hoover brent-hoover self-requested a review October 19, 2022 22:01
Signed-off-by: Jayaraman N R <jayaraman17064@cse.ssn.edu.in>
@range123
Copy link
Contributor Author

Added tests! @zenweasel

@brent-hoover brent-hoover merged commit 871d46c into reactioncommerce:trunk Oct 20, 2022
This was referenced Oct 21, 2022
sujithvn added a commit that referenced this pull request Oct 27, 2022
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
sujithvn added a commit that referenced this pull request Nov 3, 2022
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
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.

Attribute checks in shipping restrictions don't work for nested item properties (e.g. parcel.*)
2 participants