This issue stems from a need to bypass the Square payment pane to account for 100% discounts (or for any other time a cart would be processing a $0 balance order). As a solution, I implemented the fix outlined in #3 and #5 here:

https://www.drupal.org/project/commerce_userpoints/issues/1844236

So, I added this Condition to the Square Payment method:
---
Data comparison
Parameter: Data to compare: [commerce-order:commerce..., Operator: is greater than, Data value: 0
---

Resulting in the successful removal of the pane (with it being replaced by, "Payment is not required to complete your order.") - along with the following errors:

--
Notice: Undefined index: payment_methods in commerce_square_form_alter() (line 465 of .../sites/all/modules/commerce_square/commerce_square.module).
Warning: Invalid argument supplied for foreach() in commerce_square_form_alter() (line 465 of .../sites/all/modules/commerce_square/commerce_square.module).
--

I found this thread on the same topic that seems to indicate that this isn't a bug in Commerce but rather a module that doesn't implement the terminal properly in the submit function and validation function.

https://www.drupal.org/project/commerce/issues/2254223

CommentFileSizeAuthor
#3 2942214-3.patch720 bytesmglaman

Comments

Website Worker created an issue. See original summary.

chris matthews’s picture

I also implemented the fix outlined in #3 and #5 here, but I'm still getting the following warning:

Warning: Invalid argument supplied for foreach() in commerce_square_form_alter() (line 465 of .../sites/all/modules/commerce_square/commerce_square.module).

Is there a fix for this by chance?

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new720 bytes

This verifies the sub array keys exist and that we have an array.

daletrexel’s picture

At mglaman's request, I've tested the patch by applying it on a local copy of my D7 Commerce Kickstart site, and the JS for the Square Payment fields still loads. It sounds like that's the main concern needing testing, so I believe this can be marked RTBC.

daletrexel’s picture

Status: Needs review » Reviewed & tested by the community
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

@DaleTrexel thanks for testing! Committing this.

  • mglaman committed 38cd1ea on 7.x-1.x
    Issue #2942214 by mglaman, DaleTrexel: "Undefined index" when attempting...

Status: Fixed » Closed (fixed)

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