Send Tracking number in order status notification

  • Posts: 165
  • Thank you received: 3
8 years 7 months ago #236927

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.5.1

Hi, I have read through this forum but I still cannot seem to get this to work. I have a custom field for my orders with a column name of tracking_number. I got this to show up perfectly on the order page itself in the customer admin section of the site. However, I want to have the tracking number sent when I change the status to shipped on an order and have the tracking number displayed in the order status notification email. I have tried reading this below and using the below code but it does not work. The problem is this looks like something that goes into the text version of the email and I am using the HTML Version of the emails. How can I achieve using A UPS tracking number that is linkable to their site in the order status notification email using the HTML Version of the email?
www.hikashop.com/forum/shipping-methods/...ed-order-status.html

<?php
$shippingClass = hikashop_get('class.shipping');
$shipping_name = '';
if(!is_numeric($data->cart->order_shipping_id)){
$shipping_name=$shippingClass->getShippingName($data->cart->order_shipping_method,$data->cart->order_shipping_id);
}
if($shipping_name == 'shipped'){
echo '<a href=" wwwapps.ups.com/WebTracking/track?track=yes&trackNums='.$data- >order->tracking_number.'&P='.$data->order->zip_code.'" target="_blank"><strong>'.$data->order->tracking_number.'</strong></a>';
}else{
echo 'You can track your shipment with ups, by clicking this url wwwapps.ups.com/WebTracking/track?track=yes&trackNums='.$data- >order->tracking_number.'<br/>Your tracking number is '.$data->order->tracking_number;
}
?>

Thanks,

Josh

Last edit: 8 years 7 months ago by jschroeder.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 7 months ago #236940

Hi,

To display tracking number or text in email notification I use this code which is added to HTML version:

<?php                       
if($data->order_status == 'shipped'){
?><?php echo JText::_( 'CUSTOM_SHIPPING_MESSAGE' ); ?><br><span style="color:#1c8faf !important;font-size:12px;font-weight:bold;"><?php echo JText::_( 'CUSTOM_TRACKING_INFO_SUBJECT' ); ?></span><a href="<?php echo JText::_( 'CUSTOM_POST_HYPERLINK' ); ?>{VAR:order.tracking_number}" target="_blank">{VAR:tracking_number}</a><br>
<span style="color:#1c8faf !important;font-size:12px;font-weight:bold;"><?php echo JText::_( 'CUSTOM_POSTAGE_DATA' ); ?></span><?php echo $data->cart->postage_date;
} 
?>

Tracking number is displayed as hyperlink....
'CUSTOM_POST_HYPERLINK' = is joomla translation override, I added there my postage service tracking link, in your case it will be UPS
You can modify it to your needs.

Hope that helps.

Thanks

Last edit: 8 years 7 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #236959

Hi,

Yes, that code is much better. Here is my take on that:

<?php
if($data->cart->order_status=='shipped'){
echo  'Your tracking number is <a href="wwwapps.ups.com/WebTracking/track?track=yes&trackNums='.$data->cart->tracking_number.'&P='.$data->cart->shipping_address->address_post_code.'" target="_blank"><strong>'.$data->cart->tracking_number.'</strong></a>';
} ?>
That code can be added in the HTML version, that's not a problem.

Please Log in or Create an account to join the conversation.

  • Posts: 165
  • Thank you received: 3
8 years 7 months ago #237849

nicolas wrote: Hi,

Yes, that code is much better. Here is my take on that:

<?php
if($data->cart->order_status=='shipped'){
echo  'Your tracking number is <a href="wwwapps.ups.com/WebTracking/track?track=yes&trackNums='.$data->cart->tracking_number.'&P='.$data->cart->shipping_address->address_post_code.'" target="_blank"><strong>'.$data->cart->tracking_number.'</strong></a>';
} ?>
That code can be added in the HTML version, that's not a problem.


Thank you so much it worked perfectly!

Please Log in or Create an account to join the conversation.

  • Posts: 585
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
8 years 5 months ago #241123

Hi Nicolas,

Am I correct that this code isn't working anymore in version 2.6.3 and higher
I see no UPS URL appear in the e-mail.

I only see the tracking number appear (on a new line with the name of the field), but that is because I set the custom field (type: order) Display to YES for Order Status notification. So since 2.6.3 it is automatically inserted in to the e-mail.

Unfortunately this tracking number is also displayed when you set order status back to to confirmed.
I only want to display it when you set it to shipped and not on a new line with the name of the field before it.
Just like you designed the code ;-)

I hope you can take a look at it.

Kind regards,
Lumiga


Kind regards,
Lumiga
Last edit: 8 years 5 months ago by Lumiga.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #241219

Hi,

You should keep the display option in the email turned off since that code will do the display instead, and only for the shipped orders.

That code still works fine with the 2.6.3
If you don't see the tracking number text from that code, it's either that the status of the order is not "shipped", or that you didn't add the code to the correct email. That's all I can think of.

Please Log in or Create an account to join the conversation.

  • Posts: 585
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
8 years 5 months ago #242459

Hi Nicolas,

I think there is a bug. I have tested it over and over again.
This code only works when you set the display option from the tracking_number in the email turned on.
For me this is the only custom field I use for the table 'order'.

I have tested it with this simple code:

<?php
{
echo  'test';
} ?>

I put this simple code at the end of this code:
<h1 style="color:#ac5d62 !important;font-size:16px;font-weight:bold;border-bottom:1px solid #ddd;padding-top:10px;padding-bottom:10px;">
	{TXT:ADDITIONAL_INFORMATION}
</h1>

Hopefully you can help me with this code.

See you on Saturday at Breda! ;-)

Kind regards,
Lumiga


Kind regards,
Lumiga
Last edit: 8 years 5 months ago by Lumiga.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #242467

Hi,

That code does work. So either your order status is not "shipped", or your not editing the correct email, as I said in my previous email.
Bring your laptop and I'll have a look with you on Saturday.

Please Log in or Create an account to join the conversation.

  • Posts: 585
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
8 years 5 months ago #242981

Hi Nicolas,

Thanks for your help in Breda! It was a nice day.

The code is fine now but the problem is that the status of the order must be shipped BEFORE Hikashop is sending this Track & Trace information.

But, when your order is confirmed and you want to send the customer an email (from the orders list view: Component>Hikashop>Orders) to change the order status to shipped and notify customer to YES. Then Hikashop doesn't sent the Track & Trace code.

But after that, every status change is getting the Track & Trace code. Also refunded and that’s not to supposed to be.

So my conclusion is: The code works fine but it doesn't sent the Track & Trace code on the right moment when your change you order from confirmed to shipping. So a workaround is to change the code with the status 'confirmed'. But in that case it's also sending Track & Trace code if you change your order to cancelled or refunded.

So the question is:
Is there some sort of code that is will only sent this Track & Trace code (regardless of the current status) when you change the status to shipped?

Second question: In none of above cases the Track & Trace code is displayed (emailed) when you manually send the email from the single product order view. Is there a way to let this email also send the Track & trace code?

Kind regards,
Lumiga


Kind regards,
Lumiga

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #242997

Hi,

This issue is this:
When you change the status of the order from the order listing, it opens a popup and when you turn on the "notify customer" option there, it displays you the email that will be sent. The problem here is that the order status in the database hasn't been changed yet in the database.
To circumvent that, you have two solutions:
1. You change the status of the order from the order details page. There, the email content is loaded after the order status is changed in the database.
2. In your customized code, instead of :
if($data->cart->order_status=='shipped'){
use:
if(@$data->order_status=='shipped'){
and that should work fine regardless from where you send the email.

The following user(s) said Thank You: Lumiga

Please Log in or Create an account to join the conversation.

  • Posts: 585
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
8 years 5 months ago #243121

Hi Nicolas,

Thanks for your answer. Everything works fine now. ;)

But regarding point 1 and 2, in both situations there is no Track & Trace code sent if you choose the Email button from the order details page on the top beside the invoice and shipping invoice button.

Can you please explain why this is?



Kind regards,
Lumiga


Kind regards,
Lumiga
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 5 months ago #243143

Hi,

That's because it uses the "order notification" email, not the "order status notification" email.
You would have to edit that email code too.

The following user(s) said Thank You: Lumiga

Please Log in or Create an account to join the conversation.

Time to create page: 0.103 seconds
Powered by Kunena Forum