oc-mall-plugin
oc-mall-plugin copied to clipboard
addToCart data layer not fired if Redirect to Cart is enabled
Hi,
if I set the Redirect to cart to true in Base settings, then Add to cart data layer is not fired and data sent to Google Analytics.
https://github.com/OFFLINE-GmbH/oc-mall-plugin/blob/fc72aac3e50d109d13750d14c2f5873ac246d82b/components/product/cart.htm#L2
Edit: Looking deeper I guess the problem is that layer data can't be sent back to frontend and then redirected from the component:
https://github.com/OFFLINE-GmbH/oc-mall-plugin/blob/fc72aac3e50d109d13750d14c2f5873ac246d82b/components/Product.php#L559
I guess this "Redirect to cart" should be rewriten to only work in frontend to be able to send data layer. Some sort of new bolean in the data response? Like redirectToCart: true
and then capture this in the frontend with javascript and redirect from here:
https://github.com/OFFLINE-GmbH/oc-mall-plugin/blob/f07371d533bf07c6d3a022be307a8d7fb38832f0/components/enhancedecommerceanalytics/default.htm#L6
Is this logical? It's Friday and I'm burnt :D
Regard, Darjan