Jump to content

Send order status change email from URL


razvy

Recommended Posts

Hi,

 

Thank to the contribution of Guest, I have I can change the status and the tracking number of an order just by accessing an URL like:

http://www.mydomain.com/change-order-state.php?order=6354&state=4&tracking_no=xxx&secure_key=123456

The thing is that this tool sends the "shipped" email to the customer, but the tracking URL does not show, it only shows "{followup}".

However, if I send the "shipped" email from the backoffice, the tracking URL is showe instead of the text "{followup}" and the customer can click on it in order to track the parcel.

I need someone to change the code in order to send the "shipped" email with a WORKING tracking URL insstead of the "{followup}" text.

 

Here is the php file I'm using:

<?php

  include('./config/config.inc.php');
  include('./config/settings.inc.php');
  
  $my_secure_key = '123456';
  $secure_key = isset($_GET['secure_key']) ? $_GET['secure_key'] : '';
  $get_order = isset($_GET['order']) ? $_GET['order'] : '';
  $get_state = isset($_GET['state']) ? $_GET['state'] : '';
  $tracking_number = isset($_GET['tracking_no']) ? $_GET['tracking_no'] : '';
  $get_current_state = '';
  
  if ($get_order) {
    $get_current_state = Db::getInstance()->getValue('SELECT current_state FROM '._DB_PREFIX_.'orders WHERE id_order = '.$get_order); 
  }
  
  if ( ($get_current_state == $get_state) || (empty($get_current_state)) ) {exit("New order status is the same or empty");}
  echo 'tracking number: '.$tracking_number.'<br />order id: '.$get_order.'<br />order state: '.$get_state;

  $email_enable = Db::getInstance()->getValue('SELECT send_email FROM '._DB_PREFIX_.'order_state WHERE id_order_state = '.$get_state);
  
  if ( ($my_secure_key == $secure_key) && ($get_order) && ($get_state) ) {
  
      
      if ($tracking_number) {
          Db::getInstance()->Execute("UPDATE "._DB_PREFIX_."order_carrier SET tracking_number = '".$tracking_number."' WHERE id_order = ".$get_order);
          Db::getInstance()->Execute("UPDATE "._DB_PREFIX_."orders SET shipping_number = '".$tracking_number."' WHERE id_order = ".$get_order);
      }    
                   
      $order = new Order($get_order);
      $history  = new OrderHistory();
      $history->id_order = (int)$order->id;
      $history->changeIdOrderState((int) $get_state, $order->id);
      
      if ($email_enable == '1') {
          $history->addWithemail(true);
      }
                
      $history->save();
 
  }

 

Thank you.

Link to comment
Share on other sites

Send status by status id?
For some emails, parameters must be sent.
I don't know the whole story.
Will you send data to my script via Windows and VB script?
Too little information.

Link to comment
Share on other sites

Yes, send status by status id.

In fact I just need it to change the status to "shipped" ,and update the tracking nyumber, but I need it to send the "shipped" email in the same time, wich MUST include the tracking URL.

I don't want to use VB, but an URL with parameters.

Link to comment
Share on other sites

  • 9 months later...

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