Skip Navigation

[Resolved] Non-numeric value encountered when passing numeric value

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 5 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1221743

My calculation function:

/**
 * Running balance shortcode
 */
add_shortcode( 'balance', function( $atts ){
 
    // Initialise running total
    static $running = 0;
 
    // Set default values of zero for credit and debit
    $atts = shortcode_atts( array(
        'credit'    =>   0,
        'debit'     =>   0 
        ),
        $atts );
 
    // Update running total
    $running = $running + ( $atts['credit'] - $atts['debit'] );
 
    return $running;
});

My view code:

[balance credit="[types field='txcr' output='raw'][/types]" debit="[types field='txdr' output='raw'][/types]"]

View output:

Warning: A non-numeric value encountered in /home/atomic2co/public_html/jes/wp-content/plugins/atomic/atomic.php on line 38

BUT the view is correct.

I am collecting only numeric values (with validation) on fields txcr and txdr. Tried the shortcode with raw and without.

Any ideas?

#1221806

Hi, can you answer a few questions?
1. It looks like you have placed the balance shortcode in the loop of a View. Does the warning appear for every iteration of the loop, or only for certain items in the loop? Use the limit and offset attributes if necessary to narrow it down and let me know if there is a specific combination of values causing the problem.
2. Is this Atomic plugin where you keep your custom shortcode code? If possible, can you move the code into a Toolset custom code snippet to rule out timing issues? You can create one in Toolset > Settings > Custom Code.
3. I see you are using an alpha version of Oxygen. Can you temporarily switch to the last public release to see if the problem is resolved?