Different Email To Customer Depending on Order

  • Posts: 159
  • Thank you received: 25
  • Hikashop Business
3 weeks 3 days ago #372514

-- HikaShop version -- : 6.5.0 [2605281459]
-- Joomla version -- : 6.1.1
-- PHP version -- : 8.4.22

  • We are selling physical products and as well a digital product.
  • All orders require registration
  • We are using HikaShop Tags to hide content from those who haven't paid for the digital items
  • Now looking to send, in the order confirmation email, to anyone purchasing the digital item or both physical/digital a different email confirmation to those who only purchased the physical products. We are looking to include the link to the "hidden" menu item for them to access a login form redirecting them to the "hidden" page
Possible?

Last edit: 2 weeks 3 days ago by yerg55.

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

  • Posts: 85985
  • Thank you received: 14149
  • MODERATOR
3 weeks 3 days ago #372522

Hi,

Yes, this is possible. Your order confirmation email is a PHP template, and inside it you have the full list of the products that were purchased, so you can show an extra block (your login / hidden menu link) only when the order contains the digital item, and hide it for orders that are physical only.

In your HikaShop backend go to System > Emails and open the email your customers receive: the "Order creation notification", and/or the "Order status notification" if you would rather reveal the access only once the order is confirmed and paid. Whatever you save there is kept as an update safe override, so a HikaShop update will not overwrite it.

At the spot in the body where you want the link to appear, add this block and set your digital product id(s):

<?php
$digitalProductIds = array(12, 34); // put your digital product id(s) here
$hasDigital = false;
foreach($data->cart->products as $item) {
    if(in_array($item->product_id, $digitalProductIds)) {
        $hasDigital = true;
        break;
    }
}
if($hasDigital) {
    echo '<p><a href="'.HIKASHOP_LIVE.'index.php?Itemid=123">Access your content here</a></p>';
}
?>

Replace 12, 34 with the id(s) of your digital product(s) (you see them in the ID column of the Products listing), and Itemid=123 with the id of your hidden menu item. Customers who bought only physical products will not see the block; anyone who bought the digital item, alone or together with physical products, will get the link.

If you have many digital products and would rather not maintain a list of ids, you can rearrange the code to use a custom product field, or something else based on how you characterize digital products in your shop.

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

  • Posts: 159
  • Thank you received: 25
  • Hikashop Business
2 weeks 3 days ago #372610

Thanks Nicolas

That's all functioning correctly
Emails coming through as expected

I'll post another Item to keep this one focused for others

The following user(s) said Thank You: nicolas

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

Time to create page: 0.055 seconds
Powered by Kunena Forum