-
Notifications
You must be signed in to change notification settings - Fork 219
Add minimum quantity and step so Cart Block and Store API. #5037
Conversation
Size Change: +1.36 kB (0%) Total Size: 820 kB
ℹ️ View Unchanged
|
Hey @senadir -- I have had a chance to quickly set up an example and do some tests. One issue I noticed is that once I increase the cart item quantity to 2 or higher, I am no longer able to set it back to 1. On another note, I tried to continue where we left things off in this PR and have the following to share:
Here's some code you can use to play around with this state-related problem:
What this code does, in a nutshell: Whenever you change the quantity of an item called "Hoodie", it searches for an item called "Belt", and tries to keep the quantity of the latter in sync with the former. Here's how this works in the legacy cart: Screen.Recording.2021-11-23.at.05.15.18.p.m.mp4And here's what's happening in the block cart: Screen.Recording.2021-11-23.at.05.17.51.p.m.mp4Note that I need to refresh to get the qty of the "synced" item to update, although it's coming back just fine through the API. I'm not sure if this needs to be addressed in this PR (probably not?) but it's still a roadblock, and one that we'll need to overcome to make the new Cart/Checkout Blocks compatible with Force Sells, Product Bundles, Composite Products, Mix and Match Products, and likely other extensions that rely on the |
8169696
to
f01c1c1
Compare
Yes, I noticed this as well, seems like a bug.
Keeping cart in sync is working, you can see the item subtotal changing, there's a small bug you can see there around reinitaiting state, that needs to be fixed, probably in a another PR. |
Yup, that's probably a separate issue -- definitely a blocking one for what we're trying to achieve! Will open a new issue with the description from the last comment. Thanks!!! |
79fd824
to
2882d3c
Compare
Note that work on this was moved to #5406. I will be closing this in favor of that one. |
This PR adds
minimum
andstep
concepts to Store API and Cart Block.This functionality is still mainly plugin land, so we're not actually implementing a way for a merchant to setup a step or a minimum amount, but we're laying the foundation for plugins to use this, in Store API, via two new filters:
woocommerce_store_api_item_quantity_minimum
woocommerce_store_api_item_quantity_step
Following on the steps of
woocommerce_store_api_product_quantity_limit
.The second addition is honoring those values in Cart Block. Cart Item quantity switcher now honors minimum and step values and would change according to them.
Based on 66b0534
Testing steps
Caveats:
Changelog