There is a problem when setting the Donation Line Item Field for commerce_donate_amount, you can not make any changes without setting a default value (this exists in both Beta 1 and the Dev versions). Setting a default value is bad business practice because the field would be automatically set to whatever value as they go through the checkout process. When you try to save without a default value you get the 'Donation Amount field must be a valid integer or decimal.' error.
Cannot use a scalar value as an array in commerce_donate_checkout_pane_checkout_form()
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | commerce_donate-Fix-default-in-checkout-2062285-3.patch | 892 bytes | dave bruns |
Comments
Comment #1
rbrownellUpdating the title of this to see if it attracts any interest.
Comment #2
dave bruns commentedI had the same problem. The default value works fine for the field 'Amount', which appears in the 'Donation' custom line item type. However, it didn't work during checkout, when commerce donate was set to 'override available options'. The cause is a subtle bug in commerce_donate.checkout_pane.inc.inc at line 91:
$pane_form[$pane_id][$field_name][$language]['#default_value']['value'] = '';
should be:
$pane_form[$pane_id][$field_name][$language]['#default_value'] = '';
Note the extra ['value'] at the end of the first line. This caused a corruption of the default value, which then caused it never to match any of the options (notably 'none' which is what it is supposed to match).
I don't have any experience submitting patches, but will look into when I have a bit of time. In the meantime, making the change above should do the trick.
Comment #3
dave bruns commentedHere's a patch to fix the default in checkout problem as described in the comment above. My first patch, so please review and let me know if there's anything else I should be doing.
Comment #4
rbrownellThanks Dave!
Comment #5
rbrownellComment #6
lsolesen commentedRelated to #1986592: Upgrade from beta1 to 1.x-dev - Cannot use a scalar value as an array in commerce_donate_checkout_pane_checkout_form()
Comment #7
lsolesen commentedComment #8
lsolesen commentedI can confirm that the patch works as expected.
Comment #9
selfuntitled commentedYep - can confirm this resolves the issue, this looks ready to commit.
Comment #10
jlea9378 commented#2330633: Illegal String Offset Value appears to be a duplicate of this issue. I closed it.
Comment #11
Andy_D commentedStill occuring when I try to set the value to n/a in the Field Settings. overlay=admin/commerce/config/line-items/commerce-donate/fields/commerce_donate_amount won't allow me to set the Default value amount to N/A.
Interestingly I'm getting a similar issue to this: https://www.drupal.org/node/1701746 with the same error "Amount field must be a valid integer."
Comment #13
stella commentedCommitted, thanks!