-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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 quantity rule logic around buy buttons #2255
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a comment on the naming. Let me know your thoughts
snippets/buy-buttons.liquid
Outdated
@@ -42,28 +42,25 @@ | |||
class="product-variant-id" | |||
> | |||
<div class="product-form__buttons"> | |||
{%- liquid | |||
if product.selected_or_first_available_variant.quantity_rule.min > product.selected_or_first_available_variant.inventory_quantity and product.selected_or_first_available_variant.inventory_policy == 'deny' or product.selected_or_first_available_variant.inventory_management != 'shopify' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these!
I do feel this is surfacing some unnecessary logic in the front end, would be good to suggest a server-side check for these conditions tied to a single Liquid property for the future.
snippets/buy-buttons.liquid
Outdated
assign check_against_inventory = true | ||
if product.selected_or_first_available_variant.inventory_management != 'shopify' | ||
assign check_against_inventory = false | ||
elsif product.selected_or_first_available_variant.inventory_policy == 'continue' | ||
assign check_against_inventory = false | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to have this logic instead.
inventory_management
can be set to not be tracked and therefor won't be equal to shopify
. And when it's not tracked by Shopify, the Continue selling when out of stock
setting/checkbox disappears from the admin but the value of product.selected_or_first_available_variant.inventory_policy
is still deny
. Which didn't work out with the previous logic I had.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if the merchant can turn on the Continue selling when out of stock
elsewhere (third party) if they are tracking inventory elsewhere? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No they shouldn't be able to as when they're not tracking the inventory through Shopify that Continue selling when out of stock
checkbox is hidden like shown in the screenshot of my above comment 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think in Bulk Editor you still can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right 👍 Though I don't think it should be a problem with the current logic we have 🙂
Cause if it's not tracked in Shopify, we won't disable the button. And if it's not tracked and also set to continue selling when out stock, it will still not disable the buy buttons 👌
Co-authored-by: Sofia Matulis <sofiamatulis@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to Sofia's comment, otherwise looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Ludo
PR Summary:
There is an issue with the logic we currently have around the buy buttons and quantity rules. We're not accounting for the scenarios in which the merchant has set their products/variants to
continue selling when out of stock
.Why are these changes introduced?
Fixes #2246
What approach did you take?
Added another check to make sure the
inventory_policy
isn't set tocontinue
Other considerations
Should we look into a different logic ?
Visual impact on existing themes
No visual impact, it's tweaking some logic that hasn't shipped yet to our published themes.
Testing steps/scenarios
TEST - No featured image
product, and select theyellow-4 (no-sku)
test prod no media no variant with a long title for testing purposes
. It used to disable the buy buttons but shouldn't anymoreDemo links
Checklist