Jump to content

{meta_products} variable of "in_transit" mail not working


maalik

Recommended Posts

Hello,

I'M using Prestashop 8.2.0. When sending an email with the template "in_transit", the variable "{meta_products}" will just be send as it is. It won't be converted to any other text.

Is this intended? Did I make an error? Or is this a bug?

 

Is there a list of the existing variables, so that I can check, what actually stands behind a variabel?

 

Additional hint, don't know if that changes anything: I changed the email template for the status change of "shipped" to the template "in_transit"

 

Thanks

Link to comment
Share on other sites

Hey Daresh,

 

thanks for the quick reply. It helped me figure out where the problem is: I changed the OrderCarrier.php, so that no E-Mail will be sent, when adding the shipping number in the backend. This also led to the metadata variable not being generated.

 

My OrderCarrier.php currently looks like this:

 

<?php
/**
 * OrderCarrier override : disable in_transit emails
 *
 */
defined('_PS_VERSION_') or die;
class OrderCarrier extends OrderCarrierCore
{
    /**
     * @param Order $order Required
     *
     * @return bool
     */
    public function sendInTransitEmail($order)
    {
        return true;
    }
}

 

 

Do you know, how I can change the original file, so that the metadata variable will be generated, but NO email is send, when adding the shipping number?

 

Will it be enough to comment out this block?
 

        if (@Mail::Send(
            $orderLanguageId,
            'in_transit',
            $this->trans(
                'Package in transit',
                [],
                'Emails.Subject',
                $orderLanguage->locale
            ),
            $templateVars,
            $customer->email,
            $customer->firstname . ' ' . $customer->lastname,
            null,
            null,
            null,
            null,
            _PS_MAIL_DIR_,
            true,
            (int) $order->id_shop
        )) {
            return true;
        } else {
            return false;
        }

 

Or this?

$sendemail = (bool) Tools::getValue('sendemail', false);

 

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

I use the in_transit template, when I change the status of an order to "shipped".
The default "shipped" template contains neither the order-details nor the shipping number.

Link to comment
Share on other sites

I don't quite understand your answer unfortunately. What do you mean with "there is no metadata variable".

 

To sum up, what I'm trying to do:
1) I don't want an email to be sent out, when I add the shipping number in the backend.
2) I want the the mail, that gets send when I change the order to "Shipped" to include the shipping url ({followup}) aswell as the articles of the order.

What would be the best way to achieve this?

Link to comment
Share on other sites

Your case is quite common, but it may require some more coding or some additional modules.

PrestaShop simply sends totally different sets of email templates to the emails.

So you can't just switch one email template to another assuming the other one will have all the variables set.

Link to comment
Share on other sites

Okay. So in order to get the {meta_products} variable to work again, I need to revert the changes in OrderCarrier.php, so that it contains the code for the creation of the variable. 
Which line would be best to comment out in OrderCarrier.php then, to disable the email being send?

 

(sorry, if this is a repetition, but i can't quite keep up with the technical detail of your answers)

Link to comment
Share on other sites

Nope, you're wrong.

If you want to have the {meta_products} variable set for any email related to a general order status change, you would need to change OrderHistory.php and add some code there that will gather all the required information.

Link to comment
Share on other sites

I think I understand now. I need to use the OrderHistory, because it handles the status changes; the OrderCarrier file only handles the carrier(shipping) related changes, right?

I think I will just drop the {meta_products} variable then, my PHP knowledge is not that high unfortunately.

Link to comment
Share on other sites

Yes, now you got it! :)

Changing core is generally not a good practice, so dropping that variable may be a good decision here.

And if you would like to block the 'in_transit' email from being sent without any core modifications, I have a module that can do this task: Email Toolbox

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