Custom email confirmation based on product

  • Posts: 332
  • Thank you received: 6
8 years 1 month ago #250998

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.2
-- PHP version -- : 5.5.38
-- Browser(s) name and version -- : FF & Chrome - Updated

I read this post Modify "confirmed order" email based on purchase and have edited the 'en-GB.com_hikashop.ini file as well as edited the order confirmation email. However, it does not seem to be working as the 'additional' text is not displayed.

Here is the 'pertinent' fields in the language file:

THANK_YOU_FOR_YOUR_ORDER="Once again, thank you for your order at %s. We hope to see you again soon."
THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL="<br /><strong>NEXT STEP: </strong>Now that you have completed your purchase, the next step is to send the coupon code to your client with instructions for them to come to this website, create an account, purchased the pertinent Client program, either Divorcing with Children or Divorcing without Children, and apply the coupon to their purchase which will provide the program to them at no cost."
THANK_YOU_FOR_YOUR_ORDER_CLIENT="<br /><strong>NEXT STEP: </strong>Now that you have completed your purchase, the next step is log into our website, view the instructions on the right sidebar after logging in and click the link to begin viewing the program that you have purchased."

Here is the edits to the Text version section of the email (fully displayed here):
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.6.3
 * @author	hikashop.com
 * @copyright	(C) 2010-2016 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php echo JText::sprintf('HI_CUSTOMER',@$data->customer->name)."\n"."\n";?>
<?php
$url = $data->order->order_number;
if($config->get('simplified_registration',0) != 2) {
	$url .= "\n".'( '.$data->order_url.' )'."\n";
}
echo JText::sprintf('ORDER_STATUS_CHANGED_TO',$url,$data->mail_status)."\n"."\n";?>
<?php  echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER',HIKASHOP_LIVE)."\n"."\n"."\n"; ?>
<?php
/* adding additional text based on which product was ordered. */
foreach($data->cart->products as $product){
   if($product->product_id==1){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==2){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==3){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==4){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
}
?>
<?php echo str_replace('<br/>',"\n",JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name));?>

When I did a test, the order confirmation email did not display the additional text.

Can you tell me what I am doing incorrectly?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 1 month ago #251046

Hi,

The "text version" of the email will only be displayed by your email client if there is no HTML version or if your email client doesn't support HTML. But these days, almost all the email clients out there support HTML versions, and unless you force the setting in the email to not send the HTML version, HikaShop will send either the HTML version only or both the HTML and the text version.
So if you add custom code in the text version, it's normal you don't see it.
I would recommend to put that in the HTML version.

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

  • Posts: 332
  • Thank you received: 6
8 years 1 month ago #251101

Nicolas,

I do not see any coding for the 'THANK_YOU_FOR_YOUR_ORDER' in the HTML version section. The only area that I see dealing with the end of order messaging is as follows:

<!--{ENDIF:ORDER_SUMMARY}-->
<p>
	{TXT:ORDER_END_MESSAGE}
</p>

I assumed that the "{TXT:ORDER_END_MESSAGE}" was internal code to insert what has been coded in the 'Text version' section. If this is incorrect, then do I simply replace the code "<p> {TXT:ORDER_END_MESSAGE} </p>" with the 'entire' Text version' code?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 1 month ago #251129

Hi,

It's almost that. It's an "internal code to insert what has been coded in the" preload version section.

So yes, you can replace the code with your custom PHP. Or modify the code of the preload. Both are possible.

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

  • Posts: 332
  • Thank you received: 6
8 years 1 month ago #251194

Nicolas,

You comments are cryptic. I don't want to be critical here as I have 'very high' respect and admiration for the HikaShop team but please remember that most of the people who come to the forums are either not developers themselves, are beginner or intermediate level developers or people, like myself, who are advanced developers (yep, been doing it for 40+ years).

Naturally, someone who is not a developer needs a higher level of guidance but so too does beginner to advanced developers. Why? Because they didn't code HikaShop. You can give an instruction like this but, as a developer, I can't just go half-cocked (American term for jumping off a cliff) and hope that what I do will work. It is important to me that I do more good than harm. I may 'think' I understand exactly what to do but without knowing what some underlying code may be doing to the changes I make, I could cause more harm because I do not know 'fully' the underlying structure / coding and, to be honest, I really don't have time to 'reverse engineer' HikaShop. :P As much as I hate to say this but give feedback like you're speaking to a dummy, call it "HikaShop for Dummies". :lol: :lol:

So you say "you can replace the code with your custom PHP.". Are you talking about the PHP that is in the 'Text Version'? If so, why not just simply say "you can replace the {TXT:ORDER_END_MESSAGE} with the entire contents in your edited 'Text Version' ". I am assuming that is what you are saying. If not, enlighten me.

As far as making the changes in the Preload version, If I decided to change that version, would I replace this code:

'ORDER_BEGIN_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_BEGIN', HIKASHOP_LIVE),
	'ORDER_END_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER', HIKASHOP_LIVE) . '<br/>' . JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name),

With this code to accomplish the same thing:
'ORDER_BEGIN_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_BEGIN', HIKASHOP_LIVE),
	'ORDER_END_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER', HIKASHOP_LIVE) . '<br/>' .
	foreach($data->cart->products as $product){
		if($product->product_id==1){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE) 
		}
		if($product->product_id==2){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)
		}
		if($product->product_id==3){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)
		}
		if($product->product_id==4){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)
		}
	}
. '<br/>' . JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name),

If I change either the "HTML version" or the "Preload version", should I remove the changes that I made in the "Text version"?

Again, I appreciate your efforts.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 1 month ago #251236

Hi,

We prefer to spend time on a new version of the documentation instead of writing the same elements in the forum.
You will be able to find a dozen of thread (or more) about the email edition and the "html / text / preload" elements.
So, I understand your message and your advice ; but also please understand that when we see an account with around 200 messages, we suppose that you already have some knowledge about HikaShop workarounds.

Now each time you edit an email it will create overrides for the three parts.
So, logically, you can delete the overrides if you did not make modification but you can keep them if you want to be sure that it will not be modified with an update.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 332
  • Thank you received: 6
8 years 1 month ago #251243

I feel your frustration. :(

In the "Order notification" email, I tried this in the Preload version with no success in the confirmation email.

	'ORDER_BEGIN_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_BEGIN', HIKASHOP_LIVE),
	'ORDER_END_MESSAGE' => JText::sprintf('THANK_YOU_FOR_YOUR_ORDER', HIKASHOP_LIVE) . '<br/>' .
	
	foreach($data->cart->products as $product){
		if($product->product_id==1){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE) 
		}
		if($product->product_id==2){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)
		}
		if($product->product_id==3){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)
		}
		if($product->product_id==4){
			JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)
		}
	}
. '<br/>' . JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name),

I tried this in the HTML version with no success in the confirmation email:
<!--{ENDIF:ORDER_SUMMARY}-->
<p>
<!-- bypass text insert and post PHP in directly {TXT:ORDER_END_MESSAGE} -->
<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.6.3
 * @author	hikashop.com
 * @copyright	(C) 2010-2016 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php echo JText::sprintf('HI_CUSTOMER',@$data->customer->name)."\n"."\n";?>
<?php
$url = $data->order->order_number;
if($config->get('simplified_registration',0) != 2) {
	$url .= "\n".'( '.$data->order_url.' )'."\n";
}
echo JText::sprintf('ORDER_STATUS_CHANGED_TO',$url,$data->mail_status)."\n"."\n";?>
<?php  echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER',HIKASHOP_LIVE)."\n"."\n"."\n"; ?>
<?php
/* adding additional text based on which product was ordered. */
foreach($data->cart->products as $product){
   if($product->product_id==1){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==2){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==3){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==4){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
}
?>
<?php echo str_replace('<br/>',"\n",JText::sprintf('BEST_REGARDS_CUSTOMER',$mail->from_name));?>
</p>
<!-- end PHP insert -->

I have confirmed that the 'en-GB.com_hikashop.ini' file has the reference language fields:
THANK_YOU_FOR_YOUR_ORDER="Once again, thank you for your order at %s. We hope to see you again soon."
THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL="<br /><strong>NEXT STEP: </strong>Now that you have completed your purchase, the next step is to send the coupon code to your client with instructions for them to come to this website, create an account, purchased the pertinent Client program, either Divorcing with Children or Divorcing without Children, and apply the coupon to their purchase which will provide the program to them at no cost."
THANK_YOU_FOR_YOUR_ORDER_CLIENT="<br /><strong>NEXT STEP: </strong>Now that you have completed your purchase, the next step is log into our website, view the instructions on the right sidebar after logging in and click the link to begin viewing the program that you have purchased."

It looks like I have tried the correct coding to insert this additional text but, so far, no luck. Any suggestions?

As far as I can see, it should be

Last edit: 8 years 1 month ago by LukeDouglas.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 1 month ago #251266

Hi,

The code:

<?php
/* adding additional text based on which product was ordered. */
foreach($data->cart->products as $product){
   if($product->product_id==1){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==2){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==3){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_CLIENT',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
   if($product->product_id==4){
     echo JText::sprintf('THANK_YOU_FOR_YOUR_ORDER_PROFESSIONAL',HIKASHOP_LIVE)."\n"."\n"."\n";
     }
}
?>
added to the HTML version should definitely display the text in the email if the product_id of one of the products in the order has that id. Note however that if your products have variants, when you purchase it the product_id will be the id of the variant, not the id of the main product. So that might be why it doesn't display.

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

  • Posts: 332
  • Thank you received: 6
8 years 1 month ago #251332

Nicolas,

I tested and it didn't work so I did some digging and found the issue. I was editing the 'Order notification' instead of the 'Order status notification'. Once I made the changes to that record, it worked. Sorry for all this back and forth when it was a much simpler issue. :woohoo:

Also, I like the style changes on the website. Very nice!

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
1 year 4 months ago #352795

what i should add if i want this custom text not only on certain product ordered, but also only if order status changed to "confirmed".
Basically i need a custom text to appear in email for customer if order status is "conformed" and there is a custom product in order.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 4 months ago #352796

Hi,

When you edit the "order status notification" email, you have a "per status override" button for the HTML area.
Click on it and it will open a popup where you can select the order status and do your modifications of the HTML only for that particular order status. So you should be able to use the same code through that.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
1 year 4 months ago #352830

ok, but customer is stil getting "pending" email notifications, how to disable those completely? I need customer to get only one email - when status is "confirmed".

UPDATE: this was sent by payment plugin, Managed to get rid of that.

Last edit: 1 year 4 months ago by arnask.

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

Time to create page: 0.082 seconds
Powered by Kunena Forum