Jump to content

{shop name} in emails - change to the shop where order was placed - multistore


clubvapea

Recommended Posts

Hi guys,

I can't find a solution to this problem.

 

I have a multistore. Whenever a customer buys something in my store and I change the order status, the email sent looks at which shop _I have currently selected at backoffice_ and not at the _shop where the customer ordered_. This creates a big problem, as I usually have "All shops" enabled, so all customer emails go with only the default shops name. 

 

Any suggestions on how to change {shop name} to look at where the order was placed at?

 

Thanks,

Phoebe

Link to comment
Share on other sites

The shop name used in emails related to an order is normally the name of the shop related to the order (cf. OrderHistory).

Didn't you forget to set the "public" name of your shops?

BO > Preferences > Store Contacts > Contact Details > Shop name (depends on shop context).

 

 

 

Link to comment
Share on other sites

The shop name used in emails related to an order is normally the name of the shop related to the order (cf. OrderHistory).

Didn't you forget to set the "public" name of your shops?

BO > Preferences > Store Contacts > Contact Details > Shop name (depends on shop context).

 

Thanks for your reply. But I have set the public name for each store. 

I have done some testing:

1. I place an order

2. I go to backoffice and change the order status using shop3, the email sent has the name shop3. I change the order status again, with shop2, the email has shop2. It does not correspond to OrderHistory. 

3. I answer a message on backoffice, exact same thing happens. See the photo below.. Thanks

 

Does this happen to me only?poista.JPG

Link to comment
Share on other sites

I just did the same tests on PS 1.6.1.4

  • 2 shops: A and B, shop A is default
  • order in from shop B
  • BO > Orders > Edit order
  • Set shop context = Shop B and change order state => email from shop B
  • Set shop context = All shops and change order state => email from shop B
  • Set shop context = Shop A (*) and change order state => email from shop B

(*) It's not possible from order list but it is from order detail...

 

So, don't you have an override of OrderHistory or did you change it?

Link to comment
Share on other sites

I just did the same tests on PS 1.6.1.4

  • 2 shops: A and B, shop A is default
  • order in from shop B
  • BO > Orders > Edit order
  • Set shop context = Shop B and change order state => email from shop B
  • Set shop context = All shops and change order state => email from shop B
  • Set shop context = Shop A (*) and change order state => email from shop B

(*) It's not possible from order list but it is from order detail...

 

So, don't you have an override of OrderHistory or did you change it?

 

Thanks for your reply. I don´t have an override of OrderHistory, not that I know of. Where can I download the original file, or what should I do?

 

Thanks!

Link to comment
Share on other sites

I just did the same tests on PS 1.6.1.4

  • 2 shops: A and B, shop A is default
  • order in from shop B
  • BO > Orders > Edit order
  • Set shop context = Shop B and change order state => email from shop B
  • Set shop context = All shops and change order state => email from shop B
  • Set shop context = Shop A (*) and change order state => email from shop B

(*) It's not possible from order list but it is from order detail...

 

So, don't you have an override of OrderHistory or did you change it?

 

I did a little testing:

  • 5 shops: A and B, shop A is default, CDE not relevant
  • order in from shop B
  • BO > Orders > Edit order
  • Set shop context = Shop B and change order state => email from shop B
  • Set shop context = All shops and change order state => email from shop A, default shop!
  • Set shop context = Shop A and change order state => email from shop B
Link to comment
Share on other sites

UPDATE:

I recently copied manually the default theme folder and created a new theme, which I use in the sop that has the problems. These problems dont occur with the other shops. So, did I miss a step in copying the theme? I simply copied the whole folder, added it, and in the backoffice, selected that folder and renamed the theme. Then I deleted the cache files. Help?

Link to comment
Share on other sites

After having seen your post in French, I also tested on PS 1.6.0.14, and got the same results (every email sent from shop B, ok)

 

Original source code is here: https://github.com/PrestaShop/PrestaShop/tree/1.6.0.14

 

About the theme, it should not interfere with that functionnality which is purely back-office, but...

 

In order to detect where the problem is, you can add some traces in the code (you should set your shops in maintenance mode or work with a mirror installation). I would start with the following:

 

1. Check if shop id is correctly set before sending email (file /classes/order/OrderHistory.php, line 442)

var_dump((int)$order->id_shop);
Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
    null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);

2. Check if shop name is correctly set from configuration (file /classes/Mail.php, line 281)

var_dump(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
die();
$subject = '['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject;
$message = new Swift_Message($subject);

You will also  know if something has been overridden.

Do not forget to remove additional lines after having tested!

 

Link to comment
Share on other sites

Thank you so much for your detailed reply. 

Sorry, I am not very good with the technical side of things, so after inserting the var_dumps where can I see the result of the testing? 

 

After having seen your post in French, I also tested on PS 1.6.0.14, and got the same results (every email sent from shop B, ok)

 

Original source code is here: https://github.com/PrestaShop/PrestaShop/tree/1.6.0.14

 

About the theme, it should not interfere with that functionnality which is purely back-office, but...

 

In order to detect where the problem is, you can add some traces in the code (you should set your shops in maintenance mode or work with a mirror installation). I would start with the following:

 

1. Check if shop id is correctly set before sending email (file /classes/order/OrderHistory.php, line 442)

var_dump((int)$order->id_shop);
Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
    null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);

2. Check if shop name is correctly set from configuration (file /classes/Mail.php, line 281)

var_dump(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
die();
$subject = '['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject;
$message = new Swift_Message($subject);

You will also  know if something has been overridden.

Do not forget to remove additional lines after having tested!

Link to comment
Share on other sites

Simply open an order and  change its state. The email will not be sent because of the die (it's why you should be in maintenance mode) and the 2 values will be displayed on your browser.

If it's not the case, you should look for an override (/override/classes/order/OrderHistopry.php or /override/classes/Mail.php)

Again, remove the var_dump and especially the die asap.

Edited by erouvier29 (see edit history)
Link to comment
Share on other sites

Simply open an order and  change its state. The email will not be sent because of the die (it's why you should be in maintenance mode) and the 2 values will be displayed on your browser.

If it's not the case, you should look for an override (/override/classes/order/OrderHistopry.php or /override/classes/Mail.php)

Again, remove the var_dump and especially the die asap.

 

It gives me int(8) string(12) "ClubVapea.es" which is the first store. Does this mean my configuration is wrong?

In Preferences > Store contacts > Contact Details I have in Shop Name: DiiliHiiri.fi .. I don't understand :(

 

The correct shop ID is 8, and the first shop ID is 1.

Edited by clubvapea (see edit history)
Link to comment
Share on other sites

 

What about ps_configuration table content in database?

Could you execute the following query?

SELECT * FROM ps_configuration WHERE name = "PS_SHOP_NAME"

Gives me very weird results:

delete.JPG

It is completely missing one shop, and the shop called DiiliHiiri was deleted already. And DiiliHiiri.fi should be shop id 8

 

Alternative eventuality: did you check anyway if there is a file /override/classes/Mail.php?

It could callback native Mail class after changing id_shop in some cases (e.g. shop context is All Shops)

You can add var_dump($id_shop); in Mail.php to detect this...

No, theres no override. When I added only var_dump in mail.php, I didn't get any result displayed.. 

Edited by clubvapea (see edit history)
Link to comment
Share on other sites

IMO

1. Having edited ps_configuration in that way should not be an issue.

2. Keep PS_SHOP_NAME for id_shop_group = NULL and id_shop = NULL as the default value (you can change the value).

3. You could add manually PS_SHOP_NAME for any group and shop (especially 1, 1) but it should be done automatically if you force saving from BO > Preferences > Store Contacts > Contact Details > Shop name

Link to comment
Share on other sites

  • 2 weeks later...

IMO

1. Having edited ps_configuration in that way should not be an issue.

2. Keep PS_SHOP_NAME for id_shop_group = NULL and id_shop = NULL as the default value (you can change the value).

3. You could add manually PS_SHOP_NAME for any group and shop (especially 1, 1) but it should be done automatically if you force saving from BO > Preferences > Store Contacts > Contact Details > Shop name

Hi, the problem returned. I have 4 shops. 

SHOP GROUP - SHOP NUMBER - FIELD - SHOP NAME

          1 6 PS_SHOP_NAME

DiiliHiiri

 

              2 8 PS_SHOP_NAME

DiiliHiiri.fi

 

              1 2 PS_SHOP_NAME

Nesteet.com

 

              1 1 PS_SHOP_NAME

ClubVapea.es

 

 

And default shop number is 1. If I select "all shops" it sends the email with the default shops name, not with the shop where the order was placed at. 

I dont understand this part "Keep PS_SHOP_NAME for id_shop_group = NULL and id_shop = NULL as the default value (you can change the value)."

It doesnt let me put id_shop_group NULL, it need to be a value...

Thanks for your help!

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...