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()

Comments

rbrownell’s picture

Title: Default value mandatory » Can't Set "None" as Default Value

Updating the title of this to see if it attracts any interest.

dave bruns’s picture

I 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.

dave bruns’s picture

Status: Active » Needs review
StatusFileSize
new892 bytes

Here'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.

rbrownell’s picture

Thanks Dave!

rbrownell’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: +undefined
lsolesen’s picture

Issue tags: -undefined
lsolesen’s picture

Issue summary: View changes

I can confirm that the patch works as expected.

selfuntitled’s picture

Yep - can confirm this resolves the issue, this looks ready to commit.

jlea9378’s picture

#2330633: Illegal String Offset Value appears to be a duplicate of this issue. I closed it.

Andy_D’s picture

Still 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."

  • stella committed 7549557 on 7.x-1.x authored by dave bruns
    Issue #2062285 by dave bruns: fix for: Can't Set "None" as Default Value
    
stella’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.