phpprestashop-1.6trustpilot

Prestashop 1.6.1.13 and TrustPilot SFA 2.0 service


I followed the help guide to integrate SFA of trustpilot into prestashop, bt their guide is based on sending order confirmation. When order confirmation is sent the trustpilot servie receive a bcc email and add to sending queue the email to ask for a review. The problem could be:

1) Order done but failed payment > mail sent anyway 2) Order done and payed ok but customer wanna delete the order > email already sent

So the solution is to send a bcc email when shipped status of order is reached. When shipped status is manually changed by backoffice operator the customer will receive the shipped template email.

I'm not an expert on prestashop overriding and programming so ii try to make an override to mail.php class like this one:

<?php

class Mail extends MailCore
{

public static function Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
{
    // add trustpilot SFA 2.0
    if($template == 'shipped')
    {
        $bcc->addBcc('*********@invite.trustpilot.com');
    }      

    // send to customer
    $ret = parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc, $reply_to);
    return $ret;
}
?>

I don't know if it is correct, but before creating a chaos i would like any help :)

Thank you


Solution

  • i ended with thsi working solution. I post here the code so if someone need this way is working:

    <?php
    /*
     MODIFIED VERSION TO SUPPORT TRUSTPILOT SEND ON SHIPPED STATUS CHANGE
    */
    
    class Mail extends MailCore
    {
    
        public static function Send($id_lang, $template, $subject, $template_vars, $to,
            $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
            $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
        {
    
            if($template == 'shipped') { $bcc = array('xxxx@invite.trustpilot.com'); }
    
            return parent::Send($id_lang, $template, $subject, $template_vars, $to,
                $to_name, $from, $from_name, $file_attachment, $mode_smtp,
                $template_path, $die, $id_shop, $bcc, $reply_to);
    
        }
    
    }
    

    Now i've only one problem: the shipped.html don0't have the {mail} placeholder. How i can override the AdminOrdersController.php to let me allow to add a new {mail} placeholder in the mail template?

    Ty