VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: dirkb on May 06, 2019, 13:24:27 PM

Title: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 06, 2019, 13:24:27 PM
Hi.

Using latest Joomla and VM 3.4.2

Before, with older versions of VM I could get the order descrption with language override into the shopper mail via override.

Using language override [COM_VIRTUEMART_ORDER_STATUS_EXPECT_PAYMENT_DESC] in description field.

and ... mail_html_shopper.php

<?php echo vmText::_($this->orderDetails['details']['BT']->order_status_description) ; ?>

Now, that seems not to work anymore. With and without editor, resave etc. ... does not show.
How can I achieve that again ?

Any ideas ? The order description is vital for user communication.

thanks d.
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Studio 42 on May 06, 2019, 17:29:20 PM
Try to add override in admin + front end for COM_VIRTUEMART_ORDER_STATUS_EXPECT_PAYMENT_DESC
If you change order statut in the admin, the language override key is get from admin
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 07, 2019, 09:16:05 AM
Hi. Thanks for responding.

The issue is not the language Tag itself. If I put [COM_VIRTUEMART_ORDER_STATUS_EXPECT_PAYMENT_DESC] directly in the mail_html_shopper.php, it shows.
But the order description is conditional, I do have 5 different order status, each has its own description. In the order description is the language tag above.

This one I called before with <?php echo vmText::_($this->orderDetails['details']['BT']->order_status_description) ; ?>

That is not working anymore ? Could it be that now virtuemart shows the editor for the order status description (before it did not have the editor there) and therefore modifies the language tag code ?

Hmmm ...lost on that one. Anybody some advice ?
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Jörgen on May 07, 2019, 10:01:01 AM
You have to look it up in the database:
// Get the order status description
$order_status = $this->orderDetails['details']['BT']->order_status;
// Get a database connection.
$db = JFactory::getDbo();
$query = 'SELECT `order_status_description` FROM `#__virtuemart_orderstates` WHERE `order_status_code` = ' . $db->quote($order_status);
$db->setQuery($query);
$order_status_description = $db->loadResult();


Jörgen @ Kreativ Fotografi
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 07, 2019, 10:15:39 AM
Hi. Also, thanks for your reply.
Not sure what to make with your advice resp. code ?

Do I need to include it top in my mail_html_shopper.php to load the order status description ?

Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Studio 42 on May 07, 2019, 12:03:12 PM
If you need it, then add the code provided by Jorgen before in the same file
But you can create the description using language override.
eg.
$order_status_description_key = 'ORDER_STATUS_ '.$this->orderDetails['details']['BT']->order_status.'_DESC';
echo vmText::_($order_status_description_key);



Then you add the language overrides
ORDER_STATUS_ P_DESC="Pending description"ORDER_STATUS_ C_DESC="Cancel description"
....

Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Jörgen on May 07, 2019, 13:25:56 PM
@patrick
Nice solution, didn´t think about that.

@dirkb
Both our solutions must be wrapped with the vmText exactly as Patrick has shown. That makes Patrick's solution the more elegant one :)

Jörgen @ Kreativ Fotografi
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 07, 2019, 13:26:47 PM
Hi Jörgen und Studio.

I did not get the code from Jörgen to work.
The Tip from Studio 42 worked, kind of, the language constanst showed up, but not the translation.
The order status gets translated, the order status description does not.

See screen attached.
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Jörgen on May 07, 2019, 13:30:27 PM
Why are You using brackets ? Get rid of them.

Jörgen @ Kreativ Fotografi
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 07, 2019, 13:49:28 PM
Ooops ... not sure where the brackets came from.

Did remove them, but still, the same issue. Could it be that I have to modify the database field type for the order description to display "raw" data ?

See Screen for what I have now. Order Status cap, language override cap and email coming in cap.

I'm lost ?!
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Jörgen on May 07, 2019, 14:51:27 PM
If You use this line to output :
echo vmText::_($order_status_description_key);

Then You should be good.

But I think You have a  somewhere, maybe before the L.

Jörgen @ Kreativ Fotografi
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Studio 42 on May 07, 2019, 15:00:06 PM
If you use this solution
$order_status_description_key = 'ORDER_STATUS_ '.$this->orderDetails['details']['BT']->order_status.'_DESC';
echo vmText::_($order_status_description_key);
Then you need to add the language keys
ORDER_STATUS_X_DESC
Where X is the order_status Key
If the key is not translate in all cases, then you need to add override in Joomla language FRONT+ADMIN overrides!
Because when you generate the order in admin, the admin Keys are used for overrides and not front
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 07, 2019, 15:30:08 PM
Hi. Again, thanks to both of you for helping.

Below my steps in the screen.

One part of the code at the beginning of the html override.

echo vmText to call it.

Language overrides exists with the Status (L) and for both locations.

Results in the email getting the language constant, not the translation.

Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Studio 42 on May 07, 2019, 16:29:37 PM
Curious, i had never this problem.
Try to replace vmText::_ with  Joomla jText::_
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Jörgen on May 07, 2019, 16:33:31 PM
Have you tried to echo the key order_status_.... directly? with vmText of course...I am still guessing you have a hidden character in your key. No trailing or starting blanks either.

Jörgen @ Kreativ Fotografi
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 07, 2019, 17:15:41 PM
echo jText gives me the language constant
vmText directly give me the expected translation (TEST NEWSITE)

See screen.
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Jörgen on May 07, 2019, 17:35:23 PM
Then You have to examine the key, I said it contains hidden characters, blanks, carriage return, tabs, you name it.
It is there, you have to examine the result and take appropriate action, this is not VM support, this is common PHP
programming. Find the issue and remove it, there are plenty of PHP functions to use both to examine the key
and to strip unwanted characters. Methodical approach is the best way to do it. I doubt that the vMText is buged,
but without checking Your string, we will never know.

Jörgen @ Kreativ Fotografi
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: Studio 42 on May 07, 2019, 18:01:19 PM
else add trim + strtoupper to be sure you have the KEY right formated.
something as
$key = strtoupper(trim($key));
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: dirkb on May 08, 2019, 10:21:51 AM
Jörgen and Studio.

Thanks for all your help. Appreciate it.
Jörgen was right, the ORDER_STATUS_ had a hidden space. Now its working perfectly.
Compared to the core hack I had to do back with 3.0.19, that solution is very elegant =)

cheers
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: DubStudio on May 10, 2020, 01:43:24 AM
Quote from: Studio 42 on May 07, 2019, 15:00:06 PM
If you use this solution
$order_status_description_key = 'ORDER_STATUS_ '.$this->orderDetails['details']['BT']->order_status.'_DESC';
echo vmText::_($order_status_description_key);
Then you need to add the language keys
ORDER_STATUS_X_DESC
Where X is the order_status Key
If the key is not translate in all cases, then you need to add override in Joomla language FRONT+ADMIN overrides!
Because when you generate the order in admin, the admin Keys are used for overrides and not front


The mysterious space is actually in the above code, so anyone copying and pasting it should delete the space after 'ORDER_STATUS_
Title: Re: Order Status Description in Shopper Email (what changed ?)
Post by: AH on May 10, 2020, 09:45:41 AM
Yes