Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occurred during "shipping_address" processing on guest checkout #11

Open
sorinsinner opened this issue Mar 11, 2019 · 11 comments
Open

Comments

@sorinsinner
Copy link

I can't seem to get around this. Everything is working perfectly for logged in customer checkout (both frontend, and admin side).

But guest customer cannot place error with the following error coming up in the first step (Shipping) of checkout:

Error occurred during "shipping_address" processing. Error occurred during "customAttributes" processing. A custom attribute is specified with a missing attribute code. Verify the code and try again.

Can you help me figure this out? Checked on two different Magento 2.3 installations. One was fresh made just for testing this, and the other one is also 2.3 but with a theme applied.

@svijany
Copy link

svijany commented May 30, 2019

Did you ever resolve this issue?

@IonutGorgos
Copy link

I have just found a solution. You need to rename the "customAttributes" key from the JSON that will be sent to guest-rest-api, with "custom_attributes".

Here you can find the documentation:
https://devdocs.magento.com/redoc/2.3/guest-rest-api.html#operation/checkoutGuestShippingInformationManagementV1SaveAddressInformationPost

@Jyotishina
Copy link

Hey @IonutGorgos could you eloborate how does the issue is resolved? did you override core code

@IonutGorgos
Copy link

IonutGorgos commented Aug 8, 2019

Hello,

I think that the solution wasn't to rename the "customAttributes" key. I did other things too. I will enumerate the steps.

  1. You need to create another plugin for GuestPaymentInformationManagement. Copy and paste this code in etc/di.xml file.
<type name="Magento\Checkout\Model\GuestPaymentInformationManagement">
        <plugin disabled="false" name="Experius_ExtraCheckoutAddressFields_Plugin_Magento_Checkout_Model_GuestPaymentInformationManagement"
                sortOrder="10" type="Experius\ExtraCheckoutAddressFields\Plugin\Magento\Checkout\Model\GuestPaymentInformationManagement"/>
</type>
  1. Create the file Plugin/Magento/Checkout/Model/GuestPaymentInformationManagement.php
    You can copy and paste the PaymentInformationManagement.php file from the same folder and just add the email param in the beforeSavePaymentInformation method.

beforeSavePaymentInformation method:

public function beforeSavePaymentInformation(
        \Magento\Checkout\Model\GuestPaymentInformationManagement $subject,
        $cartId,
        $email,
        PaymentInterface $paymentMethod,
        AddressInterface $address
    ) {
        $extAttributes = $address->getExtensionAttributes();
        if (!empty($extAttributes)) {
            $this->helper->transportFieldsFromExtensionAttributesToObject(
                $extAttributes,
                $address,
                'extra_checkout_billing_address_fields'
            );
        }
    }
  1. Now, if you did all this steps, the following error will occur:
    "Property "0" does not have accessor method "get0" in class "Magento\Quote\Api\Data\AddressExtensionInterface"."
    That is because you need to do some changes in view/frontend/web/js/action/set-shipping-information-mixin.js

We need to have the extension_attributes key something like that:

{
 attribute_code1_key: "attribute_code1_value",
 attribute_code2_key: "attribute_code2_value",
 ....... ....... ....... ....... ....... ........
 attribute_codeN_key: "attribute_codeN_value",
}
  1. Some changes in view/frontend/web/js/action/set-shipping-information-mixin.js:
            if (shippingAddress.customAttributes !== undefined) {
                $.each(shippingAddress.customAttributes, function (key, value) {

                    var attrCode = value['attribute_code'];
                    var attrValue = value['value'];

                    shippingAddress['customAttributes'][attrCode] = value;
                    shippingAddress['extension_attributes'][attrCode] = attrValue;
                });
            }
  1. Some changes in view/frontend/web/js/action/create-shipping-address-mixin.js:
            if (messageContainer.custom_attributes != undefined) {
                $.each(messageContainer.custom_attributes , function( key, value ) {
                    messageContainer['custom_attributes'][key] = value;
                });
            }
  1. Some changes in view/frontend/web/js/action/set-billing-address-mixin.js:

                if (billingAddress.customAttributes != undefined) {
                    $.each(billingAddress.customAttributes, function (key, value) {

                        var attrCode = value['attribute_code'];
                        var attrValue = value['value'];

                        billingAddress['extension_attributes'][attrCode] = attrValue;
                    });
                }
  1. Don't forget the fieldset.xml and extensions_attributes.xml files.

@Jyotishina
Copy link

Hey @IonutGorgos Im still getting get0 exception while changing set-shipping-information-mixins could you share updated code and files please so that could everyone get cleared:

[email protected]

@Jyotishina
Copy link

Report ID: webapi-5d4c9c422969a; Message: Property "0" does not have accessor method "get0" in class "Magento\Quote\Api\Data\AddressExtensionInterface". {"exception":"[object] (Exception(code: 0): Report ID: webapi-5d4c9c422969a; Message: Property "0" does not have accessor method "get0" in class "Magento\Quote\Api\Data\AddressExtensionInterface". at /home/dev73onlinetesti/public_html/magento/project-community-edition/vendor/magento/framework/Webapi/ErrorProcessor.php:206, LogicException(code: 0): Property "0" does not have accessor method "get0" in class "Magento\Quote\Api\Data\AddressExtensionInterface". at /home/dev73onlinetesti/public_html/magento/project-community-edition/vendor/magento/framework/Reflection/NameFinder.php:100)"} []

@Jyotishina
Copy link

@sorinsinner did you resolve issue?

@KovalskiWeb
Copy link

Has anyone solved this problem?

@Jyotishina
Copy link

Jyotishina commented Aug 31, 2019 via email

@RonakParmar
Copy link

Is anyone has fix of this issue? Tried above solution but still getting same error.

@hmhosseini
Copy link

hi,problem still remains any solution ?

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

No branches or pull requests

7 participants