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

Reworking how pixel events on redirect to cart are handled. #2671

Merged
merged 6 commits into from
Dec 27, 2023

Conversation

message-dimke
Copy link
Contributor

@message-dimke message-dimke commented Dec 10, 2023

This one came from Slack channel.

When using Stripe plugin from one of 3rd party devs there was an issue with Facebook pixel events duplicated since that extension was cloning cart to perform some calculations which resulted in triggering cart hooks on a cloned object doubling the events.

After the fix from above was merged in another thing happened. The code added to prevent events from firing on cloned carts was failing when redirect to cart after product added setting is on. The reason to that is the previous fix was operating cart item key which was not always present when the code was called outside woocomerce_add_to_cart hook.

Current PR reworks the mechanism how events are rendered on redirect to cart after product added to make things work w/o any issues.

Detailed test instructions:

  1. Install Meta Pixel Helper Chrom extension. https://chromewebstore.google.com/detail/meta-pixel-helper/fdgfkebogiimcoedlicjlajpkdmockpc?pli=1
  2. Install AJAX Add to cart button extension at will. https://wordpress.org/plugins/woo-ajax-add-to-cart/
  3. Open WooCommerce Settings and check some boxes =)
WooCommerce_settings_‹_WordPress_Facebook_—_WordPress
  1. Go to Shop page
Cursor_and_Shop_–_WordPress_Facebook
  1. Add some products into cart. In case of using AJAX extension page must not reload but Meta Pixel Helper must show Add to cart event. If w/o AJAX the page must reload and add the event.
Cursor_and_Shop_–_WordPress_Facebook-2
  1. Add some more products (multiple at once).
Cursor_and_Logo_Collection_–_WordPress_Facebook Cursor_and_Logo_Collection_–_WordPress_Facebook-2
  1. Observe Meta Pixel Helper chrome extension looking for AddToCart events.

  2. Go to WooCommerce Settings again and update them as on the screen below.

WooCommerce_settings_‹_WordPress_Facebook_—_WordPress
  1. Go back to the Shop page and Add something to the cart. The page must redirect to the cart page adding the product in and rendering the Pixel event.
Cart_–_WordPress_Facebook
  1. And add some more. The page also must redirect to the cart page with Pixel events rendered.
Cursor_and_Cart_–_WordPress_Facebook-2
  1. When the cart page loads, observe the Meta Pixel Helper chrome extension. You must see a bunch of AddToCart events there.

Additional details:

Changelog entry

Fix - Facebook Pixel events missing on redirect to cart.

…me broken after one of the fixes was introduced to fix cloned carts issue.
@message-dimke message-dimke self-assigned this Dec 10, 2023
@github-actions github-actions bot added changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug. labels Dec 10, 2023
@message-dimke message-dimke requested a review from a team December 10, 2023 22:06
@message-dimke message-dimke marked this pull request as ready for review December 10, 2023 22:39
includes/fbutils.php Outdated Show resolved Hide resolved
@rawdreeg rawdreeg requested a review from a team December 11, 2023 11:16
includes/fbutils.php Outdated Show resolved Hide resolved
includes/fbutils.php Outdated Show resolved Hide resolved
includes/fbutils.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@budzanowski budzanowski left a comment

Choose a reason for hiding this comment

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

Thank you for the changes!

:shipit:

@message-dimke message-dimke merged commit c5f34b7 into develop Dec 27, 2023
6 checks passed
@message-dimke message-dimke deleted the fix/missing-pixel-events-on-redirect branch December 27, 2023 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants