How to display Customer order number at checkout message and input in HTML link?

  • Posts: 62
  • Thank you received: 3
2 months 1 week ago #313902

-- url of the page with the problem -- : www.ginmacher.de
-- HikaShop version -- : 4.2.2
-- Joomla version -- : 3.9.6
-- PHP version -- : 7.2
-- Browser(s) name and version -- : Firefox/Chrome
-- Error-message(debug-mod must be tuned on) -- : Access to Order Number

Hi Team

when a customer buys a product via the webshop, after the payment process via plugin Paypal Plus he will be redirected to the page where the sucess message will be displayed to him (e. g. thanks for the purchase ...). This message can be edited in the hika shop text file. But I also want to show the current order number to the customer in this message. What's the variable to add into the HTML code that also the Hika Shop order number can be displayed.

Additionally: I want to create also a HTML link to a rating portal, that the customer can give my shop a rating. For that reason I also need to put this variable (the order number) and also other variables if possible into the mail - see example:

www.shopauskunft.de/neue-bewertung?xc__label=XYZ&bestellnr= [ORDER NUMBER]&email=[CustomerMail]&bestelldatum=[ORDER_DATE]

How do I get the variables per order into the customer message and also into the HTML link?

Thanks for help.

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

  • Posts: 68132
  • Thank you received: 10158
  • MODERATOR
2 months 1 week ago #313907

Hi,

First it depends. If you have "return URL" of the payment method filled in, then the thank you message is displayed on that page by something I'm not aware of. It could be a Joomla article etc.
Supposing that this setting is empty, you're using the thank you page of HikaShop. In that case, you'll need to edit the file "after_end" of the view "checkout" via the menu Display>Views to add your link and add the order number etc.
The order data is available in the $this->order variable in that view file.
So the order number can be retrieved like this:
<?php echo $this->order->order_number; ?>
And the email address with:
<?php echo $this->order->customer->user_email; ?>
The date is available like this:
<?php echo hikashop_getDate($this->order->order_created,'%d %B %Y %H:%M'); ?>
Note that you'll have to adapt the format of the date based on the requirements of that website.

Finally, to modify the email to the customer, you can edit it via the menu System>Emails.
Most information should be available as tags and you can display the list of the tags with the "list of tags" button when you edit the email.

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

  • Posts: 62
  • Thank you received: 3
2 months 6 days ago #313928

Hello Nicolas,

thanks for the quick answer. I guess i need a little bit more help:

