Display text depending on shipping method

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

Hi,

I need to show text in email order status notification depending on shipping method and order status. Is this possible? What code I could use?

I use this code below to display text depending of the order status.

<?php                       
if($data->order_status == 'shipped'){
?><?php echo JText::_( 'CUSTOM_SHIPPING_MESSAGE_END' ); }?>
Regards

Last edit: 8 years 7 months ago by kyratn.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 7 months ago #234673

Hi,

You can use such code:

if($data->order_status == 'shipped' && $data->cart->order_shipping_id==XXX){
//my code
}
where XXX is the id of the shipping method for which you want to display something.

The following user(s) said Thank You: kyratn

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

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

Thank you Nicolas

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

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

Hi,

This is the code i use to display text in order/listing view depending on order status.

     <?php 
							
		 $url = JText::_( 'CUSTOM_POST_HYPERLINK' );
	         $url2 = JText::_( 'ORDER_TRACKING_AWAITING_PAYMENT' );
	         $url3 = JText::_( 'ORDER_TRACKING_AWAITING_SHIPMENT' );
		 $url4 = JText::_( 'NO_ORDER_TRACKING_NUMBER' );
								
		   if($row->order_status == 'shipped'){
	
		     echo '<a href="'.$url. $row->siuntosnumeris.'" target="_blank">'. $row->siuntosnumeris. '</a>';

                        }elseif ($row->order_status == 'created'){
							
		    echo '<span class="hikashop_order_listing_status hikashop_order_status_created">'.$url2.'</span>';
							
			}elseif ($row->order_status == 'confirmed'){
							
		    echo '<span class="hikashop_order_listing_status hikashop_order_status_confirmed">'.$url3.'</span>';
							
			}elseif ($row->order_status == 'refunded'){
							
		    echo '<span class="hikashop_order_listing_status hikashop_order_status_refunded">'.$url4.'</span>';
							
			}elseif ($row->order_status == 'cancelled'){
							
		    echo '<span class="hikashop_order_listing_status hikashop_order_status_cancelled">'.$url4.'</span>';

			 }else{

		     echo JText::_( 'NO_ORDER_TRACKING_NUMBER' );

	 } ?>

Now, how can i display text depending on order status + payment method or shipping method?

Tried something like this:
}elseif ($row->order_status == 'created' && $row->order_payment_id== 8){
							
	echo '<span class="hikashop_order_listing_status hikashop_order_status_created">'.$url3.'</span>';

Or this:
}elseif ($row->order_status == 'created' && $data->cart->order_shipping_id==XXX){
							
	echo '<span class="hikashop_order_listing_status hikashop_order_status_created">'.$url3.'</span>';

But none worked.

Maybe because i do change payment method manually in back-end? Just to see if it works....

Also, where i could find payment or shipping id's? I only could see it with firebug...

Regards

Last edit: 8 years 7 months ago by kyratn.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 7 months ago #237102

Hi,

It should be that:

}elseif ($data->cart->order_status == 'created' && $data->cart->order_shipping_id==XXX){

You can see the id of a payment/shipping method at the end of the URL in the address bar when you edit it in the backend.

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

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

Hi,

Are you sure this is correct code?
I tried to add this:

}elseif ($data->cart->order_status == 'created' && $data->cart->order_shipping_id==17){

                            echo '<span class="hikashop_order_listing_status hikashop_order_status_confirmed">'.$url3.'</span>';

And it didn't work.
So just to check I have changed in my code above from this:
$row->order_status == 'created'

to this:
$data->cart->order_status == 'created'

and it doesn't work anymore...

It seems $row is working but not $data
What is the difference?

I am trying to display text in order listing view file....

Thank you

Last edit: 8 years 7 months ago by kyratn.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 7 months ago #237352

Hi,

I thought that you were in the order notification email.
On the order listing, then yes it's $row->order_status and $row->order_shipping_id
Just do a var_dump() of $row and you can see all the available variables for it.

The following user(s) said Thank You: kyratn

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

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

Now it works.

Thank you

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

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

Nicolas can you help me once more please?

I am trying to add text in email notification. first text depending on status and second text depending on status + payment method
but it seems elseif isn't working for me and I am not sure why and what I am doing wrong.
Here is the code:

<?php                       
if($data->cart->order_status == 'shipped'  && $data->cart->order_payment_id==18){
 echo JText::_( 'CUSTOM_SHIPPING_MESSAGE');
}elseif ($data->cart->order_status == 'shipped'){
 echo JText::_( 'CUSTOM_SHIPPING_MESSAGE_CASH' );
}
?>

As I have 4 payment methods I need display other text for orders with one of these payment methods

Thank you

Last edit: 3 years 2 weeks ago by nicolas. Reason: fixed code

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 7 months ago #237553

Hi,

On the elseif you're using $data->order_status instead of $data->cart->order_status
That's all I can see in your code.

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

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

Ahh, my bad. Seems i am blind...

Thank you Nicolas

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

Time to create page: 0.077 seconds
Powered by Kunena Forum