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

Update snackbarNotices filter to snackbarNoticeVisibility #4417

Merged
merged 4 commits into from Jul 26, 2021

Conversation

opr
Copy link
Contributor

@opr opr commented Jul 1, 2021

After internal discussion at pca54o-1Gs-p2 I wanted to put this PR out there to see what folks think, the changes are made to stop third party extensions being able to modify the particulars of any snackbar notice, and control only whether it is shown to the user or not. An overview of the changes is:

  • Change the filter so that only an object keyed by the notice's message is passed to the filter - initially all values in this object will be true.
  • After the filters have done their work, remove any entries from the array whose value is false.
  • Filter the original list of notices so that only notices that have a corresponding entry in the one returned by the filter are shown.

How to test the changes in this Pull Request:

  1. Check out update/snackbar-filtering-function in WooCommerce Points and Rewards
  2. Run npm run build in the WC P&R directory.
  3. Ensure your user account has points (WooCoomerce > Points and Rewards)
  4. Add items to your cart and go to the Cart block.
  5. Try adding a coupon, ensure the snackbar notice shows for coupon addition.
  6. Remove the coupon, ensure the snackbar notice shows for coupon removal.
  7. Please don't add more than one coupon, we have a known issue with this, Change couponName filter to coupons and update documentation #4312
  8. Use the points redemption panel to redeem some points.
  9. Remove the coupon that was added as a result of redeeming points.
  10. Ensure no snackbar notice shows.
  11. In the WooCommerce Points and Rewards file: assets/js/filters.js change snackbarNoticeVisibility to snackbarNotices and run npm run build.
  12. Add a coupon to the cart again and ensure a deprecation notice is shown in the console.

Changelog

Deprecate snackbarNotices filter in favour of snackbarNoticeVisibility to allow extensions to hide snackbar notices in the Cart and Checkout blocks.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2021

Size Change: +117 B (0%)

Total Size: 965 kB

Filename Size Change
build/blocks-checkout.js 20.2 kB +44 B (0%)
build/cart-frontend.js 78.4 kB +39 B (0%)
build/checkout-frontend.js 82.6 kB +34 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 8.28 kB
build/active-filters.js 7.84 kB
build/all-products-frontend.js 23 kB
build/all-products.js 37.3 kB
build/all-reviews.js 9.61 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.57 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 1.82 kB
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 334 B
build/atomic-block-components/add-to-cart-frontend.js 8.65 kB
build/atomic-block-components/add-to-cart.js 7.72 kB
build/atomic-block-components/button-frontend.js 1.74 kB
build/atomic-block-components/button.js 874 B
build/atomic-block-components/category-list-frontend.js 469 B
build/atomic-block-components/category-list.js 477 B
build/atomic-block-components/image-frontend.js 1.87 kB
build/atomic-block-components/image.js 1.34 kB
build/atomic-block-components/price-frontend.js 2.09 kB
build/atomic-block-components/price.js 2.11 kB
build/atomic-block-components/rating-frontend.js 562 B
build/atomic-block-components/rating.js 566 B
build/atomic-block-components/sale-badge-frontend.js 856 B
build/atomic-block-components/sale-badge.js 867 B
build/atomic-block-components/sku-frontend.js 388 B
build/atomic-block-components/sku.js 392 B
build/atomic-block-components/stock-indicator-frontend.js 610 B
build/atomic-block-components/stock-indicator.js 611 B
build/atomic-block-components/summary-frontend.js 906 B
build/atomic-block-components/summary.js 911 B
build/atomic-block-components/tag-list-frontend.js 465 B
build/atomic-block-components/tag-list.js 471 B
build/atomic-block-components/title-frontend.js 1.43 kB
build/atomic-block-components/title.js 1.28 kB
build/attribute-filter-frontend.js 18 kB
build/attribute-filter.js 11.9 kB
build/cart.js 45.9 kB
build/checkout.js 48.2 kB
build/featured-category.js 7.39 kB
build/featured-product.js 9.55 kB
build/handpicked-products.js 6.56 kB
build/price-filter-frontend.js 14.3 kB
build/price-filter.js 9.57 kB
build/price-format.js 1.38 kB
build/product-best-sellers.js 6.73 kB
build/product-categories.js 3.38 kB
build/product-category.js 7.59 kB
build/product-new.js 6.89 kB
build/product-on-sale.js 7.23 kB
build/product-search.js 2.68 kB
build/product-tag.js 6.69 kB
build/product-top-rated.js 6.85 kB
build/products-by-attribute.js 7.82 kB
build/reviews-by-category.js 11.6 kB
build/reviews-by-product.js 13.1 kB
build/reviews-frontend.js 9.22 kB
build/single-product-frontend.js 25.7 kB
build/single-product.js 9.87 kB
build/vendors--atomic-block-components/price-frontend.js 5.71 kB
build/wc-blocks-data.js 10.9 kB
build/wc-blocks-editor-style-rtl.css 14.9 kB
build/wc-blocks-editor-style.css 14.9 kB
build/wc-blocks-google-analytics.js 1.99 kB
build/wc-blocks-middleware.js 1.48 kB
build/wc-blocks-registry.js 2.75 kB
build/wc-blocks-shared-context.js 1.54 kB
build/wc-blocks-shared-hocs.js 1.75 kB
build/wc-blocks-style-rtl.css 19.3 kB
build/wc-blocks-style.css 19.3 kB
build/wc-blocks-vendors-style-rtl.css 1.05 kB
build/wc-blocks-vendors-style.css 1.05 kB
build/wc-blocks-vendors.js 239 kB
build/wc-blocks.js 3.51 kB
build/wc-payment-method-bacs.js 812 B
build/wc-payment-method-cheque.js 807 B
build/wc-payment-method-cod.js 903 B
build/wc-payment-method-paypal.js 844 B
build/wc-payment-method-stripe.js 12.3 kB
build/wc-settings.js 2.93 kB

