-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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 –formattedSubtotal
is 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
formattedSubtotal
intowoocommerce/mini-cart::state
, the span will render empty. Either:
- Move the state to the
woocommerce/mini-cart
namespace, 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
.
AssetDataRegistry
is 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!important
to guarantee hiding wins over block styles.Several components inject inline
display:inline
rules at runtime. If that happens after this stylesheet loads, the selector loses. Appending!important
guarantees 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!important
would 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.cartIsEmpty
is false. This keeps assisted tech in sync with thehidden
binding 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_label
is 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-label
s 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
getCartItemById
casts the result of.find()
directly toCartItem
. If the ID is missing it returnsundefined
, causing downstream crashes. Consider returningnull
or 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
Outdated
Show resolved
Hide resolved
plugins/woocommerce/src/Blocks/BlockTypes/MiniCartItemsBlock.php
Outdated
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
Outdated
Show resolved
Hide resolved
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: 2
🧹 Nitpick comments (1)
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts (1)
202-255
:parseInt
vs decimal amounts and extraconvertPrecision
callsThe discount calculations reuse the same truncating
parseInt
pattern and callconvertPrecision
on every getter access, which is expensive.
- Use
parseFloat
(or keep values in minor units).- Cache the
normalizedCurrency.minorUnit
outside the getter to avoid repeatedconvertPrecision
in tight loops (wp-each
over 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 –cartItemMaximum
now 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.isNaN
check 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
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: 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-hidden
condition with aninert
attribute for full accessibility
hidden
removes 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
: RepeatedparseInt
truncates 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 theisNaN
check 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
setupOpenDrawerListener
now adds thewc-blocks_added_to_cart
listener 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
cartItemMaximum
now 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_description
innerHTML 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
/decrementQuantity
bypass 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
Outdated
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
Outdated
Show resolved
Hide resolved
@coderabbitai configuration |
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.