2

How to remove or hide a shipping information in Email template order_new.html if the shipping method is freeshipping, i named it "Shop pick up" so we don't need to display this information because there is no shipping.

1 Answer 1

2

You can achieve this by below code.

Create an observer function which will check if order has "Free Shipping" in your case "Shop pick up" method selected.

<events>
    <sales_order_place_before>
        <observers>
            <update_order_for_free_shipping>
                <type>singleton</type>
                <class>Vendor_Module_Model_Observer</class>
                <method>updateOrderForFreeShipping</method>
            </update_order_for_free_shipping>
        </observers>
    </sales_order_place_before>
</events>

Now create Observer.php

<?php
class Vendor_Module_Model_Observer 
{
    public function updateOrderForFreeShipping($observer)
    {
        $order = $observer->getEvent()->getOrder();
        $order->getShippingMethod() == 'freeshipping_freeshipping' ? $order->setHideFreeShipping(false) : $order->setHideFreeShipping(true);
    }
}

Now update your order_new.html file and replace

{{depend order.getIsNotVirtual()}}
<td class="method-info">
    <h6>Shipping method:</h6>
    <p>{{var order.shipping_description}}</p>
</td>
{{/depend}}

With

{{depend order.getIsNotVirtual()}}
{{if order.hide_free_shipping}}
<td class="method-info">
    <h6>Shipping method:</h6>
    <p>{{var order.shipping_description}}</p>
</td>
{{/if}}
{{/depend}}
1
  • Thank you @Jaimin, nobody was able to do it except you ;)
    – PЯINCƎ
    May 24, 2017 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.