Jump to content

How to remove the shop name from the mail subject by override


ballashop
 Share

Recommended Posts

Hi,

is there anyone who can tell me how to override this code to remove [shop name] from the mail subject?

from:

$subject = '[' . $shop->name . '] ' . $subject;

to:

$subject = $subject;

goal: remove [shop name] from the all mails subject

Thanks for any reply.

balla

Share this post


Link to post
Share on other sites

./classes/Mail.php

Find function Send().

 

Comment line /* xxx */:

/* $subject = '[' . Configuration::get('PS_SHOP_NAME', null, null, $idShop) . '] ' . $subject; */

 

Or create override Mail.php and save to ./override/classes/Mail.php:

<?php

class Mail extends MailCore
{
    
    public static function send(
        $idLang,
        $template,
        $subject,
        $templateVars,
        $to,
        $toName = null,
        $from = null,
        $fromName = null,
        $fileAttachment = null,
        $mode_smtp = null,
        $templatePath = _PS_MAIL_DIR_,
        $die = false,
        $idShop = null,
        $bcc = null,
        $replyTo = null,
        $replyToName = null
    )
    {
        $shop_name = '[' . strip_tags($configuration['PS_SHOP_NAME']) . '] ';
        $subject = str_replace($shop_name, '', $subject);
        $message->setSubject($subject);     
    
        return parent::send(
            $idLang,
            $template,
            $subject,
            $templateVars,
            $to,
            $toName,
            $from,
            $fromName,
            $fileAttachment,
            $mode_smtp,
            $templatePath,
            $die,
            $idShop,
            $bcc,
            $replyTo,
            $replyToName
        );
    }
}

 

Or create custom module and call hook:

public function hookActionEmailSendBefore($param)
{
    if (!isset($param['subject'])) {
        return;
    }

    $shop_name = '['.strip_tags($configuration['PS_SHOP_NAME']).'] ';
    $subject = str_replace($shop_name, '', $param['subject']);
    
    $param['subject'] = $subject;
}

There are more options 😉

Edited by 4you.software (see edit history)
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More