Skip to content

Conversation

@helgatheviking
Copy link
Contributor

@helgatheviking helgatheviking commented Jun 28, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

Echo out filtered product name instead of filtering it again

Closes #38744.

How to test the changes in this Pull Request:

Follow the repro steps in the original issue.

1- Add this snippet

add_filter( 'woocommerce_cart_item_name', function( $cart_item_name ) {
   return $cart_item_name . ' - test';
} );

2- Add an item to the cart.
3- Go to cart.
4- Without the patch -test should appear twice. With the patch, -test should appear only once.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement

Message

Eliminate woocommerce_cart_item_name filter running twice on cart.php template

Comment

@github-actions github-actions bot added plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution labels Jun 28, 2023
@woocommercebot woocommercebot requested review from a team and jorgeatorres and removed request for a team June 28, 2023 14:10
@github-actions
Copy link
Contributor

Hi ,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

@rrennick rrennick left a comment

Choose a reason for hiding this comment

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

@helgatheviking Thanks for submitting this. I apologize for not catching that on the original PR.

@barryhughes
Copy link
Member

✍🏼 Not something introduced by this PR, and so doesn't necessarily need to be changed here, but I think the @since tag for this hook should be 2.1.0, not 7.8.0 (we're documenting when the hook was introduced, not when the hook documentation was added).

@rrennick
Copy link
Contributor

@helgatheviking Thanks for the help with this. I made the last change to the PR ecause we are running a tight timeline to get it included in 7.9.0.

@rrennick rrennick requested a review from barryhughes June 30, 2023 18:45
Copy link
Member

@barryhughes barryhughes left a comment

Choose a reason for hiding this comment

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

Nice: if we can get the required checks passing, it should be good to merge.

@jorgeatorres jorgeatorres requested a review from vedanshujain July 3, 2023 23:16
@jorgeatorres
Copy link
Member

Hi @helgatheviking,

Thanks for your contribution 💯. I've taken the liberty of fixing the version in the filter docblock (as suggested by @barryhughes) and added wp_strip_all_tags() around $product_name when it is used in an attribute. Otherwise, things looked good to me, so I'm approving.

On account of those changes, though, I'm asking for a review from @vedanshujain, so he can give the final approval.

@helgatheviking
Copy link
Contributor Author

Hey gang, thanks for carrying this across the finish line!

@jorgeatorres jorgeatorres force-pushed the issues/38744-duplicate-filter branch from b8d9571 to 294f59f Compare July 4, 2023 01:26
@Konamiman Konamiman self-requested a review July 4, 2023 02:34
@Konamiman Konamiman requested a review from rrennick July 4, 2023 02:38
@psealock psealock merged commit 9d5c90d into woocommerce:trunk Jul 4, 2023
@github-actions github-actions bot added this to the 8.0.0 milestone Jul 4, 2023
@psealock psealock modified the milestones: 8.0.0, 7.9.0 Jul 4, 2023
github-actions bot pushed a commit that referenced this pull request Jul 4, 2023
…8999)

* Send $product_name through woocommerce_cart_item_name filter only once. Closes #38744.

* Replace additional product name filters, with already filtered variable.

* add additional params to docblock of woocommerce_cart_item_name

* bump template version to 7.9.0

* revert cart_item_name filter change in #37830

* Minor fixes

* Bump template version

---------

Co-authored-by: Ron Rennick <[email protected]>
Co-authored-by: Jorge A. Torres <[email protected]>
@helgatheviking helgatheviking deleted the issues/38744-duplicate-filter branch July 4, 2023 04:02
psealock pushed a commit that referenced this pull request Jul 4, 2023
* Send $product_name through woocommerce_cart_item_name filter once (#38999)

* Send $product_name through woocommerce_cart_item_name filter only once. Closes #38744.

* Replace additional product name filters, with already filtered variable.

* add additional params to docblock of woocommerce_cart_item_name

* bump template version to 7.9.0

* revert cart_item_name filter change in #37830

* Minor fixes

* Bump template version

---------

Co-authored-by: Ron Rennick <[email protected]>
Co-authored-by: Jorge A. Torres <[email protected]>

* Prep for cherry pick 38999

---------

Co-authored-by: Kathy <[email protected]>
Co-authored-by: Ron Rennick <[email protected]>
Co-authored-by: Jorge A. Torres <[email protected]>
Co-authored-by: WooCommerce Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

woocommerce_cart_item_name filter is applied twice

6 participants