compressed-size-action

@opr opr added category: extensibility Work involving adding or updating extensibility. Useful to combine with other scopes impacted. status: needs review PR that needs review ◼️ block: cart Issues related to the cart block. ◼️ block: checkout Issues related to the checkout block labels Jul 1, 2021
@opr opr self-assigned this Jul 1, 2021
@opr opr marked this pull request as ready for review Jul 1, 2021
@opr opr requested a review from a team as a code owner Jul 1, 2021
@opr opr requested review from mikejolley and removed request for a team Jul 1, 2021
Copy link
Member

@mikejolley mikejolley left a comment

This appears to be working as described :) Approving. Rebase is needed.

Was the "multiple coupon" issue you mentioned the block error boundary when removing a coupon when points are applied?

I noticed a notice which is unrelated to this change but something in points. Are you aware or should I log a new issue?

Notice: Array to string conversion in /plugins/woocommerce-points-and-rewards/includes/class-wc-points-rewards-extend-store-endpoint.php on line 86

@opr opr force-pushed the update/snackbar-filter branch from 00c1ca4 to 31f7d6f Compare Jul 12, 2021
@opr
Copy link
Contributor Author

opr commented Jul 12, 2021

This appears to be working as described :) Approving. Rebase is needed.

Cheers, Mike. Done!

Was the "multiple coupon" issue you mentioned the block error boundary when removing a coupon when points are applied?

Yep, this is fixed now following the rebase.

I noticed a notice which is unrelated to this change but something in points. Are you aware or should I log a new issue?

Notice: Array to string conversion in /plugins/woocommerce-points-and-rewards/includes/class-wc-points-rewards-extend-store-endpoint.php on line 86

Strange, I'm not getting this notice, this line is an array of tags that should be allowed in strip_tags, but I think I can change this to a string, which version of PHP are you using?

@mikejolley
Copy link
Member

mikejolley commented Jul 12, 2021

Strange, I'm not getting this notice, this line is an array of tags that should be allowed in strip_tags, but I think I can change this to a string, which version of PHP are you using?

7.3.5

@opr
Copy link
Contributor Author

opr commented Jul 12, 2021

Strange, I'm not getting this notice, this line is an array of tags that should be allowed in strip_tags, but I think I can change this to a string, which version of PHP are you using?

7.3.5

Makes sense then since this change to strip_tags was made in 7.4.0 - I'll change it to a string in P&R 👍🏼

@opr opr merged commit 0be666f into trunk Jul 26, 2021
18 checks passed
@opr opr deleted the update/snackbar-filter branch Jul 26, 2021
@opr opr restored the update/snackbar-filter branch Jul 26, 2021
@Aljullu Aljullu added this to the 5.6.0 milestone Aug 2, 2021
@ralucaStan ralucaStan deleted the update/snackbar-filter branch Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
◼️ block: cart Issues related to the cart block. ◼️ block: checkout Issues related to the checkout block category: extensibility Work involving adding or updating extensibility. Useful to combine with other scopes impacted. status: needs review PR that needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants