Jump to content

Removing [Brackets] from email subject


Recommended Posts

Hello, I only found something about removing shop name from emails, but nothing about removing just the straight brackets []. Is there anyone that can help me with this. I wouldn't want to remove anything else because the shop title can be changed from Back Office if needed, but I don't understand the reason for the brackets.

I managed to look around and fount this part inf theme/mytheme/template/_partials :


/* Create mail and attach differents parts */
            $subject = '[' . strip_tags($configuration['PS_SHOP_NAME']) . '] ' . $subject;
            $message->setSubject($subject);

 

Now i'm only guessing that the part  '[' and ']' is what i'm looking for, but i am not 100% sure and don't know enough code to rewrite this without messing up the entire email system that works fine. And does this part control all of the email templates like “New user” email registration, “New order” registration etc.

So in conclusion, i would like my emails to not have straight brackets  

“[Shop Title] — Thank you for registering” -> “Shop Title — Thank you for registering”

Link to comment
Share on other sites

Hi,

To remove the square brackets from the email subject lines in your PrestaShop emails, you simply need to modify the code that formats the subject

Replace the mentioned code ( $subject = '[' . strip_tags($configuration['PS_SHOP_NAME']) . '] ' . $subject; )

with the below code-
$subject = strip_tags($configuration['PS_SHOP_NAME']) . $subject;

And if you want to use a dash between the Shop name and subject, then use the below code-
$subject = strip_tags($configuration['PS_SHOP_NAME']) . ' — ' . $subject;

Then, save the file and clear the cache of your store.

After making this modification, ensure you test by sending a test email to verify that everything works as expected.

Regards.

Link to comment
Share on other sites

Thank you for your response. It works just fine for the first example $subject = strip_tags($configuration['PS_SHOP_NAME']) . $subject;

I also tried the one with the dash like $subject = strip_tags($configuration['PS_SHOP_NAME']) . ' — ' . $subject; but this one gives me a server 500 error. I think it doesn't like that symbol "—". Do you have any thoughts on this?

If i just delete the brackets, there is no space between the store name and the email action:

Ex: StorenameOrder confirmed

I would like to use the dash "—" so it looks like this :

Ex: Storename — Order confirmed

If i do that, it gives me the error i mentioned. So when you have time and if you have some other suggestions, i would appreciate it.

Thank again.

Link to comment
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
×
×
  • Create New...