0

enter image description here

In this screenshot you can see sales order mail sending to multiple acounts . and It work good mail sending to all accounts which mention in Send Order Email Copy To This is hard code to give account. I am developing multi-vendor site. i want to give just those vendor's accounts for email which has items in this order.

Can anyone tell me how can give programmatically emails account instead of giving hardcode in frontend as shown in screenshot.

2

You need to override getEmailCopyTo() function of vendor/magento/module-sales/Model/Order/Email/Container/OrderIdentity.php

And write your custom code and returns an array of emails.

/**
 * Return email copy_to list
 *
 * @return array|bool
 */
public function getEmailCopyTo()
{
    //Write custom code and returns array of emails

    $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId());
    if (!empty($data)) {
        return explode(',', $data);
    }

    return false;
}

For Invoice Emails: vendor/magento/module-sales/Model/Order/Email/Container/InvoiceIdentity.php

For Shipment Emails: vendor/magento/module-sales/Model/Order/Email/Container/ShipmentIdentity.php

For creditmemo emails: vendor/magento/module-sales/Model/Order/Email/Container/CreditmemoIdentity.php

| improve this answer | |
  • Dear @Prince ! where i mention custom emails ? dev.test1@gmail.com,dev.test2@gmail.com etc ? in $data variable ? – HaFiz Umer Apr 3 '19 at 7:35
  • @HaFizUmer I just mentioned original function. As per your question you need to pass emails programmatically, You can write your custom code and returns the array of email here – Prince Patel Apr 3 '19 at 8:43

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.