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 quantity rule logic around buy buttons #2255

Merged
merged 8 commits into from
Jan 27, 2023
Merged

Conversation

ludoboludo
Copy link
Contributor

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 to continue

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

  • Go to a product like the TEST - No featured image product, and select the yellow-4 (no-sku)
  • Then reload the page on that variant and you should see the buy buttons not disabled and be able to add it to the cart.
  • You can also test with the product test prod no media no variant with a long title for testing purposes. It used to disable the buy buttons but shouldn't anymore

Demo links

Checklist

Copy link
Contributor

@sofiamatulis sofiamatulis left a 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 Show resolved Hide resolved
@sofiamatulis sofiamatulis self-assigned this Jan 25, 2023
@@ -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'
Copy link
Contributor

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.

Comment on lines 46 to 51
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
Copy link
Contributor Author

@ludoboludo ludoboludo Jan 26, 2023

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.

Screenshot

Copy link
Contributor

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? 🤔

Copy link
Contributor Author

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 👍

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.

Copy link
Contributor Author

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>
KaichenWang
KaichenWang previously approved these changes Jan 26, 2023
Copy link
Contributor

@KaichenWang KaichenWang left a 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!

Copy link
Contributor

@sofiamatulis sofiamatulis left a comment

Choose a reason for hiding this comment

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

Thanks Ludo :shipit:

@ludoboludo ludoboludo merged commit 8eded48 into main Jan 27, 2023
@ludoboludo ludoboludo deleted the fix-quantity-rule-on-atc branch January 27, 2023 19:48
phapsidesGT pushed a commit to Gravytrain-UK/gt-shopify-dawn-theme that referenced this pull request Sep 3, 2024
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.

[PDP] Buy button disabled while "Continue selling while out of stock"
4 participants