Jump to content

Auto email after set tracking number


Recommended Posts

sorry about that...

 

you would need to update (assuming again 1.5)

 

controllers/admin/AdminOrdersControllers to not send the email.

 

here is the code in a 1.5.4.1, you would need to find the same/similar code for your version and eliminate the mail send

 /* Update shipping number */
 if (Tools::isSubmit('submitShippingNumber') && isset($order))
 {
  if ($this->tabAccess['edit'] === '1')
  {
   $order_carrier = new OrderCarrier(Tools::getValue('id_order_carrier'));
   if (!Validate::isLoadedObject($order_carrier))
 $this->errors[] = Tools::displayError('The order carrier ID is invalid.');
   elseif (!Validate::isTrackingNumber(Tools::getValue('tracking_number')))
 $this->errors[] = Tools::displayError('The tracking number is incorrect.');
   else
   {
 // update shipping number
 // Keep these two following lines for backward compatibility, remove on 1.6 version
 $order->shipping_number = Tools::getValue('tracking_number');
 $order->update();
 // Update order_carrier
 $order_carrier->tracking_number = pSQL(Tools::getValue('tracking_number'));
 if ($order_carrier->update())
 {
  // Send mail to customer
  $customer = new Customer((int)$order->id_customer);
  $carrier = new Carrier((int)$order->id_carrier, $order->id_lang);
  if (!Validate::isLoadedObject($customer))
   throw new PrestaShopException('Can\'t load Customer object');
  if (!Validate::isLoadedObject($carrier))
   throw new PrestaShopException('Can\'t load Carrier object');
  $templateVars = array(
   '{followup}' => str_replace('@', $order->shipping_number, $carrier->url),
   '{firstname}' => $customer->firstname,
   '{lastname}' => $customer->lastname,
   '{id_order}' => $order->id,
   '{shipping_number}' => $order->shipping_number,
   '{order_name}' => $order->getUniqReference()
  );
  if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
   $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
   _PS_MAIL_DIR_, true, (int)$order->id_shop))
  {
   Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order));
   Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
  }
  else
   $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
 }
 else
  $this->errors[] = Tools::displayError('The order carrier cannot be updated.');
   }
  }
  else
   $this->errors[] = Tools::displayError('You do not have permission to edit this.');
 }

Link to comment
Share on other sites

try this (untested)

 

find

	                     	 if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
                           $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
                           _PS_MAIL_DIR_, true, (int)$order->id_shop))
                       {
                           Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order));
                           Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
                       }
                       else
                           $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');

 

change to this:

//	   if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
//	    $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
//	    _PS_MAIL_DIR_, true, (int)$order->id_shop))
//	   {
    Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order));
    Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
//	   }
//	   else
//	    $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

HI friends,

 

I'm using stamps pro to print the labels. When i print a label the tracking number is not updated in the webstore. The stamps.com doc says

"Stamps.com will automatically post back to your web store and shopping cart account information data like tracking number and shipping cost. This allows you to easily let your customers know that an order has shipped."

 

All i want to know is how can i insert the tracking number in my webstore after i print the label frm the stamps pro software automatically

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

Dear El Patron,

 

Thanks for providing this solution here.

I would also like to disable the automatically sent e-mail after filling in a tracking number.

 

I am using 1.5.5.0

tried to edit AdminOrdersController.php , but I can't find the exact text which you specifiy in this topic.

 

However, I do see this code, can you point me in the right direction how to change this ?

 

 

 

