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

Cannot return null for non-nullable field AvailableShippingMethod.method_code when no shipping methods are available #526

Merged
merged 3 commits into from
Apr 29, 2019

Conversation

XxXgeoXxX
Copy link
Member

Description (*)

Description #524

Manual testing scenarios (*)

Steps to reproduce (*)
Navigate to Stores> Settings>Configuration>Sales>Shipping Methods and turn off Flat Rate
Enable Free Shipping but go to Ship to Applicable Countries and uncheck Use Default
In Ship to Specific Countries set country to United Kingdom only.
In Show Method if Not Applicable set Yes
Get Customer Token
Create empty Cart
Add simple product to cart
Execute query cart:

query {
  cart(
    cart_id: "mfdHyHY0QgtXW5LeHxfJ0nVCjWjy655n"
  ) {
    available_payment_methods {
      code
      title
    }
    shipping_addresses {
      available_shipping_methods {
        carrier_title
        method_code
      }
    }
    
  }
}

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)

…hod_code when no shipping methods are available
}
}
if (count($methods) === 0) {
throw new GraphQlNoSuchEntityException(__(' This shipping method is not available. To use this shipping method, please contact us.'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to load the text of the message from config there

Have no idea how it can be done. So it's a question, not suggestion.

@@ -65,13 +66,19 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
$shippingRates = $address->getGroupedAllShippingRates();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check this behavior on frontend.
How to frontend work with getGroupedAllShippingRates method and provide the same error message

@galaoleksandr
Copy link

Cannot reproduce the issue.

@XxXgeoXxX
Copy link
Member Author

Hi, @galaoleksandr
This bug reproduced with enabled debugging.
Browser extension return empty array instead shipping error message

@naydav
Copy link
Contributor

naydav commented Mar 29, 2019

@TomashKhamlai Why do you consider that we need to show an error message?

Let's go step by step:

  1. Create cart
  2. Adding product to cart
  3. Get info about the cart
query {
  cart(
    cart_id: "mfdHyHY0QgtXW5LeHxfJ0nVCjWjy655n"
  ) {
    available_payment_methods {
      code
      title
    }
    shipping_addresses {
      available_shipping_methods {
        carrier_title
        method_code
      }
    }    
  }
}

Result should be

{
  "data": {
    "cart": {
      "available_payment_methods": [
        {
          "code": "checkmo",
          "title": "Check / Money order"
        }
      ],
      "shipping_addresses": [
        {
          "available_shipping_methods": []
        }
      ]
    }
  }
}

So, I see that there are not any available shipping methods.
This is enough information about deciding decision on UI.

@paliarush Could you look at it?

@naydav
Copy link
Contributor

naydav commented Mar 29, 2019

@XxXgeoXxX
In the scope of this task need to make

type AvailableShippingMethod {
    carrier_code: String!
    carrier_title: String!
    method_code: String!
    method_title: String!
    error_message: String
    amount: Float!
    base_amount: Float!
    price_excl_tax: Float!
    price_incl_tax: Float!
}

without required fields because it is not InputType(which can has some validation rules for input parameters) but it is Type
So we don't need to force to load all information (moreover GraphQL is way how to load just what you need)

@TomashKhamlai
Copy link
Contributor

@naydav, the message appears on Storefront and it also appears in developer mode.

@ghost
Copy link

ghost commented Apr 29, 2019

Hi @XxXgeoXxX, 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.

5 participants