I wrote the following piece of code and the 2nd nested IF statement is being ignored. If I switch the order of them the same thing happens. I've tried an elseif statement and that doesn't seem to work either.
Any ideas why? I'm guessing it's a pretty noob question, so please skool me :)
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '169969516705075');
fbq('track', "PageView");
<?php
if($_GET['order_total'] && $_GET['product_id']) {
$order_total = $_GET['order_total'];
$product_id = $_GET['product_id'];
if($product_id === 8421 || 1925 || 1932) {
$output = "fbq('track', 'Purchase', {value: '$order_total', currency: 'USD'});";
echo $output;
}
if($product_id === 1647) {
$free_output = "fbq('track', 'CompleteRegistration');";
echo $free_output;
}
}
if (is_cart()) {
$output = "fbq('track', 'AddToCart');";
echo $output;
}
if(is_checkout()) {
$output = "fbq('track', 'InitiateCheckout');";
echo $output;
}
if (is_wc_endpoint_url( 'order-received' )) {
$output = "fbq('track', 'Purchase', {value: '$order_total', currency: 'USD'});";
echo $output;
}
?></script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=169969516705075&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->