-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Experimental iAPI Mini Cart - Finish up features: min/max steppers, discount badges, empty mini cart contents, open drawer when add to cart #58716
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
Conversation
|
Size Change: +3.52 kB (+0.06%) Total Size: 5.84 MB
|
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
📝 WalkthroughWalkthroughThis update enhances the WooCommerce mini-cart feature by introducing support for minimum and maximum values, discount badges, improved subtotal formatting, and refined interactivity. It includes new and refactored store actions and getters, updates to markup for accessibility and discount display, CSS for conditional visibility, and feature-flagged rendering logic. Changes
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (4)⏰ Context from checks skipped due to timeout of 90000ms (27)
🔇 Additional comments (6)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 6
🔭 Outside diff range comments (2)
plugins/woocommerce/src/Blocks/BlockTypes/MiniCartFooterBlock.php (2)
28-34: Subtotal calculation is wrong –get_subtotal_tax()returns tax, not “subtotal including tax”.
get_subtotal_tax()yields only the tax amount. To output the subtotal including tax you must add both values:- $subtotal = $display_cart_price_including_tax ? $cart->get_subtotal_tax() : $cart->get_subtotal(); + $subtotal = $cart->get_subtotal(); + if ( $display_cart_price_including_tax ) { + $subtotal += $cart->get_subtotal_tax(); + }Current code under-reports the subtotal (shows only tax!) whenever the “incl” option is active.
51-66: State namespace mismatch –formattedSubtotalis stored under the footer block but read from the mini-cart store.wp_interactivity_state( $this->get_full_block_name(), // → woocommerce/mini-cart-footer-block [ 'formattedSubtotal' => $formatted_subtotal ] );Yet the markup binds to:
<span data-wp-text="woocommerce/mini-cart::state.formattedSubtotal">Unless another component also puts
formattedSubtotalintowoocommerce/mini-cart::state, the span will render empty. Either:
- Move the state to the
woocommerce/mini-cartnamespace, or- Revert the attribute back to
woocommerce/mini-cart-footer-block::state.formattedSubtotal.Please align the two to avoid broken UI.
🧹 Nitpick comments (6)
plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php (1)
8-8: Remove or use the newly-importedAssetDataRegistry.
AssetDataRegistryis imported but never referenced in this trait. Unused imports trigger PHPCS warnings and needlessly bloat the opcode cache.-use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;Either remove the line or actually leverage the registry here (e.g. for injecting shared data).
plugins/woocommerce/client/blocks/assets/js/base/components/cart-checkout/product-badge/style.scss (1)
11-13: Optional: add!importantto guarantee hiding wins over block styles.Several components inject inline
display:inlinerules at runtime. If that happens after this stylesheet loads, the selector loses. Appending!importantguarantees the element is hidden whenever[hidden]is present.- display: none; + display: none !important;Non-blocking; ignore if all consumers rely solely on the native
[hidden]behaviour.plugins/woocommerce/client/blocks/assets/js/base/components/product-price/style.scss (1)
19-21: Mirror the badge rule – consider!important.Same reasoning as the badge CSS: a later inline style could override this
display:none. Using!importantwould bullet-proof the hide logic.- display: none; + display: none !important;Minor, feel free to skip if you are confident no competing inline styles exist.
plugins/woocommerce/src/Blocks/BlockTypes/EmptyMiniCartContentsBlock.php (1)
44-55: Minor formatting / a11y polishConsider adding
aria-hidden="true"to the outer wrapper whenstate.cartIsEmptyis false. This keeps assisted tech in sync with thehiddenbinding and matches the convention used elsewhere in Core blocks.Purely optional – code functions as-is.
plugins/woocommerce/src/Blocks/BlockTypes/MiniCartShoppingButtonBlock.php (1)
42-60: Escape translated output
$start_shopping_labelis user-facing text. Echo it withesc_html()to avoid edge-case XSS when translation files are compromised.- echo $start_shopping_label; + echo esc_html( $start_shopping_label );plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php (1)
128-153: Button glyphs: consider accessible alternativesThe full-width
+ / -characters can be mis-pronounced by some screen-readers. Prefer SVG icons or a visually-hidden+ / –witharia-labels already supplied.Optional but improves a11y consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
plugins/woocommerce/changelog/58716-dev-min-max-discount(1 hunks)plugins/woocommerce/client/blocks/assets/js/base/components/cart-checkout/product-badge/style.scss(1 hunks)plugins/woocommerce/client/blocks/assets/js/base/components/product-price/style.scss(1 hunks)plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts(5 hunks)plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts(8 hunks)plugins/woocommerce/src/Blocks/BlockTypes/EmptyMiniCartContentsBlock.php(1 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php(3 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCartFooterBlock.php(1 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php(3 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCartShoppingButtonBlock.php(2 hunks)plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php (1)
Learnt from: mreishus
PR: woocommerce/woocommerce#58891
File: plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php:0-0
Timestamp: 2025-06-16T21:59:26.243Z
Learning: In WooCommerce's CartSchema::get_item_response() method, when called in the context of BlocksSharedState::register_cart_interactivity(), the method returns a plain array rather than a WP_REST_Response object, making it directly suitable for wp_interactivity_state() without needing to call ->get_data().
🧬 Code Graph Analysis (1)
plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php (2)
plugins/woocommerce/includes/wc-formatting-functions.php (1)
wc_price(567-640)plugins/woocommerce/src/Blocks/BlockTypes/AbstractBlock.php (1)
get_full_block_name(79-81)
⏰ Context from checks skipped due to timeout of 90000ms (14)
- GitHub Check: Blocks e2e tests 9/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core API tests - @woocommerce/plugin-woocommerce [api]
- GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: JavaScript - @woocommerce/block-library [unit]
- GitHub Check: PHP: 8.4 WP: latest [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: PHP: 8.4 WP: latest [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: Lint - @woocommerce/plugin-woocommerce
- GitHub Check: Lint - @woocommerce/block-library
- GitHub Check: Check Asset Sizes
- GitHub Check: build
🔇 Additional comments (3)
plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php (1)
126-130: Defensive fallback for missing shop page.
wc_get_page_id( 'shop' )may return0, in which caseget_permalink()returnsfalse. Down-stream callers expecting a string URL will then receivefalse, potentially breaking JS that assumes a string.- 'shopUrl' => get_permalink( wc_get_page_id( 'shop' ) ), + 'shopUrl' => (string) get_permalink( wc_get_page_id( 'shop' ) ) ?: '',Consider exposing an empty string (or omitting the key) when the shop page is not configured.
plugins/woocommerce/changelog/58716-dev-min-max-discount (1)
1-4: Changelog entry looks good.Accurately summarises the patch; no action needed.
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (1)
178-184: Defensive check for undefined cart item
getCartItemByIdcasts the result of.find()directly toCartItem. If the ID is missing it returnsundefined, causing downstream crashes. Consider returningnullor throwing early to aid debugging.- return wooStoreState.cart.items.find( ( item ) => item.id === id ) as CartItem; + return ( + wooStoreState.cart.items.find( ( item ) => item.id === id ) ?? null + );
plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts
Show resolved
Hide resolved
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Show resolved
Hide resolved
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Show resolved
Hide resolved
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (1)
202-255:parseIntvs decimal amounts and extraconvertPrecisioncallsThe discount calculations reuse the same truncating
parseIntpattern and callconvertPrecisionon every getter access, which is expensive.
- Use
parseFloat(or keep values in minor units).- Cache the
normalizedCurrency.minorUnitoutside the getter to avoid repeatedconvertPrecisionin tight loops (wp-eachover items).Example micro-refactor:
const parseAmount = (v:string) => Number.parseFloat(v); const { precision } = prices.raw_prices; const regular = Dinero({ amount: parseAmount(prices.raw_prices.regular_price), precision }); …Not critical but improves correctness and avoids unnecessary CPU on carts with many items.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts(5 hunks)plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts(8 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php(1 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php
- plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts
- plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php
🔇 Additional comments (2)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (2)
266-269: Good catch –cartItemMaximumnow returns the correct limit.This fixes the previous off-by-one bug and correctly caps the quantity input.
408-414: Guard againstNaN– issue resolved.The extra
Number.isNaNcheck prevents corrupt cart quantities when the user enters non-numeric text.
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Outdated
Show resolved
Hide resolved
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Show resolved
Hide resolved
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
plugins/woocommerce/src/Blocks/BlockTypes/EmptyMiniCartContentsBlock.php (2)
18-24: DocBlocks still reference “Filled” rather than “Empty” mini-cartBoth DocBlocks were copied from the previous implementation and no longer describe the current behaviour, which can trip up IDEs and future maintainers.
- * Render the markup for the Filled Mini-Cart Contents block. + * Render the markup for the Empty Mini-Cart Contents block. … - * Render the experimental interactivity API powered Filled Mini-Cart Contents block. + * Render the experimental interactivity-API powered Empty Mini-Cart Contents block.Also applies to: 34-40
44-50: Consider mirroring thearia-hiddencondition with aninertattribute for full accessibility
hiddenremoves the subtree from the accessibility tree, but focus can still be programmatically moved into it when the element is later shown. Addinginert(ortabindex="-1"on reveal) prevents accidental focus while the drawer is closed.Not critical for functionality, but worth evaluating against WCAG focus-management guidelines.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
plugins/woocommerce/src/Blocks/BlockTypes/EmptyMiniCartContentsBlock.php(2 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php(4 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCartShoppingButtonBlock.php(2 hunks)plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- plugins/woocommerce/src/Blocks/Utils/BlocksSharedState.php
- plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php
- plugins/woocommerce/src/Blocks/BlockTypes/MiniCartShoppingButtonBlock.php
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Lint - @woocommerce/plugin-woocommerce
- GitHub Check: Lint - @woocommerce/block-library
- GitHub Check: Validate changelog
- GitHub Check: build
- GitHub Check: Check Asset Sizes
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.
Actionable comments posted: 1
♻️ Duplicate comments (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (1)
79-97: RepeatedparseInttruncates fractional amounts – acknowledged patternThe subtotal logic inherits the existing
parseInt-based approach that drops decimal parts (e.g."12.99"→12). This is consistent with the rest of the Mini-Cart code and your earlier decision to postpone a Dinero-wide refactor.No action required here.
🧹 Nitpick comments (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (1)
411-417: Redundant branch after early NaN guard
parseInt( '' )returnsNaN, which is already caught by theisNaNcheck and earlyreturn. The additionalelse if ( qty === '' )can never be reached.-} else if ( qty === '' ) { - finalQuantity = minimum; -}Removing this dead code slightly simplifies the flow without changing behaviour.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts(8 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php(1 hunks)plugins/woocommerce/src/Blocks/BlockTypes/MiniCartShoppingButtonBlock.php(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- plugins/woocommerce/src/Blocks/BlockTypes/MiniCartShoppingButtonBlock.php
- plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php
🧰 Additional context used
🧠 Learnings (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (3)
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.435Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:132-149
Timestamp: 2025-06-17T07:07:01.274Z
Learning: The WordPress Interactivity API's wp-init directive automatically handles cleanup by calling any function returned from the init callback when the element is removed from the DOM. HTML directives cannot take complex JavaScript expressions.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:132-149
Timestamp: 2025-06-17T07:07:01.274Z
Learning: The WordPress Interactivity API's wp-init directive automatically handles cleanup by calling any function returned from the init callback when the DOM element is removed from the DOM. The callback function can optionally return a cleanup function, and if it does, wp-init will automatically execute it during element removal. HTML directives in the Interactivity API cannot take complex JavaScript expressions.
⏰ Context from checks skipped due to timeout of 90000ms (19)
- GitHub Check: JavaScript - @woocommerce/block-library [unit]
- GitHub Check: Blocks e2e tests 10/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 5/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 9/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 3/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 1/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: PHP: 8.4 WP: latest [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 2/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: PHP: 8.4 WP: latest [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: Lint - @woocommerce/block-library
- GitHub Check: Lint - @woocommerce/plugin-woocommerce
- GitHub Check: build
- GitHub Check: Check Asset Sizes
🔇 Additional comments (2)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (2)
127-145: Listener setup / teardown looks solid
setupOpenDrawerListenernow adds thewc-blocks_added_to_cartlistener only when needed and correctly returns a cleanup function for automatic teardown bywp-init. Nice job preventing duplicate listeners and leaks.
260-267: Correct maximum limit retrieval
cartItemMaximumnow correctly returnsquantity_limits.maximum, fixing the earlier bug that exposed the minimum limit.
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Outdated
Show resolved
Hide resolved
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.
Actionable comments posted: 3
🧹 Nitpick comments (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (1)
341-352: Potential XSS viashort_descriptioninnerHTML injectionAlthough WooCommerce generally filters product descriptions, relying on that sanitisation at this point is brittle.
Inserting HTML directly bypasses React/Interactivity API’s escaping and could open a hole if upstream filtering changes.Consider:
- Whitelisting allowed tags with
DOMPurify(already a WC dependency).- Rendering the description server-side and passing the safe markup via block config.
Hardening this now avoids a class of future security bugs.
[security]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts(8 hunks)
🧰 Additional context used
🧠 Learnings (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (3)
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.435Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:132-149
Timestamp: 2025-06-17T07:07:01.274Z
Learning: The WordPress Interactivity API's wp-init directive automatically handles cleanup by calling any function returned from the init callback when the element is removed from the DOM. HTML directives cannot take complex JavaScript expressions.
Learnt from: samueljseay
PR: woocommerce/woocommerce#58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:132-149
Timestamp: 2025-06-17T07:07:01.274Z
Learning: The WordPress Interactivity API's wp-init directive automatically handles cleanup by calling any function returned from the init callback when the DOM element is removed from the DOM. The callback function can optionally return a cleanup function, and if it does, wp-init will automatically execute it during element removal. HTML directives in the Interactivity API cannot take complex JavaScript expressions.
⏰ Context from checks skipped due to timeout of 90000ms (27)
- GitHub Check: Blocks e2e tests 10/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 6/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 9/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 4/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Metrics - @woocommerce/plugin-woocommerce [performance]
- GitHub Check: Blocks e2e tests 3/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 8/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 5/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 7/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core API tests - @woocommerce/plugin-woocommerce [api]
- GitHub Check: Blocks e2e tests 2/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Blocks e2e tests 1/10 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
- GitHub Check: JavaScript - @woocommerce/block-library [unit]
- GitHub Check: PHP: 8.4 WP: latest [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: PHP: 8.4 WP: latest [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
- GitHub Check: Lint - @woocommerce/block-library
- GitHub Check: Lint - @woocommerce/plugin-woocommerce
- GitHub Check: Check Asset Sizes
- GitHub Check: build
🔇 Additional comments (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (1)
446-472:incrementQuantity/decrementQuantitybypass min/max limitsThe actions blindly add ±1 and rely on the UI to disable the buttons.
Programmatic calls (or a future UI change) could exceed limits, producing 422 responses from the API.-quantity: cartItem.quantity + 1, +quantity: Math.min( + cartItem.quantity + 1, + cartItem.quantity_limits.maximum || Number.MAX_SAFE_INTEGER +),…and the symmetrical clamp for decrement.
Defensive coding here removes the need to trust every caller.
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Show resolved
Hide resolved
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Show resolved
Hide resolved
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
Outdated
Show resolved
Hide resolved
|
@coderabbitai configuration |
|
Please advise on where/how we can test it! |
|
Two functionality suggestions regarding proper UX.
|
|
Sadly, our theme, (Botiga) does not appear to be supporting it yet. Actually, by switching to it, it goes even slower than withou it.
Any suggestions for a (free) theme that does?
…________________________________
From: Luis Herranz ***@***.***>
Sent: Thursday, September 25, 2025 12:48 PM
To: woocommerce/woocommerce ***@***.***>
Cc: Dimitris Vayenas ***@***.***>; Comment ***@***.***>
Subject: Re: [woocommerce/woocommerce] Experimental iAPI Mini Cart - Finish up features: min/max steppers, discount badges, empty mini cart contents, open drawer when add to cart (PR #58716)
[https://avatars.githubusercontent.com/u/3305402?s=20&v=4]luisherranz left a comment (woocommerce/woocommerce#58716)<#58716 (comment)>
Please advise on where/how we can test it!
You can follow these instructions to test it.
* #59850<#59850>
When adding/removing a product to/from cart to have the option to NOT automatically open the mini-cart drawer but rather just update the counter in the floating mini cart area.
As far as I know, that has always been possible just by deactivating this checkbox in the minicart block options.
Screenshot.2025-09-25.at.11.46.52.png (view on web)<https://github.com/user-attachments/assets/f9b96b3b-3c10-4921-959b-d50296ddd0f1>
With the side/drawer cart open, when I remove a product from the list to have the option to NOT automatically close the side/drawer cart (because the user may want to remove more and/or another product). Also it is bad UX.
As far as I know, the mini cart overlay doesn't close when you remove a product.
—
Reply to this email directly, view it on GitHub<#58716 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BH4Z5HNS53Z66V7Y24U3EST3UO267AVCNFSM6AAAAAB7BTZ3NOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMZTGE2TONZZHE>.
You are receiving this because you commented.Message ID: ***@***.***>
|
|
This is a block, so you can use it in any block theme, or use a template part on your classic theme. |
|
My apologies, I was under the impression that it was build in on storefront etc. and that by activating was taking over automatically! ;) |
|
Here is my feedback in action. It is on the botiga theme. In this instance a product with a huge number of variations. Add to cart action is not working (you have to refresh the page to get the update). Also more complex actions when like having Complimentary products is not refreshing. Sadly I realized that it appears that it is as the add to cart call is not working. Here is a code that successfully opens the minicart, yet fails to update the item counter and the items in cart. The side cart per se is lovely, it updates instantly quick. Well done guys. Note that I have disabled all the plugins apart from woocommerce and pods and merchant (also made by the Botiga team). Also note the in Astra theme I have identical behaviour. @luisherranz if you like I can provide credentials in my lab site for you to investigate, cause I am running out of OpenAI credits 😃 I am sure that if I run in issues in setting it up, so do many others. Me thinks that in order for the testing/adoption to be successful, you have to make more seamless the transition. As I said, I was actually under the impression that by checking the box everything else is taken care off.... |
|
@luisherranz after having spent a couple of days trying to even set up a test rig - that only, partly, works on Storefront theme - here is my final feedback for this stage of development for such an important - actually the most important as far as I am concerned - feature. The importance of speed is impossible to be understated. In all fronts. And the add to cart action is one - even semantically - of the most important, if not the most important, as it also carries psychological connotations about the speed of delivery, the business itself and so on.
Nowadays most themes show the quantity in the buttons. It is obvious to expect that when quantity changes in the mini-cart it will update the quantity in the button, as instantaneously as it does in the minicart itself. It is been almost 4 years (ever since I occupied myself with building sites with Woo) that I had argued against this major pain point (cart fragments etc,) while say other platforms -such as Opencart- had this functionality since time immemorial. I hope that in version 10.3 you will offer us just this: one button (beta) experience that has actually being tested in popular block based themes such as Storefront, Astra and Botiga/Sydney. Thank you for your consideration - keep up the good work! May the force be with you ;) Edited: OpenAI proved ;) - plugin to test the cart with full logging (that may come handy to developers of themes). Does everything apart from refreshing its contents. |
You don't need to enqueue the scripts or styles. When you render the mini cart using blocks, they should be enqueued correctly.
The new Add to Cart with options (beta) block does precisely that. |
|
@luisherranz If I create a shortcode to add it to my theme (without having the block in the page), functionality is missing: It does not open the mini-cart on click for starters: This is why I tried to do it with the code above (and many more incarnations). The common theme was that interactivity api was not detected by the code, nor the cart (even when opened) was refreshing upon add to cart. Also I need to add the Free Shipping bar, but shorcodes in the block (any shortcode) does not seem to get rendered. It is as if it does not exist. One more suggestion and a crucial one. Have to allow for different behaviour between mobile and desktop. |
|
If you think there is a bug with the new Add to cart with options block, you should open an issue explaining how to reproduce the problem. Likewise, if you want to request a new feature. |



Changes proposed in this Pull Request:
Closes:
#58523
#58521
#58179
#58196
and has a workaround to solve #58673
Includes:
How to test the changes in this Pull Request:
Test min/max threshold
Test discount badge display
Test removing item from cart entirely
Test "open cart when adding" block setting
Test "display total price" block setting
Test empty cart state
Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment
Add min/max, discount badge support to experimental interactivity API mini cart.