-
Notifications
You must be signed in to change notification settings - Fork 219
Apply filter woocommerce_loop_add_to_cart_link is called with 2 params instead of 3 #8020
Apply filter woocommerce_loop_add_to_cart_link is called with 2 params instead of 3 #8020
Comments
Thanks @jorgemd24 for raising this issue. I followed the steps you provided, but I can't seem to reproduce the issue. On the other hand, from the links you provided, it looks like there is some inconsistency in the number of parameters provided to the filter. @sunyatasattva, could you take a look at the issue as it's related to Products block, please? |
Thank you @kmanijak for tagging me. This sounds related to the Products block. If you and @jorgemd24 could provide reliable reproduction steps, then it'd be great if you'd add it to the woocommerce/woocommerce#42616 Epic 🙏 |
Sounds good @sunyatasattva! @jorgemd24, could I ask you for more details around testing steps? I followed those steps:
but that didn't trigger the error you mentioned:
This may be just formatting issue, but I spotted the testing steps are missing steps 3. and 4. Maybe they misplaced while raising an issue :) |
Hello @jorgemd24 , we tried to reproduce this issue but with no luck. Could you guide us further on reproducing it? Otherwise I'm going to need to close the issue. |
I wasn't able to reproduce the fatal either, but I think it makes sense to align the number of parameters of the
As a sidenote, GL&A is declaring the |
Sorry, not sure why I missed these comments! Here it is a video reproducing the error: Screen.Capture.on.2023-02-14.at.15-52-45.mp4And then in the logs, I see:
Plugins: WooCommerce 7.3.0 Thanks for fixing this! |
Describe the bug
While we were testing Google Listings & Ads and the Products Block (Beta) a fatal error was displayed, the issue is caused because the filter
woocommerce_loop_add_to_cart_link
is applied with two parameters instead of three.See how WooCommerce applies the filter: https://github.com/woocommerce/woocommerce/blob/7.2.2/plugins/woocommerce/templates/loop/add-to-cart.php#L35
See WooCommerce Blocks:
woocommerce-blocks/src/BlockTypes/ProductButton.php
Line 111 in ffe341c
See how GL&A use the filter: https://github.com/woocommerce/google-listings-and-ads/blob/d4b2dfd8751ebadb096f2a974de0202d08c048d0/src/Google/GlobalSiteTag.php#L153
Fatal error:
Uncaught ArgumentCountError: Too few arguments to function Automattic\WooCommerce\GoogleListingsAndAds\Google\GlobalSiteTag::Automattic\WooCommerce\GoogleListingsAndAds\Google\{closure}(), 2 passed in /var/www/html/wp-includes/class-wp-hook.php on line 308 and exactly 3 expected
The filter should be aligned with how WooCommerce applies the filter.
To reproduce
Steps to reproduce the behavior:
Uncaught ArgumentCountError: Too few arguments to function Automattic\WooCommerce\GoogleListingsAndAds\Google\GlobalSiteTag::Automattic\WooCommerce\GoogleListingsAndAds\Google\{closure}(), 2 passed in /var/www/html/wp-includes/class-wp-hook.php on line 308 and exactly 3 expected
Expected behavior
Not fatal errors.
The text was updated successfully, but these errors were encountered: