Custom HTML in confirm email if product present

  • Posts: 72
  • Thank you received: 0
11 years 7 months ago #139976

Hi,

I'm trying to edit the order confirmation email template to display a block of html but only if a certain product has been bought.

We achieved this in the past with hika starter by editing the 'order_status_notification.html.php' file using the following code:

<?php 
if ($item->product_id == 155) { 
echo 'CUSTOM HTML HERE'; 
							
} elseif ($item->product_id == 5) { 
echo 'CUSTOM HTML HERE';
...
..
.
?> 

how is this done in hika business edition?

many thanks

Last edit: 11 years 7 months ago by daveturner101.

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

  • Posts: 12953
  • Thank you received: 1778
11 years 7 months ago #139992

Hi,
Note that you'll still be able to do that by using your code through your "order status notification" email configuration page ("Hikashop->System->Emails").

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

  • Posts: 72
  • Thank you received: 0
11 years 7 months ago #140108

Mohamed Thelji wrote: Hi,
Note that you'll still be able to do that by using your code through your "order status notification" email configuration page ("Hikashop->System->Emails").


hi, thanks for the reply.

i did try it on the template file but it didn't work. could the syntax have changed with moving the code into a new location?

thanks

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

  • Posts: 84242
  • Thank you received: 13686
  • MODERATOR
11 years 7 months ago #140170

If you have a recent version of HikaShop, you can see that there is no PHP anymore in emails but only tags.
You would have to edit the "preload" file of the email via the menu System>Emails (available in the latest version of HikaShop) in order to add your custom PHP code.

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

  • Posts: 72
  • Thank you received: 0
11 years 7 months ago #140377

nicolas wrote: If you have a recent version of HikaShop, you can see that there is no PHP anymore in emails but only tags.
You would have to edit the "preload" file of the email via the menu System>Emails (available in the latest version of HikaShop) in order to add your custom PHP code.


thanks for the info. i've edited the preload file as such but i'm not seeing my code displayed. can you advise?

i've added the following into the preload file
if ($item->product_id == 159) { 
    $gift_cert = 'CUSTOM HTML HERE';
  } else {
    $gift_cert = '';
  }

and then added an extra line to the VARS array:
$vars = array(
....
...
..
'GIFT_CERT' => $gift_cert,
);

i've then used the 'GIFT_CERT' tag in the main email body:
<table width="100%">
<tr>
<td>
<p>
{VAR:GIFT_CERT}
</p>
</td>
</tr>
</table>

is this the correct process?

many thanks

Last edit: 11 years 7 months ago by daveturner101. Reason: code amend

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

  • Posts: 84242
  • Thank you received: 13686
  • MODERATOR
11 years 7 months ago #140391

Yes that's the correct process.
It's probably that you added the first piece of code outside of the foreach on the products and thus the $item variable doesn't exist.

The following user(s) said Thank You: daveturner101

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

  • Posts: 72
  • Thank you received: 0
11 years 7 months ago #140400

nicolas wrote: Yes that's the correct process.
It's probably that you added the first piece of code outside of the foreach on the products and thus the $item variable doesn't exist.


thanks, i managed to get it working. put it at the bottom of the preload file and changed
if ($item->product_id == 159) {

to
if ($item->product_id == '159') {

is there a way to target a product whether it has any characteristics added to it or not? i'm realising that when i add and remove characteristics from a product (which will be quite often) i will have to go into the preload file and amend my product id number as this will keep changing won't it?

is there a unique id for a product that always stays the same whether there's a characteristic added to it or it's just stand alone?

hope i'm explaining myself OK.

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

  • Posts: 84242
  • Thank you received: 13686
  • MODERATOR
11 years 7 months ago #140403

There is no unique id. The id will change if you regenerate the variants of the product and thus the product_id of the variants will change too.

The following user(s) said Thank You: daveturner101

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

  • Posts: 72
  • Thank you received: 0
11 years 7 months ago #140405

nicolas wrote: There is no unique id. The id will change if you regenerate the variants of the product and thus the product_id of the variants will change too.

OK thanks. i'll just have to go into the file and amend it when i need to.

on the subject of characteristics, i'm noticing that when i add an extra characteristic to a product on the back end it's not showing on the front end unless i go into the product, remove the characteristics, save, add the characteristics again and then save again.

is this normal? and will new product_id's be generated every time i remove the characteristics and then add them again?

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

  • Posts: 84242
  • Thank you received: 13686
  • MODERATOR
11 years 7 months ago #140409

That's normal with old versions of HikaShop. With recent versions, the variants are regenerated automatically when you do that and you should see it directly on the frontend.

And yes, the product_ids are regenerated in such case.

The following user(s) said Thank You: daveturner101

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

  • Posts: 72
  • Thank you received: 0
11 years 7 months ago #140411

nicolas wrote: That's normal with old versions of HikaShop. With recent versions, the variants are regenerated automatically when you do that and you should see it directly on the frontend.

And yes, the product_ids are regenerated in such case.


thanks. that's not the case for me and i'm using the most up to date version of hikashop.

could it be that i've edited one of the 'views' files and the shop is still using older code? if so which one is likely to be the culprit?

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

  • Posts: 84242
  • Thank you received: 13686
  • MODERATOR
11 years 7 months ago #140443

No that shouldn't be the case as it is done directly in the product saving process which is not editable.

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

Time to create page: 0.083 seconds
Powered by Kunena Forum