After I updated my addressfield module to the latest to 7.x-1.0-rc1, it gives me an error when ajax does a refresh of the shipping services pane.

Notice: Undefined index: addressfield in commerce_shipping_recalculate_services_submit() (line 264 of /Applications/MAMP/htdocs/shiyr-poets/sites/all/modules/_store/commerce_shipping/includes/commerce_shipping.checkout_pane.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

akosipax’s picture

akosipax’s picture

Status: Active » Needs review
IckZ’s picture

works for me! akosipax++

akosipax’s picture

By the way, this still exists in the latest Addressfield (1.0)

derjochenmeyer’s picture

Project: Commerce Shipping » Address Field
Version: 7.x-2.x-dev » 7.x-1.x-dev

I don't know if changing the project is the right way to get an Address-Field-maintainers attention.

Adding isset() works, but maybe we need another fix here?

bojanz’s picture

Project: Address Field » Commerce Shipping
Status: Needs review » Needs work

There is no more $form_state['addressfield'] with latest addressfield, this code will need to change significantly.

revagomes’s picture

I agree we need a better solution in long term. Although the path #1 works fine for now.

I would just rename the patch to have the module's name as prefix. e.g. commerce_shipping-addressfield_undefined_index-2410911-1.patch

@see https://www.drupal.org/node/1054616#naming-conventions

mglaman’s picture

Assigned: Unassigned » mglaman
Category: Support request » Bug report

Taking a stab at this to fix error in CK2

mglaman’s picture

Assigned: mglaman » Unassigned
Status: Needs work » Needs review
FileSize
1.22 KB

Following the logic in the widget form, this patch should be the fix.

  // If the form has been rebuilt via AJAX, use the form state values.
  // $form_state['values'] is empty because of #limit_validation_errors, so
  // $form_state['input'] needs to be used instead.
  $parents = array_merge($element['#field_parents'], array($element['#field_name'], $langcode, $delta));
  $input_address = drupal_array_get_nested_value($form_state['input'], $parents);
mglaman’s picture

FileSize
1.32 KB

Whoops :) last patch was missing array key for field name. This patch fixes that, and ensures Country remains so there isn't a new error.

googletorp’s picture

Status: Needs review » Needs work
  1. +++ b/includes/commerce_shipping.checkout_pane.inc
    @@ -274,10 +274,22 @@ function commerce_shipping_recalculate_services_submit($form, &$form_state) {
    +        // Addressfield beta
    +        if (isset($form_state['addressfield'])) {
    +          foreach ($form_state['addressfield'] as $key => $value) {
    +            if (strpos($key, 'commerce_customer_profile|' . $type) === 0) {
    +              unset($form_state['addressfield'][$key]);
    +            }
    +          }
    +        }
    +        // Addressfield 1.0+
    +        else {
    

    It's fine to remove support for addressfield beta

  2. +++ b/includes/commerce_shipping.checkout_pane.inc
    @@ -274,10 +274,22 @@ function commerce_shipping_recalculate_services_submit($form, &$form_state) {
    +          foreach ($form_state['input']['customer_profile_' . $type]['commerce_customer_address'][LANGUAGE_NONE][0] as $key => &$value) {
    

    The code for 1.0 only works for commerce_customer_address, it should work for any addressfield.

wgsimon’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review
FileSize
971 bytes

I've just uploaded a new patch. This is the first patch I've submitted. I hope I've done it correctly.

wgsimon’s picture

wgsimon’s picture

Second try. Needed to check the field exists.

  • googletorp committed 0fe42f1 on 7.x-2.x
    Issue #2410911 by mglaman, wgsimon, akosipax, googletorp: Notice:...
googletorp’s picture

Status: Needs review » Fixed

Committed and pushed

Status: Fixed » Closed (fixed)

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

wgsimon’s picture

Status: Closed (fixed) » Needs work

The patch in #14 causes further errors.

When the 'Shipping information', 'Billing information' (with profile copying) and the 'Shipping service' are all on the checkout pane the following errors appear in the 'Billing information' when the 'Continue to next step' button is clicked:

Address 1 field is required.
Postal code field is required.
City field is required.
Full name field is required.

Why do we need to try and remove the cached data at all?

a.milkovsky’s picture

@wgsimon please check the #2453499-18: When 'copying' featured is enabled, PHP notice appears which affects recalculation of shipping services for the "..field is required" errors and tell if it fixes the issue for you.

quantos’s picture

Following. Got the same issue for the same reasons. Just found them after updating from Address Field 7.x-1.0-beta5 to Address Field 7.x-1.2. Reverting to the previous Address Field 7.x-1.0-beta5 removes the error (just in case that's not obvious to anyone just looking into this). Thanks. Q.

wgsimon’s picture

The patch in #2453499-18 fixes this issue for me as well. Thanks!

ludovic.agathe’s picture

Faced the same issue with:

commerce 7.x-1.3
addressfield 7.x-1.2
shipping 7.x-2.2

Ended up checking if the addressfield form variable was set in an if() statement. Not sure if this is the right approach but, so far, it fixed the issue for me.

Attached is the patch for the commerce_shipping.checkout_pane.inc file, in commerce_shipping > includes folder.

jasom’s picture

#22 seems working, error disappeared.

botris’s picture

Status: Needs work » Reviewed & tested by the community

Confirming #22 to fix the problem.

andyg5000’s picture

Status: Reviewed & tested by the community » Needs work

Hunting this down, but at a minimum, this needs a re-roll against -dev

andyg5000’s picture

Status: Needs work » Fixed

The site I was working on had a real old address field release. Updating it resolved the issues that brought me here. @bortis & @jasom, if you're still having the issue can you open a new issue and reference this one since it's been closed out?

andyg5000’s picture

... Also make sure you're using the -dev release of commerce_shipping! :P

Status: Fixed » Closed (fixed)

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

darrenwh’s picture

I'm still having issues with this https://www.drupal.org/node/2928534