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