0

I am pretty new to Magento but I am in the process of building out a plugin that will eventually validate a user's shipping address and then update the user's shipping address on the payment screen.

My plugin seems to be firing fine as I can write to the log and see the updated address in the quote_address table but the address is not updated on the payment screen. Can someone point out what I am missing here?

Old address on Payment Screen:

enter image description here

Plugin Code:


public function beforeSaveAddressInformation(
    \Magento\Checkout\Model\ShippingInformationManagement $subject,
    $cartId,
    \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
)
{
    $addressInformation->getShippingAddress()->setStreet("123 Updated Rd");
    $addressInformation->getBillingAddress()->setStreet("123 Updated Rd");

    $this->_logger->debug(json_encode((array)$addressInformation->getBillingAddress()));
    $return = [$cartId, $addressInformation];

    return $return;
}

Edit:

After digging into this further, I believe this is a front-end cache issue. I've attempted to reload the cache but that doesn't seem to do anything. Any suggestions on where or how to reload the cache on the front-end would be appreciated. In my custom plugin, I've overridden the checkout-data.js file and added a custom function that seems like it should reload the cache from the server but I've not had any luck with it.

getRefreshedData = function () {
            let sections = ['checkout-data'];
            storage.invalidate(sections);
            storage.reload(sections, true);
            var data = storage.get(cacheKey)();
            saveData(data);
            return data;
        };

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.