IF语句忽略第二个嵌套的IF语句

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 --> 

The other answers address the issue with your core problem - which is that PHP does not do what you think it does with this statement:

if ($product_id == 8421 || 1925 || 1932) {...

This would ALWAYS evaluate to TRUE, because you are saying:

if $product_id == 8421 (which does a comparison as intended)
OR
1925 (which is not a comparison, but rather is a non-zero integer, which is "truthy")
OR
1932 (which is another non-zero integer, which is also "truthy")
then...

So, as a matter of coding style whenever there's more than a few values that I'm checking for, I like to use in_array:

if ( in_array( $product_id, array( 1925, 1932, 8421 ) ) {...

However, there's more that you're doing I'd like to help you with as well.

WordPress best practices would not have you put that code in the top of your template file, but rather in a functions file.

So, take that same code, but instead, alter it like so and place it in your theme's functions.php file.

Note that it will get CALLED based on the wp_head hook (which I've also included below), which keeps your template file free from logic / functionality:

// First, hook into the "wp_head" so that this is output in the head 
add_action('wp_head','facebook_output');

<?php  
// This function is called by the 'wp_head' action above
function facebook_output() { 
    // Close the PHP tag to output some script simply
    ?>
    <!-- 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  // Re-open the PHP tag so we can do our PHP logic
    if($_GET['order_total'] && $_GET['product_id']) {

        $order_total = $_GET['order_total'];
        $product_id = $_GET['product_id'];

        // For maintainability and readability, put the array(s) of values into variables
        $products_purchase = array(8421, 1925, 1932);
        $products_registration = array(1647);

        // Check if the product_id is in the array
        if( in_array( $product_id, $products_purchase ) ) {
            // No need to assign to $output and then echo - just echo
            echo "fbq('track', 'Purchase', {value: '$order_total', currency: 'USD'});";
        }

        if( in_array( $product_id, $products_registration ) ) {
            echo "fbq('track', 'CompleteRegistration');";
        }  
    }

    if ( is_cart() ) {
        echo "fbq('track', 'AddToCart');";
    }

    if( is_checkout() ) {
        echo "fbq('track', 'InitiateCheckout');";
    }

    if ( is_wc_endpoint_url( 'order-received' ) ) {
        echo "fbq('track', 'Purchase', {value: '$order_total', currency: 'USD'});";
    }
    // Close the PHP tag again to output the straight script
    ?>
    </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 --> 
<?php // And finally re-open the PHP tag
}

if($product_id === 8421 || $product_id ===1925 || $product_id ===1932)

is the way to do it