• Resolved rupalu

    (@rupalu)


    Hi Support team,

    Recently we have one error on our WordPress dashboard. Below is the full error:-

    “Apple Pay domain verification failed. Please check the log to see the issue. (Logging must be enabled to see recorded logs)”

    When I clicked on the logs below error is display:-

    2021-09-14T13:59:30+00:00 CRITICAL syntax error, unexpected ‘$order_total’ (T_VARIABLE) in /home1/officec1/public_html/wp-content/themes/flatsome/functions.php on line 65

    2021-09-14T13:59:31+00:00 CRITICAL syntax error, unexpected ‘$order_total’ (T_VARIABLE) in /home1/officec1/public_html/wp-content/themes/flatsome/functions.php on line 65

    When I go to this file and check the code on 65 lines, below codes are there:-

    add_action(‘wp_head’, ‘bks_head_social_tracking_code’);

    function bks_head_social_tracking_code() {
    // Check if its thank you page.
    if(is_wc_endpoint_url( ‘order-received’ )) {
    // Get order object.
    $order = wc_get_order(get_query_var(‘order-received’));

    // Get total.
    $order_total = $order->get_total();

    // Prepare.
    $output = ”
    <script>
    gtag(‘event’, ‘conversion’, {
    ‘send_to’: ‘AW-1043540229/3GEKCIvXwM0CEIXSzPED’,
    ‘value’: “. $order_total .”, // Use dynamically.
    ‘currency’: ‘USD’,
    ‘transaction_id’: ”
    });

    </script>”;
    // echo.
    echo $output;
    }
    }

    Can you please help me with that? Let me know if you need any other information from my side!

    Thank you!
    Rupal

    • This topic was modified 3 years, 2 months ago by rupalu. Reason: Highlight the code

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • That code is looking for a query string from the URL, for example yourwebsite.com/order-recieved/?order-received=orderID

    but there is no fallback if the query string doesn’t exist.

    so to fix it by bypassing the error, wrap it in a IF statement

    if($order):
    
    // Get total.
    $order_total = $order->get_total();
    
    // Prepare.
    $output = ”
    <script>
    gtag(‘event’, ‘conversion’, {
    ‘send_to’: ‘AW-1043540229/3GEKCIvXwM0CEIXSzPED’,
    ‘value’: “. $order_total .”, // Use dynamically.
    ‘currency’: ‘USD’,
    ‘transaction_id’: ”
    });
    
    </script>”;
    // echo.
    echo $output;
    
    endif;

    P.S. I don’t think this will fix your domain verification issue, this functionality is basically for pushing a conversion to gtag.

    Thread Starter rupalu

    (@rupalu)

    Hello Stefan,

    Thank you for your reply! should I replace my code with this new one? OR Do I need to paste this new code below /above my code?

    Thank you!
    Rupal

    I just added 2 lines:

    if($order):

    and

    endif;

    so just wrap the existing code with it starting from // Get total.

    Here is the full code:

    add_action(‘wp_head’, ‘bks_head_social_tracking_code’);
    
    function bks_head_social_tracking_code() {
        // Check if its thank you page.
        if(is_wc_endpoint_url( ‘order-received’ )) {
            // Get order object.
            $order = wc_get_order(get_query_var(‘order-received’));
    
            if($order): // added
                // Get total.
                $order_total = $order->get_total();
    
                // Prepare.
                $output = ”
                <script>
                    gtag(‘event’, ‘conversion’, {
                    ‘send_to’: ‘AW-1043540229/3GEKCIvXwM0CEIXSzPED’,
                    ‘value’: “. $order_total .”, // Use dynamically.
                    ‘currency’: ‘USD’,
                    ‘transaction_id’: ”
                    });
                </script>”;
                // echo.
                echo $output;
            endif; // added
        }
    }
    Thread Starter rupalu

    (@rupalu)

    Hello

    I’m not sure it’s showing me an error

    2021-09-14T13:59:30+00:00 CRITICAL syntax error, unexpected ‘$order_total’ (T_VARIABLE) in /home1/officec1/public_html/wp-content/themes/flatsome/functions.php on line 65

    2021-09-14T13:59:31+00:00 CRITICAL syntax error, unexpected ‘$order_total’ (T_VARIABLE) in /home1/officec1/public_html/wp-content/themes/flatsome/functions.php on line 65

    Hi @rupalu,

    I suspect there are a few different things happening here. The Apple Pay verification notice will be referring to debug logging for the payment gateway specifically. You can typically enable that by going to WooCommerce > Settings > Payments and clicking on the gateway you’re working with. There is typically a way to enable logging here.

    The next time you see a message about Apple Pay domain verification failing it should add a log for that date with the payment gateway’s name in it. You can find them by going to WooCommerce > Status > Logs.

    Hopefully, the log will give some clues as to why Apple Pay verification is failing.

    Let us know what you find out.

    Hi @rupalu

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Apple Pay domain verification failed’ is closed to new replies.