Skip to main content

Add stock status to the customer's confirmation email

More
9 years 3 months ago #272828 by dancingkazzaf
-- url of the page with the problem -- : charnwood.net
-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.2

Hi, Our client wants the customer's confirmation email to also include the current stock (plus some custom PHP code that we've put in to give customer's a little information about the stock level).

Where would we need to put this code to make it appear under each product listing in the email? (I've attached a screenshot to help illustrate what it is we're trying to achieve)

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

More
9 years 3 months ago #272855 by nicolas
Hi,

That's actually quite easy to do.
Edit the email via the menu Display>Emails.
There, if you just want to add text and the stock level, you can add such text in the HTML version:
Code:
Stock for that product: {LINEVAR:product.product_quantity}
after for example the tag:
{LINEVAR:PRODUCT_DETAILS}

If you want to add custom PHP there, you can write it there inside PHP tags.
For example:
Code:
Stock for that product: {LINEVAR:product.product_quantity}<?php echo 'test'; ?>
Otherwise, for more complex modifications, you can also add custom code in the preload of the email.
The following user(s) said Thank You: dancingkazzaf

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

More
9 years 3 months ago - 9 years 3 months ago #272866 by dancingkazzaf
Hi Nicolas,
Thanks for this, it's worked perfectly for adding the stock to the email. I'm struggling with the PHP code though.

The code we have calls in a custom field we've made called "product_back_in_stock". The code looks like this:
Code:
<?php if ($this->row->product_quantity == 0 && $this->element->product_back_in_stock) { echo "<strong>Product currently out of stock, back in stock: </strong>"; echo $this->element->product_back_in_stock; } ?>
Is it possible to call in custom fields to the email? If so, how would we do this?
Last edit: 9 years 3 months ago by dancingkazzaf.

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

More
9 years 3 months ago #272875 by nicolas
Hi,

The order data is stored in the variable $data in the emails.
You can look in the preload on how the data is used to fill the tags that are used in the HTML version.
Here is a snippet:
Code:
foreach($data->cart->products as $item) { if($group && $item->order_product_option_parent_id) continue; $product = @$productClass->all_products[$item->product_id]; $cartProduct = array( 'PRODUCT_CODE' => $item->order_product_code, 'PRODUCT_QUANTITY' => $item->order_product_quantity, 'PRODUCT_IMG' => '', 'item' => $item, 'product' => $product, );
you can see that the data of the product (and the custom product fields) are available there in $product so you can add your HTML to an entry in $cartProduct to create your own tag.
The following user(s) said Thank You: dancingkazzaf

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

More
9 years 3 months ago #273065 by dancingkazzaf
Thank you for your help Nicolas, i've got it working now :)

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

Time to create page: 0.160 seconds
Powered by Kunena Forum