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

Improve ViewContent event handling #2691

Open
sukafia opened this issue Feb 16, 2024 · 0 comments
Open

Improve ViewContent event handling #2691

sukafia opened this issue Feb 16, 2024 · 0 comments
Labels
type: enhancement The issue is a request for an enhancement.

Comments

@sukafia
Copy link

sukafia commented Feb 16, 2024

✍️ Describe the bug

When Redirect to the cart page after successful addition is enabled in WooCommerce > Settings > Products, the ViewContent events aren't triggered across the site.

According to the explanation by @message-dimke - p1707212005472779/1706873190.731819-slack-CK365S85V:

No events are lost. This is just a behavior that confuses our users. We look at the WC setting for woocommerce_cart_redirect_after_add and decide whether to fire the event immediately or keep it and fire the next page render. This was made not to lose events because of the redirect and to render them the next page load (events get stored into a buffer and output on the next page). I can see this as confusing since not all events have to be delayed. We can add a filter not to delay all the events but only the affected ones.

If the user opens a product page and WC settings have woocommerce_cart_redirect_after_add set to on , we do not shoot ViewContent event but store it into a buffer. We do this because we render events at each page footer. In case of a redirect, the page footer won't be rendered, and events get lost. So, the user opens the page and the event goes into a buffer. The user adds the product, and the buffer gets rendered at the cart page (ViewContent for the product will fire at the cart page). If the user refreshes the product page, ViewContent will fire at the product page, and since we are still at that page, the new ViewContent will go into the buffer.

Adding a filter on events, which require the delay, will help here to render ViewContent when the product page loads and deffer other events which may get lost in case of the redirect setting.

While the expectation is that no events are lost, there's a report of this leading to loss of events. Opening this issue so we can double-check the ViewContent event handling, particularly as the event is triggered on v3.0.33 when Redirect to the cart page after successful addition is enabled.

@sukafia sukafia added the type: enhancement The issue is a request for an enhancement. label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement The issue is a request for an enhancement.
1 participant