cancel
Showing results for 
Search instead for 
Did you mean: 

Backorder notifaction in order email

Backorder notifaction in order email

Hi All

Is new at M2 and is just changing my site from m1 to m2.

Its very different from M1 and have need some help to get an backorder notifation in the order email for the customer.

 

I dont know where to find it in M2.

 

in M1 I changed it here:
app/design/frontend/base/default/template/email/order/items/order/default.phtml

 

added the following:

<strong style="font-size:11px;"><?php echo $this->escapeHtml($_item->getName()) ?></strong><?php if ($_item->getQtyBackordered()): ?><br><span style="font-size: 10px">(<?php echo $_item->getQtyBackordered()*1 ?> stk. bestilles hjem)</span><?php endif; ?>

 

How and where do I do that in M2?

 

Thanks in advance Smiley Happy

6 REPLIES 6

Re: Backorder notifaction in order email

Hello @KElund

 

As per your reference please find below links so they can help:

 

https://mage2.pro/t/topic/870

https://magento.stackexchange.com/questions/177343/override-magento-2-email-items-order-default-phtm...

Manish Mittal
https://www.manishmittal.com/

Re: Backorder notifaction in order email

found thr file in M2 here:

 

vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtm

 

if I add this: 

<?php if ($_item->getQtyBackordered()): ?><br><span style="font-size: 10px">(<?php echo $_item->getQtyBackordered()*1 ?> stk. bestilles hjem)</span><?php endif; ?>

 

so the file will looks like that does that seem right?

edit.jpg

Re: Backorder notifaction in order email

Hello @KElund

 

I can not see attached image but you have to override core file first and then you can try this code. 

Manish Mittal
https://www.manishmittal.com/

Re: Backorder notifaction in order email

Hello @KElund,

 

Please run below command to clear cache and regenerate static content in magento 2 root directory

php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade
rm -rf pub/static/frontend/* pub/static/adminhtml/* var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ var/composer_home generated/
php -dmemory_limit=6G bin/magento setup:static-content:deploy -f
chmod -Rf 777 pub/ var/
php bin/magento cache:clean

--
If my answer is useful, please Accept as Solution & give Kudos

Re: Backorder notifaction in order email

Was it the right solution or?

Re: Backorder notifaction in order email

Hello @KElund,

 

The block you are trying to modify the template of is within the "sales.email.order.renderers" block so your referencing the wrong block. The block you want to modify has no name however and just the alias "default". Have you tried something like:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Creditmemo Items List" design_abstraction="custom">
    <body>
        <referenceBlock name="sales.email.order.renderers">
            <block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="Vendor_Module::email/items/order/default.phtml"/>
        </referenceBlock>
    </body>
</page>

Also i was told yesterday that the action tag is being depreciated and now is best to use below to override templates:

<referenceBlock name="sales.email.order.renderers" template="Company_Module::email/items/order/default.phtml" />

However I think the name is wrong as the template we need to modify is within this block:

<block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="email/items/order/default.phtml"/>

Rather than the block "sales.email.order.renderers" and am unsure if below would work with the alias:

<referenceBlock name="default" template="Company_Module::email/items/order/default.phtml" />

Reading here Magento 2: How to change template of a block without "name" it just seems to show what i suggested.

 

Please run below command to clear cache and regenerate static content in magento 2 root directory

php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade
rm -rf pub/static/frontend/* pub/static/adminhtml/* var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ var/composer_home generated/
php -dmemory_limit=6G bin/magento setup:static-content:deploy -f
chmod -Rf 777 pub/ var/
php bin/magento cache:clean

--
If my answer is useful, please Accept as Solution & give Kudos