[Bug][Code attached] Customtextfield - Additional amount despite empty field

Started by Anna_Bolika, April 26, 2021, 19:56:58 PM

Previous topic - Next topic

Anna_Bolika

Hi all

In an almost current VM (3.8.8 10472), the plugin 'customtext' was faulty. With additional text, the flat rate was added to the price, but not subtracted again when the field was cleared.
In plugins/vmcustom/textinput/textinput.php - line ~201
I've had to wrap this block

            if ($customfield->custom_price_by_letter == 1) {
                $modificatorSum += $charCount * $customfield->customfield_price;
            } else {
                $modificatorSum += $customfield->customfield_price;
            }


with a additional condition so that char count comes in play:

        if($charCount > 0) {
            if ($customfield->custom_price_by_letter == 1) {
                $modificatorSum += $charCount * $customfield->customfield_price;
            } else {
                $modificatorSum += $customfield->customfield_price;
            }
        }


Now the field works as expected.
If this bug does not exist in the latest version, this post can be ignored.

Hope this helps, cheers
Anna