I’m working with Magento 1.9 and have a PHP include file that I’m using to display facebook pixel code based on the page type. IE: cart, checkout, product details, catalog, cms…
I’m looking at the page request module, controller, action, etc. However, I can’t seem to find a way to determine if they’re at /checkout/success/ or not. If I try to look at the request URI it returns /checkout/cart/
Is there a class property or method that I can use to determine that the user is in fact on the order success page?
3
Answers
I ended up working through it by looking at the current quote ID (which should be null), the current controller, and the last order ID.
After a purchase has been completed, the current quote is cleared. However, since we're still in the cart, then that means the purchase has been completed. I check the last order id just to be sure there was a purchase.
You can use:
You may also make use of the layout handle
checkout_onepage_success
.Reference this in a layout of your custom module and in the referenced template file include the facebook pixel code.
And, in
example/fb/conversion.phtml
, do the needful processing and include the facebook pixel code.