We stumbled on an issue where if we enter a comma in a product's price field (ex: "1,000") and then save, when the page refreshes, it contains a value of "1". However, it works fine if "1000" is entered.
Is there anything that can be done to handle an entry that contains a comma? My initial thought would be to look for a comma in those fields and strip it out before the value is actually recorded. Thoughts?
Thanks for your help,
In most cases the PHP function floatval() is used to filter most numeric data related to price. It will see the comma as the decimal separator. It would be my bet that the data is being processed through floatval() first (regardless of currencies that may also use comma as the decimal separator).
Not sure this would be easy to solve for all cases. I show 168 instances of floatval() in the app directory.
If the issue is the admin UI (assuming for vendors), then You'd probably have to to add a pre controller to look at the $_REQUEST['product_data'] array and then filter all prices to strip the comma. However this won't work for import of CSV and other ways that prices are set. You'd probably have to add several pre-filters to catch all instances.
Thanks for the response, Tony. Man, you're such a buzzkill :)
Yea, the main concern would be for the vendor UI since we've disabled their ability to import via csv and other price inputs/manipulation, such as promotions and gift certificates are admin only. So, as far as I can tell, the only price inputs available to the vendors are: price & list price on products.update and price on product_options.inventory (this was added via an addon that enables setting prices for combinations).
Given that, does that change the level of complexity to fix this? Or, can you think of another solution, maybe some type of warning instead?
Hoping 'buzzkill' is a compliment! :-)
Yes, you can add a pre-controller that can filter those inputs to strip any commas from them.
Drop me an email and we'll get you taken care of.
Some of your Canadian vendors showing their European roots? :-)