Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Prevent undefined index warning before setting shipping method #666

Merged
merged 1 commit into from
May 10, 2019

Conversation

pmclain
Copy link
Contributor

@pmclain pmclain commented May 3, 2019

Description (*)

list could cause and undefined index error when address rates had been
collected and the shipping method was not set. This commit checks that the
shipping method is set prior to resolving.

Fixed Issues (if relevant)

  1. Notice: Undefined offset: 1 in app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddress/SelectedShippingMethod.php on line 35 #657

Manual testing scenarios (*)

Reliably reproducing the original error depends on the order of the field properties in the query, available_shipping_methods MUST precede selected_shipping_method.

  1. Create empty cart
  2. Add simple product to cart
  3. Set shipping method on cart
  4. Request available rates and selected shipping method from cart
{
  cart(cart_id: "$maskedQuoteId") {
    shipping_addresses {
      available_shipping_methods {
        carrier_code
        method_code
      }
      selected_shipping_method {
        carrier_code
        method_code
        carrier_title
        method_title
        amount {
            value
            currency
        }
        base_amount {
            value
            currency
        }
      }
    }
  }
}

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

`list` would cause and undefined index error when address rates had been
collected and the shipping method was not set. This commit checks that the
shipping method is set prior to resolving.

Fixes magento#657
@TomashKhamlai TomashKhamlai added Progress: ready for qa Add this in any case when you need some feedback, even if automated tests are failing QA in progress We are checking QA passed and removed Progress: ready for qa Add this in any case when you need some feedback, even if automated tests are failing QA in progress We are checking labels May 3, 2019
@TomashKhamlai
Copy link
Contributor

Works great! @naydav, please review.

@ghost
Copy link

ghost commented May 10, 2019

Hi @pmclain, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants