Skip Navigation

[Resolved] Error after add Shortcode for Calculating Number

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.

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

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 10 months, 2 weeks ago.

Assisted by: Waqar.

Author
Posts
#2627943

Hello, I trying add shortcode below to calculate my type field.

add_shortcode('wpv-calculate', 'calculate_shortcode');
function calculate_shortcode($atts,$content=null) {
$content = wpv_do_shortcode($content);
$content = eval("return $content;");
return round($content);
}

and add this for formula.

<p>Harga Sewa Tahunan: <span class="harga-coret">Rp [types field='harga-sewa-tahunan'][/types]</span><span class="diskon">[wpv-calculate][types field='diskon-bayar-tahunan']*100[/wpv-calculate]% OFF</span>Rp [wpv-calculate][types field='harga-sewa-tahunan']-([types field='harga-sewa-tahunan']*[types field='diskon-bayar-tahunan'])[/wpv-calculate],- / tahun</p>

The result can show, but when i wanna edit my single template, it shown error:
[28-Jul-2023 05:52:01 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/gran2379/public_html/wp-includes/formatting.php on line 2416
[28-Jul-2023 05:52:03 UTC] PHP Deprecated: ctype_digit(): Argument of type WP_Post will be interpreted as string in the future in /home/gran2379/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/inc/autoloaded/field/group/factory.php on line 134
[28-Jul-2023 05:52:03 UTC] PHP Parse error: syntax error, unexpected token "*", expecting ";" in /home/gran2379/public_html/wp-content/themes/grandhika-property/functions.php(42) : eval()'d code on line 1
[28-Jul-2023 05:52:45 UTC] PHP Deprecated: Automatic conversion of false to array is deprecated in /home/gran2379/public_html/wp-content/plugins/ele-custom-skin/includes/enqueue-styles.php on line 22
[28-Jul-2023 05:52:48 UTC] PHP Deprecated: ctype_digit(): Argument of type WP_Post will be interpreted as string in the future in /home/gran2379/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/inc/autoloaded/field/group/factory.php on line 134
[28-Jul-2023 05:52:48 UTC] PHP Parse error: syntax error, unexpected token "*", expecting ";" in /home/gran2379/public_html/wp-content/themes/grandhika-property/functions.php(42) : eval()'d code on line 1
[28-Jul-2023 05:53:11 UTC] PHP Deprecated: ctype_digit(): Argument of type WP_Post will be interpreted as string in the future in /home/gran2379/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/inc/autoloaded/field/group/factory.php on line 134
[28-Jul-2023 05:53:11 UTC] PHP Deprecated: ctype_digit(): Argument of type WP_Post will be interpreted as string in the future in /home/gran2379/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/inc/autoloaded/field/group/factory.php on line 134
[28-Jul-2023 05:53:12 UTC] PHP Deprecated: ctype_digit(): Argument of type WP_Post will be interpreted as string in the future in /home/gran2379/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/inc/autoloaded/field/group/factory.php on line 134
[28-Jul-2023 05:53:12 UTC] PHP Deprecated: ctype_digit(): Argument of type WP_Post will be interpreted as string in the future in /home/gran2379/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/inc/autoloaded/field/group/factory.php on line 134

Any suggestion for this issue, please?

#2628681

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

An error like this can be thrown if the value of any of the participating custom fields is either 'empty' or non-numeric.

Can you please make sure that in the content template's 'View with' field at the top, the preview post that is selected, has valid numeric values for all those custom fields?

I hope this helps and let me know how it goes.

regards,
Waqar

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.