Jump to content

send tracking number in shipped mail


info@babylinoshop.co

Recommended Posts

Hi,

I just managed to modify order status via a php script and sending email confirmation automatically, but I'm actually trying to improve this adding tracking number in same mail template.

the issue is that {shipping_number} tag added in template doesn't catch information and it appears like text, does anyone have idea of what's happening? the tracking number is properly set on BO and DB, but none in mail template.

 

the script code just for a single order in order to simplify it) is:

 

$objOrder = new Order(73); /for order 73 as an example
$shipping_number = 12345;
$order_carrier = new OrderCarrier(73);
$order_carrier->tracking_number = $shipping_number;
$order_carrier->update();
$objOrder->shipping_number = $shipping_number;
//tried both objOrder shipping_number and order_carrier tracking_number
 
$history = new OrderHistory();
$history->id_order = (int)$objOrder->id;
$history->changeIdOrderState(4, (int)($objOrder->id));
$history->addWithemail(true);
 
the controller AdminOrdersController includes value '{shipping_number}' => $order->shipping_number, in templateVars array, so it should catch the value.
 
thanks in advance
 
regard
 
Francesca
Link to comment
Share on other sites

  • 2 weeks later...

I'm actually testing a solution, it seems everything works now but of course it needs to be optimized yet; herebelow the code:

 

$objOrder = new Order($update);  
$shipping_number = 1; //fixed test number, it should receive a variable number from somewhere else in the preceding code
$order_carrier = new OrderCarrier($update);
$order_carrier->tracking_number = $shipping_number;
$order_carrier->update();  //updates la  ps_carrier table in db
$objOrder->shipping_number = $shipping_number;  //upates ps_orders table in db
$template_vars = array('{shipping_number}' => $shipping_number); //creates a new parameter to be sent in addWithemail
$history = new OrderHistory();   
$history->id_order = (int)$objOrder->id;
$history->changeIdOrderState(4, (int)($objOrder->id));   //changes order state, actually 4
$history->addWithemail(true,$template_vars);   //isends mail including shipping_number value
 
 
hope this helps you a little
 
ciao
  • Like 1
Link to comment
Share on other sites

  • 3 years later...

Hello, I am adding some code to send tracking number to the customer. Of course, It could be improved.

 $Order = new Order();
        $orders = Order::getByReference($reference);
//better Check if reference exists
        $objOrder = $orders[0];
        $shipping_number = 12222; //fixed test number, it should receive a variable number from somewhere else in the preceding code
        $order_carrier = new OrderCarrier((int)$objOrder->id);
        $order_carrier->tracking_number = $shipping_number;
        $order_carrier->update();  //updates la  ps_carrier table in db
        $objOrder->shipping_number = $shipping_number;  //upates ps_orders table in db
        $template_vars = array('{shipping_number}' => $shipping_number); //creates a new parameter to be sent in addWithemail
        $history = new OrderHistory();   
        $history->id_order = (int)$objOrder->id;
        $history->changeIdOrderState(STATUS_SEND_IS_4, (int)($objOrder->id));   //changes order state, actually 4
        $history->addWithemail(true,$template_vars);   //isends mail sent
        
        if ($order_carrier->sendInTransitEmail($objOrder)) {
            $customer = new Customer((int)$objOrder->id_customer);
            $carrier = new Carrier((int)$objOrder->id_carrier, $objOrder->id_lang);

        }

 

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