/* Update shipping number */
if (Tools::isSubmit('submitShippingNumber') && isset($order))
{
if ($this->tabAccess['edit'] === '1')
{
$order_carrier = new OrderCarrier(Tools::getValue('id_order_carrier'));
if (!Validate::isLoadedObject($order_carrier))
$this->errors[] = Tools::displayError('The order carrier ID is invalid.');
elseif (!Validate::isTrackingNumber(Tools::getValue('tracking_number')))
$this->errors[] = Tools::displayError('The tracking number is incorrect.');
else
{
// update shipping number
// Keep these two following lines for backward compatibility, remove on 1.6 version
$order->shipping_number = Tools::getValue('tracking_number');
$order->update();
 
// Update order_carrier
$order_carrier->tracking_number = pSQL(Tools::getValue('tracking_number'));
if ($order_carrier->update())
{
// Send mail to customer
$customer = new Customer((int)$order->id_customer);
$carrier = new Carrier((int)$order->id_carrier, $order->id_lang);
if (!Validate::isLoadedObject($customer))
throw new PrestaShopException('Can\'t load Customer object');
if (!Validate::isLoadedObject($carrier))
throw new PrestaShopException('Can\'t load Carrier object');
$templateVars = array(
'{followup}' => str_replace('@', $order->shipping_number, $carrier->url),
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{id_order}' => $order->id,
'{shipping_number}' => $order->shipping_number,
'{order_name}' => $order->getUniqReference()
);
if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit'), $templateVars,
$customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
_PS_MAIL_DIR_, true, (int)$order->id_shop))
{
Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order, 'customer' => $customer, 'carrier' => $carrier));
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
}
else
$this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
}
else
$this->errors[] = Tools::displayError('The order carrier cannot be updated.');
}
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
Edited by Roby42 (see edit history)
Link to comment
Share on other sites

  • 5 weeks later...

 

Dear El Patron,

 

Thanks for providing this solution here.

I would also like to disable the automatically sent e-mail after filling in a tracking number.

 

I am using 1.5.5.0

tried to edit AdminOrdersController.php , but I can't find the exact text which you specifiy in this topic.

 

However, I do see this code, can you point me in the right direction how to change this ?

 

 

 

/* Update shipping number */
if (Tools::isSubmit('submitShippingNumber') && isset($order))
{
if ($this->tabAccess['edit'] === '1')
{
$order_carrier = new OrderCarrier(Tools::getValue('id_order_carrier'));
if (!Validate::isLoadedObject($order_carrier))
$this->errors[] = Tools::displayError('The order carrier ID is invalid.');
elseif (!Validate::isTrackingNumber(Tools::getValue('tracking_number')))
$this->errors[] = Tools::displayError('The tracking number is incorrect.');
else
{
// update shipping number
// Keep these two following lines for backward compatibility, remove on 1.6 version
$order->shipping_number = Tools::getValue('tracking_number');
$order->update();
 
// Update order_carrier
$order_carrier->tracking_number = pSQL(Tools::getValue('tracking_number'));
if ($order_carrier->update())
{
// Send mail to customer
$customer = new Customer((int)$order->id_customer);
$carrier = new Carrier((int)$order->id_carrier, $order->id_lang);
if (!Validate::isLoadedObject($customer))
throw new PrestaShopException('Can\'t load Customer object');
if (!Validate::isLoadedObject($carrier))
throw new PrestaShopException('Can\'t load Carrier object');
$templateVars = array(
'{followup}' => str_replace('@', $order->shipping_number, $carrier->url),
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{id_order}' => $order->id,
'{shipping_number}' => $order->shipping_number,
'{order_name}' => $order->getUniqReference()
);
if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit'), $templateVars,
$customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
_PS_MAIL_DIR_, true, (int)$order->id_shop))
{
Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order, 'customer' => $customer, 'carrier' => $carrier));
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
}
else
$this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
}
else
$this->errors[] = Tools::displayError('The order carrier cannot be updated.');
}
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}

 

 

Check the codes in line 309 to 317? They look the same as what El Patron pointed out.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...

I'd suggest opening a new post for that question.

When we manually add tracking number using add tracking option on oreser page PS 1.6.0.11 then how can we display Tracking number in email transit email currently its appearing as {shipping_number} i changed to {trascking_number} but still same trascking URl is displaying as Ia dded to carrier setup page.

Thanks

Link to comment
Share on other sites

  • 8 months later...

try this (untested)

 

find

		                     	 if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
                            $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
                            _PS_MAIL_DIR_, true, (int)$order->id_shop))
                        {
                            Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order));
                            Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
                        }
                        else
                            $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
 
change to this:

//	   if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
//	    $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
//	    _PS_MAIL_DIR_, true, (int)$order->id_shop))
//	   {
	    Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order));
	    Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
//	   }
//	   else
//	    $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');

Hi, 

 

How do I fix this on 1.6.0.14? Your code does not seem to work there. Either the submit button does not work or I get a blank page

 

Thank you

Link to comment
Share on other sites

×
×
  • Create New...