Author Topic: [Bug][Code attached] Customtextfield - Additional amount despite empty field  (Read 826 times)

Anna_Bolika

  • Beginner
  • *
  • Posts: 5
  • A beginner
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

Code: [Select]
            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:

Code: [Select]
        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