smarty regex_replace no longer working in PHP8.030 (Smarty 3?)

in PDF manager I was using a regex_replace to remove the currency symbol (which varies) and check for non-zero shipping costs to print/not print some terms.

{if $fields.annual_shipping_cost_c|regex_replace:"/^./":"" gt 0} print this {/if}

After the upgrade to PHP 8.0.30 this no longer works and always returns true even when the value is $0.00 or empty.

What is the correct way to check for a non zero currency value in smarty?

All the suggestions I am finding online explicitly remove a "$" (or other individual currency symbol) but the currency can be one of four or five different ones and I would much rather have a cleaner solution that checking for each of the allowed currencies.

When tested

{$fields.annual_shipping_cost_c|regex_replace:"/^./":""}

or 

{$fields.annual_shipping_cost_c|regex_replace:"/^[^\d]/":""}

Prints a 

Thanks,
Francesca

Parents Reply Children
  • The values passed in are things like $10.00 or ¥1500.00 

    The idea was to remove the symbol and check the value to see if it was gt 0 and it worked fine until the PHP upgrade in preparation for 13->14 upgrade.

    I tried to do a regexp with the specific currency symbols we use: $, ¥, €, £ but when I save the HTML everything except $ gets replaced with HTML encoding and messes everything up.

    I manage all my PDFManager code in the HTML format (not the WYSIWYG) because i have a customization to use CSS to format the final document (I struggled too hard for too long to get the OOTHB to render properly), but when I save the HTML it sometimes, not always, it converts random things, including quotes,  into HTML encoding, which drives me nuts!

    In the end, after a three hour struggle with every attempt under the sun and every piece of documentation I could find for smarty, I added a calculated Float field that copies the amount and use that to check gt 0 avoiding quotes and symbols.

    Because I'm on premise I can easily copy the amount to that new column for every record with a quick update statement from the back-end.

    I can tell you I am not looking forward to finding an alternative for this, since it doesn't look like DocMerge will fit our needs and PDF manager is becoming less and less reliable.