0

Can we programmatically change the Cash On Delivery label like when an Order was created from the admin side or from a plugin I created (programmatically)?

I am creating a plugin that imports orders from another store. The payment are handled by that store so when I import the orders and save them as Magento Orders, I want to specify Cash On Delivery but would like to append the store name to it like "Rahaha Cash On Delivery" instead of showing up as only Cash On Delivery.

2

Unlike shipping method choice, the payment method label is not stored as part of the order information--just the internal code. The label is determined on the fly each time, pulled from store configuration for the given code.

Options?

  1. Duplicate the 'Cash On Delivery' payment method as a custom payment method with its own settings. You'll have your own payment method code, your own settings (that you can set a label for), and then your model will just extend the existing Cash On Delivery model.
  2. Modify the 'Cash On Delivery' payment method to pull its label from some other source. The payment method title is pulled in Magento_Payment::info/instructions.phtml from $block->getMethod()->getTitle(), with method being an instance of \Magento\OfflinePayments\Model\Cashondelivery (as linked above). You could alter that value with a simple 'after' plugin on getTitle.
1
  • 1
    The first solution was the one I chose. It worked as expected.
    – Rahahaha
    May 1 '16 at 19:49

Your Answer

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

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