• Resolved Rok

    (@pletershek)


    Looks like that after the PHP was updated (if I understand other support topics correctly) the snippet is no longer working, but I need it to work in order to have wocommerce bills properly displayed.

    I use the snippet with PDF Invoices & Packing Slips for WooCommerce plugin.

    I get this error:

    2025-02-21T13:18:58+00:00Kriti?no Unsupported operand types: float + string (/home/xxxx/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(584) : eval()’d code:29)

    Any idea how to fix it?

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

Viewing 1 replies (of 1 total)
  • Plugin Author Atif Riaz

    (@lightbulbman)

    Hello @pletershek

    Thanks for reaching out and sorry your facing problems. It looks like the error is caused by a type mismatch—specifically, a float (decimal number) and a string being added together. This may have started happening after your PHP update because newer versions of PHP are stricter about type handling.

    To fix this, you’ll want to ensure that both values being added are numbers. Try updating your snippet like this:

    $variable1 = floatval($variable1); // Ensure it's a number
    $variable2 = floatval($variable2); // Ensure it's a number

    $result = $variable1 + $variable2; // Now both are floats, preventing the error

    If you’re unsure which variables are causing the issue, you can try debugging using WordPress debugging or a plugin like variable inspector.

    To use WordPress debugging this needs to be enabled, by setting (WP_DEBUG in wp-config.php) to true.

    error_log( 'Variable 1: ' . gettype($variable1) . ' - ' . print_r($variable1, true) );
    error_log( 'Variable 2: ' . gettype($variable2) . ' - ' . print_r($variable2, true) )

    Then check your error log (wp-content/debug.log) to see their types and values.

    Hope this helps

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.