Answer the question
In order to leave comments, you need to log in
How to pass data from front to delivery method in Magento 2?
I'm stuck with one task related to a custom shipping method in a Magento 2 store. I've already spent an indecent amount of time looking for a solution, but things are still there.
So, there is a custom shipping method. In the basket, the selection of the pickup point is implemented using the widget provided by the delivery service. The widget returns different data depending on the selected point: its address, shipping cost depending on the weight of the package, etc. I add this data to the quote.pickpoint object using observable. And here is the task itself: to transfer the received data to the delivery method in order to select the necessary data from there, to set the delivery cost. The delivery method receives data in the form Magento\Quote\Model\Quote\Address\RateRequest. Question: how to add my custom data to this object?
First, I followed the path of forming extension attributes for Magento\Checkout\Api\Data\ShippingInformationInterface. And I managed to transfer the data, BUT. JS function getRates is processed before saveShippingInformation. And it turns out that the delivery methods are returned with an empty value, and the normal shipping cost is only in Totals, respectively, the shipping cost does not fall into the resulting Order object.
Please tell me which of the interfaces needs to be expanded with attributes in order for this to work. Or is my approach fundamentally wrong, and is it all done differently?
Thank you all in advance!
Answer the question
In order to leave comments, you need to log in
I dug up the Magenta sources, it seems I found a solution. You need to extend the Magento\Quote\Api\Data\AddressInterface interface
Need to do another shipping method. It is the shipping method that is responsible for calculating shipping for an order.
https://inchoo.net/magento-2/creating-a-shipping-m...
https://www.mageplaza.com/magento-2-create-shippin...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question