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