0

What method do I need to observe to create a 'before' plugin to add data to the Billing Address data in the quote_address table when a user clicks the 'Place Order' button?

I'd prefer to use a plugin instead of an oberserver, as I've read it's best practice to use plugins where possible (to avoid conflicts with other third-party extending code/observers etc).

1 Answer 1

0

Orders are saved trough Magento\Sales\Api\OrderRepositoryInterface its save function

I think you understand how plugins work? Do i need to explain it in more details?

7
  • Hmm but that's to save the order, right? Would it not be best to save my custom data to the quote_address table when Place Order has been clicked and then observe another method when order success occurs – and then copy the custom data from quote_address to sales_order_address?
    – MikeMason
    Nov 18, 2017 at 19:26
  • For what reason exactly do you want to do this? In other terms , what do you want to accomplish? Nov 18, 2017 at 19:33
  • I would like to save some custom data the user adds on the checkout (in a custom input). I, eventually, will pull this into the admin Order Grid. My plan (How I think I should do it): The custom input will be placed on the billing step of the checkout, so I would like to add the info to the billing address data tuple in the order_quote when the user clicks Place Order. Then, once they've made a (successful) payment, manually move the custom data from quote_address to the sales_order_address table at the same time as default checkout data is copied across. Very happy for any suggestions.
    – MikeMason
    Nov 18, 2017 at 19:44
  • Well that depends what kind of custom data.I need more information about what kind of data you want the user to add to the order. Nov 18, 2017 at 20:18
  • It'll be a text input for them to add any additional info ('Leave item with concierge / at reception' etc) they might want to add. It won't be a required field. Thanks for your help.
    – MikeMason
    Nov 18, 2017 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.