Closed (duplicate)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Price
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2012 at 18:55 UTC
Updated:
17 Dec 2013 at 03:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rszrama commentedThis isn't a bug so much as by design. I'm not sure there's a great way for us to make this editable via the UI, but at least in your case you can edit the database and change it to a bigInt or something similar.
Comment #2
hejazee commentedAnyway I think we should have at least a form validation callback
that prevents the user from entering very big numbers
Otherwise, the user will see WSOD or an ugly db error message
Comment #3
hejazee commentedNow this is a bug!
missing form validation
Comment #4
rszrama commentedLet's leave this issue categorized as such; there's a separate issue for fixing validation.
Comment #5
hejazee commentedBut it isn't 11 digits, I say :)
Comment #6
hejazee commentedI solved this issue by setting decimals to 0 for IRR currency
I think this patch should be ported !
Because there is no product ever that costs lower than a Rial, so we will never need decimal letters for this currency.
And also, showing decimals for Rials is annoying for users.
Comment #7
rszrama commentedAhh, great. That would be a great fix; also, my bad, it isn't 11 digits - it's an 11 character display width that has no bearing on the size of the integer itself. n00b mistake: http://everythingmysql.ning.com/profiles/blogs/data-type-confusion-what-...
Comment #8
hejazee commentedNote that we also need an update function in commerce.install file
We need to divide all prices by 100 (Because we removed decimals)
Only products that have a price in IRR will need to be updated
Comment #9
hejazee commentedIt seems that removing extra decimal places causes some errors in commerce !
Maybe some modules are used to add double 0 at the end of price
For example when I make a new invoice with commerce_invoices module
the amount of the invoice is multiplied by 100
And also, I can't pay for a product. I get an error (Maybe that's due to inequality of price when paying and when confirming it)
Comment #10
hejazee commentedComment #11
hejazee commentedRelated: I created this sandbox module
http://drupal.org/sandbox/hejazee/1861440
which makes a new 'Toman' currency to be used instead of 'Rials' (IRR) without applying a patch.
Comment #12
leksat commentedMy quick workaround to set commerce_price fields type to bigint:
For updating all existing fields:
drush eval 'foreach (field_info_fields() as $field) { MYMODULE_field_create_field($field); }'Comment #13
foopang commentedHi Leksat, thanks for your workaround. But I get an error message below after applying your code above. It's weird that I still get the error message even I took off the hook function and cleared cache. Any way to fix it? Thanks.Notice: Undefined index: bigint:normal in DatabaseSchema_mysql->processField() (line 205 of /var/www/test/includes/database/mysql/schema.inc).There was a problem creating field Price: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL DEFAULT 0 COMMENT 'The price amount.', `field_price_currency_co' at line 9Workaround solution from Leksat is perfect! Thanks.
Comment #14
donquixote commented#2084171: Custom module to have prices and amounts in the database stored as BIGINT instead of INT
@Leksat:
This is nice, but are there not more tables and columns that need to be changed?
(see the linked issue)
Comment #15
dgtlmoon commented[comment deleted, realised this is covered in another issue] :)
Comment #16
amankanoria commentedIf in case any 1 is looking for price validation so as to avoid mysql error for value limit I have added a short patch for it
PS: Validation is in context with int(11) field
Comment #17
rszrama commentedI'm going to go ahead and close this as either fixed by the workaround above or else pending resolution of #2084171: Custom module to have prices and amounts in the database stored as BIGINT instead of INT. I was originally interested in the idea of adding the validation from #16, but then I realized that doing so would make it more difficult for sites that actually want to support bigger numbers since they'd have to figure out how to work around this core validation. While ugly, the existing error is at least sufficient enough to show that big numbers aren't supported imo.