magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

[2.0.7] Providing a new postalcode does not refresh shipping alternatives. #4855

Closed peec closed 8 years ago

peec commented 8 years ago

Magento: 2.0.7 + 2.1.0-RC2 Theme: Luma

Steps to reproduce

  1. Add a product to cart
  2. Go to checkout
  3. Try changing address fields one by one.

    Expected result

  4. The shipping alternatives should refresh when address related fields such as postalcode are changed. Meaning the ajax call to index.php/rest/default/V1/guest-carts/xxxxxxxxxxx/estimate-shipping-methods should be called when peple change delivery address fields such as postal code etc.

    Actual result

  5. Does not refresh shipping alternatives when changing the address related fields.
joni-jones commented 8 years ago

To help us investigate and reproduce your issue, please, follow to reporting guidelines.

peec commented 8 years ago

Updated issue.

This should be called after shipping details are filled out: index.php/rest/default/V1/guest-carts/xxxxxxxxxxx/estimate-shipping-methods

Its only called on initial load of Checkout.

joni-jones commented 8 years ago

@peec, do you have any errors in the browser console during checkout step? Could you also attach debug and exception Magento log?

willstorm commented 8 years ago

Hi Guys,

Same problem here. It's happend when you has shipping method "flat rate" disabled. No errors in the browser console.

joni-jones commented 8 years ago

Hi, @willstorm, do you have any configured shipping methods except Flat Rate?

willstorm commented 8 years ago

Yes, I'm developed an extension.

peec commented 8 years ago

I am also developing a custom extension. If its when flat rate is disabled, I think to reproduce then you disable all shipping methods, keep one custom one. E.g. https://github.com/magento/magento2-samples/tree/master/sample-module-shipping-provider

joni-jones commented 8 years ago

Looks a strange, we will investigate the case when only custom shipping method is configured.

willstorm commented 8 years ago

I found another issue relating same problem. https://github.com/magento/magento2/issues/4059

joni-jones commented 8 years ago

Hi @willstorm and @peec, I've been tested on the latest develop branch with SampleShippingProvider module - all works fine. The estimate-shipping-methods is triggered when country or zip code is changed.

Note: to trigger request for shipping methods estimation for additional fields like city, street, etc you need to update ModuleName\view\frontend\web\js\model\shipping-rates-validation-rules.js model.

peec commented 8 years ago

Thank you, I now found this in the docs: http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_carrier.html

And these files must be present:

view/
└── frontend
    ├── layout
    │   ├── checkout_cart_index.xml
    │   └── checkout_index_index.xml
    └── web
        └── js
            ├── model
            │   ├── shipping-rates-validation-rules.js
            │   └── shipping-rates-validator.js
            └── view
                └── shipping-rates-validation.js

I guess this issue can be closed.

luizpaulofranz commented 6 years ago

Hi, I think this is not solved yet... (I'm using magento 2.2.2 CE edition)

I have followed the same as @peec has mentioned, but here, my custom shipping validations are not loading, and even the .js files aren't load in my page, I don't know why ... look: checkout_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
      <referenceBlock name="checkout.root">
         <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="steps" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="shipping-step" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="step-config" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <item name="shipping-rates-validation" xsi:type="array">
                                                            <item name="children" xsi:type="array">
                                                                <item name="inchoo" xsi:type="array">
                                                                    <item name="component" xsi:type="string">Inchoo_Shipping/js/view/inchoo</item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

checkout_cart_index.xml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.cart.shipping">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="summary-block-config" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="shipping-rates-validation" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="inchoo" xsi:type="array">
                                            <item name="component" xsi:type="string">Inchoo_Shipping/js/view/inchoo</item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

And Finally, my inchoo.js in Inchoo/Shipping/view/frontend/web/js/view/inchoo.js, with this content:

define([
    'uiComponent',
    'Magento_Checkout/js/model/shipping-rates-validator',
    'Magento_Checkout/js/model/shipping-rates-validation-rules',
    '../model/inchoo-validatior',
    '../model/inchoo-rules'
],function (
        Component,
        defaultShippingRatesValidator,
        defaultShippingRatesValidationRules,
        shippingRatesValidator,
        shippingRatesValidationRules
    ) {
        'use strict';
        defaultShippingRatesValidator.registerValidator('carrierName', shippingRatesValidator);
        defaultShippingRatesValidationRules.registerRules('carrierName', shippingRatesValidationRules);
        return Component;
    }
);

But when I'm at guest checkout page, I've noticed that inchoo.js file is not loaded. Any idea of why it occurs? Thanks in advance.

akshgods commented 6 years ago

hi @peec @joni-jones , can any one know where this ajax get call , full path in magento 2

index.php/rest/default/V1/guest-carts/xxxxxxxxxxx/estimate-shipping-methods

even more how to get xxxxxxxxxxx value? i want to manually fire ajax call , thanks

ParagBhargav commented 5 years ago

Same kind of issue I am facing as well. But this issue occurred randomly. Sometimes its fire the ajax request but sometimes it fails. I don't understand why this issue happens. Is anybody have any idea about it?

johnorourke commented 4 years ago

In case someone finds this still an issue with custom shipping methods, I hope https://github.com/magento/magento2/issues/4059#issuecomment-661124699 helps.