In the view after_end the Text for THANK_YOU_FOR_YOUR_PURCHASE is displayed. This text will be set up in the language file (I use the german language only. So my entry for the THANK_YOU... is:

THANK_YOU_FOR_PURCHASE="<br/><strong>Herzlichen Dank für Deinen Einkauf</strong><br/></br><strong>WICHTIG! </strong></br>Du erhältst nach Deiner Bestellung umgehend eine Bestellbestätigung von mir. Bitte prüfe ggf. Deinem SPAM-ORDNER, ob diese dort gelandet ist und füge mich in Deinem E-Mail Programm als sicheren Absender hinzu!</br><a href=' www.shopauskunft.de/neue-bewertung?xc__label=12345& bestellnr=<?php echo $this->order->order_number; ?>'>Bewerte uns über Shopauskunft.de</a>"

As you see I have included here the shoplink and tried to get the order number in the link via the PHP script you showed me (marked bold). But that doesn't work. The link still shows the PHP sscript in live system and does not retreive the order number.

Or can I enter the HTML or text for hyperlink also in the after_end?

defined('_JEXEC') or die('Restricted access');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );
if(!empty($this->url))
$app->enqueueMessage(JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE',$this->url));

I mean like the above messages are shown and additionally I enter in the after_end somethink linke:
Here is your order numer (getordernumer via PHP)
Rate us here (www.shoplink........also include order number here as ahref)

Thanks for any support.

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

  • Posts: 2412
  • Thank you received: 325
  • MODERATOR
2 months 6 days ago #313937

Hello,

The point here is that you can't have dynamic data in your language .ini, put only text then do as this code, that you can see in your after_end.php :

if(!empty($this->url))
	$app->enqueueMessage(JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE',$this->url));

For this, you have to use variable in your translation like this in language.ini :
THANK_YOU_FOR_PURCHASE="<br/><strong>Herzlichen Dank für Deinen Einkauf</strong><br/></br><strong>WICHTIG! </strong></br>Du erhältst nach Deiner Bestellung umgehend eine Bestellbestätigung von mir. Bitte prüfe ggf. Deinem SPAM-ORDNER, ob diese dort gelandet ist und füge mich in Deinem E-Mail Programm als sicheren Absender hinzu!</br> %s Bewerte uns über Shopauskunft.de</a>"

Then in after_end.php :
$url = "<a href=' www.shopauskunft.de/neue-bewertung?xc__label=12345& bestellnr="<?php echo $this->order->order_number; ?>"'>"[/color];
echo '<br/>'.JText::sprintf('THANK_YOU_FOR_PURCHASE',$url);

Your variable (%s) in your language.ini will be replaced by your dynamic data, generated in your after_end.php.

Hope this will help you.
Regards

Last edit: 2 months 6 days ago by Philip.

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

  • Posts: 62
  • Thank you received: 3
2 months 5 days ago #313964

Hello Philippe,

I tried as you mentioned below. But somehow after the PayPal payment I get an error message. I entered the following in the .ini file:

THANK_YOU_FOR_PURCHASE="<br/><strong>Herzlichen Dank für Deinen Einkauf</strong><br/></br><strong>WICHTIG! </strong></br>Du erhältst nach Deiner Bestellung umgehend eine Bestellbestätigung von mir. Bitte prüfe ggf. Deinem SPAM-ORDNER, ob diese dort gelandet ist und füge mich in Deinem E-Mail Programm als sicheren Absender hinzu!</br> %s Bewerte uns über Shopauskunft.de</a>"

My after_end.php for the template I use in Joomla looks like this:
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	3.5.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2018 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );
if(!empty($this->url))
	$app->enqueueMessage(JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE',$this->url));
$url = "<a href=' www.shopauskunft.de/neue-bewertung?xc__label=12345& bestellnr="<?php echo $this->order->order_number; ?>"'>"[/color];
echo '<br/>'.JText::sprintf('THANK_YOU_FOR_PURCHASE',$url);

But after PayPal returnin to the shop I get this error message:
Fatal error: require_once(): Failed opening required '/homepages/15/d709564232/htdocs/ginmacher/libraries/joomla/document/html/renderer/head.php' (include_path='.:/usr/lib/php7.3') in /homepages/15/d709564232/htdocs/ginmacher/templates/lt_winery/error.php on line 43

The error.php which is referenced looks like this at this code segment:
$doc->setTitle($this->error->getCode() . ' - '.$this->title);
require_once(JPATH_LIBRARIES.'/joomla/document/html/renderer/head.php');
$header_renderer = new JDocumentRendererHead($doc);
$header_contents = $header_renderer->render(null);

Thanks again for help.

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

  • Posts: 68132
  • Thank you received: 10158
  • MODERATOR
2 months 5 days ago #313965

Hi,

Philippe made some typo in the code he gave you. It should be:

$url = "<a href='http://www.shopauskunft.de/neue-bewertung?xc__label=12345&bestellnr=". $this->order->order_number."'>";
echo '<br/>'.JText::sprintf('THANK_YOU_FOR_PURCHASE',$url);

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

  • Posts: 62
  • Thank you received: 3
2 months 5 days ago #313986

Hi Nicolas,

thanks for the correction. Now it works - BUT - with a double message :) (see screenshot



Without your code(s) I normally get after PayPal the brown screen with the messages (this can also be closed on the open right on the "x"). Nothing beneath.

With the code from above I get also a message below directly in the white page (that's even netter the this brown "popup" above). But the dirrerence it - in the brwon box I additionally have the sentence with: here you can access your order - that's missing in the white part.

How can I eliminate the brown section after PayPal sucess and only get all the information for the user in the normal white website section. Also with like: Summry of showing E-Mail Adress, Order Number, Ammount of Purchase etc. I think it would be enough just to give me one example how to access these varibels so I can adapt it the the other ones (just need to know how thex are names) :)

Thanks again very much for your excellent help guys!!

Attachments:

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

  • Posts: 68132
  • Thank you received: 10158
  • MODERATOR
2 months 4 days ago #313992

Hi,

That's because you didn't remove the line:
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

I already told you how to access the variables you want at the beginning:

So the order number can be retrieved like this:
<?php echo $this->order->order_number; ?>
And the email address with:
<?php echo $this->order->customer->user_email; ?>
The date is available like this:
<?php echo hikashop_getDate($this->order->order_created,'%d %B %Y %H:%M'); ?>

The amount of the purchase is available in the variable $this->order->order_full_price

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

  • Posts: 62
  • Thank you received: 3
2 months 2 days ago #314023

Hi Nicolas,

thanks a lot. Now it works as expected!! I included all relevant parameters in the Mail. Your guys really doing the best support here in this forum.

One last questions from my side: in the link I want to add the target=_blank that the click on the link opens a new window. I tried to add it as well into the ahref-code but I always get an server error. How Do I add this in that code:

$url = "<a href=' www.shopauskunft.de/neue-bewertung?xc__label=12345&bestellnr= ". $this->order->order_number."'>";

Thanks again!

The following user(s) said Thank You: Philip

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

  • Posts: 68132
  • Thank you received: 10158
  • MODERATOR
2 months 2 days ago #314028

Hi,

You can add it like that:

$url = "<a target='_blank' href=' www.shopauskunft.de/neue-bewertung?xc__label=12345&bestellnr= ". $this->order->order_number."'>";

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

  • Posts: 62
  • Thank you received: 3
2 months 2 days ago #314042

Thanks Nicolas - again :)

Alex

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

Time to create page: 0.085 seconds
Powered by Kunena Forum