Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Issue When Entering A Comma In The Price Field Rate Topic   - - - - -

 
  • arteeni
  • Advanced Member
  • Members
  • Join Date: 07-Aug 15
  • 85 posts

Posted 09 June 2016 - 08:53 PM #1

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,

Jason


Arteeni - a marketplace for artisan, handmade goods, with a charitable twist.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11770 posts

Posted 10 June 2016 - 08:45 PM #2

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • arteeni
  • Advanced Member
  • Members
  • Join Date: 07-Aug 15
  • 85 posts

Posted 13 June 2016 - 04:43 PM #3

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?


Arteeni - a marketplace for artisan, handmade goods, with a charitable twist.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11770 posts

Posted 13 June 2016 - 10:15 PM #4

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


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.