Display order custom field value in complete order

  • Posts: 56
  • Thank you received: 1
2 years 3 months ago #344133

For the checkout flow, I have added a custom field of delivery time and I would like to display the selected time after the order created (the last page of checkout flow).

For example, the original wording is " Your order is now complete. " after the order created (checkout/after_end.php)

I want to modify the message to display like: " Your order is now complete. The item will delivered to you on 3pm. " The 3pm will be the value selected during the checkout process.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 3 months ago #344136

Hi,

Most payment plugins don't have a thank you page and use HikaShop's default thank you page. In that case, it's indeed the checkout / after_end view file which is used and you can edit it via the menu Display>Views.
There, you'll find this line of code:

$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );
which displays the message "Thank you for your purchase." at the end of the checkout.
To do what you want supposing your payment plugin is using the default thank you page, you need to change that line to:
$app->enqueueMessage( JText::sprintf('THANK_YOU_FOR_PURCHASE', $this->order->xxx) );
where xxx is to be replaced with the column name of the custom order field you created.
Then, in your translation overrides, you can change the translation key THANK_YOU_FOR_PURCHASE from:
THANK_YOU_FOR_PURCHASE="Thank you for your purchase."
to:
THANK_YOU_FOR_PURCHASE="Your order is now complete. The item will delivered to you on %s."

However, since you have the text "Your order is now complete." it means your payment plugin don't use the default thank you page and it has its own thank you page.
For example, suppose you're using the "bank transfer" payment plugin. It means you're using the file plugins/hikashoppayment/banktransfer/banktransfer_end.php
To make an override of that file, you need to copy it to templates/YOUR_TEMPLATE/hikashoppayment/banktransfer_end.php via FTP.
In that copy, you can change the line:
<?php echo JText::_('ORDER_IS_COMPLETE').'<br/>'.
in a similar fashion to:
<?php echo JText::sprintf('ORDER_IS_COMPLETE', $this->order->xxx).'<br/>'.
where xxx is to be replaced with the column name of the custom order field you created.
Then, in your translation overrides, you can change the translation key ORDER_IS_COMPLETE from:
ORDER_IS_COMPLETE="Your order is now complete."
to:
ORDER_IS_COMPLETE="Your order is now complete. The item will delivered to you on %s."

The following user(s) said Thank You: jiawen

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

  • Posts: 56
  • Thank you received: 1
2 years 2 months ago #344150

It works! Thank you.

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

Time to create page: 0.056 seconds
Powered by Kunena Forum