{"id":161533,"date":"2019-02-06T10:41:27","date_gmt":"2019-02-06T10:41:27","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=161533"},"modified":"2023-01-09T07:27:37","modified_gmt":"2023-01-09T07:27:37","slug":"add-processing-fee-in-order-email-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/","title":{"rendered":"Add processing Fee in Order Email In Magento 2"},"content":{"rendered":"\n<p>Whenever we do customize our store, there the situation comes when we add processing fee to the order.<br>and If we have added fee to the order then we must want that fee to be shown in mails as well,<\/p>\n\n\n\n<p>So today we are going to learn , how to add processing fee to the order emails.<br>It is very simple, we just need to follow two steps :<br>Step 1 : In your module create a file named as<strong>&nbsp;sales_email_order_items.xml<\/strong> , in this location &lt;Vendor&gt;\\&lt;Module&gt;\\view\\frontend\\layout\\sales_email_order_items.xml<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:xml\">&lt;?xml version=\"1.0\"?&gt;\n&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\"&gt;\n    &lt;body&gt;\n        &lt;referenceBlock name=\"order_totals\"&gt;\n            &lt;block class=\"&lt;Vendor&gt;\\&lt;Module&gt;\\Block\\Total\\Processingfee\" name=\"processing-fee\"\/&gt;\n        &lt;\/referenceBlock&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;\n<\/pre>\n\n\n\n<p>Step 2 : This xml will add the block row in order email now lets create a block for the&nbsp;<strong>processing-fee<\/strong> ,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:php\">&lt;?php\nnamespace &lt;Vendor&gt;\\&lt;Module&gt;\\Block\\Total;\n\nclass Processingfee extends \\Magento\\Framework\\View\\Element\\Template\n{\n    \/**\n     * Tax configuration model\n     *\n     * @var \\Magento\\Tax\\Model\\Config\n     *\/\n    protected $config;\n\n    \/**\n     * @var Order\n     *\/\n    protected $order;\n\n    \/**\n     * @var \\Magento\\Framework\\DataObject\n     *\/\n    protected $source;\n\n    \/**\n     * @param \\Magento\\Framework\\View\\Element\\Template\\Context $context\n     * @param \\Magento\\Tax\\Model\\Config $taxConfig\n     * @param array $data\n     * @SuppressWarnings(PHPMD.CouplingBetweenObjects)\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\Template\\Context $context,\n        \\Magento\\Tax\\Model\\Config $taxConfig,\n        array $data = []\n    ) {\n        $this-&gt;config = $taxConfig;\n        parent::__construct($context, $data);\n    }\n\n\n    \/**\n     * Get data (totals) source model\n     *\n     * @return \\Magento\\Framework\\DataObject\n     *\/\n    public function getSource()\n    {\n        return $this-&gt;source;\n    }\n\n      \/**\n       * @return Order\n       *\/\n    public function getOrder()\n    {\n        return $this-&gt;order;\n    }\n\n    \/**\n     * Initialize all order totals relates with tax\n     *\n     * @return \\Magento\\Tax\\Block\\Sales\\Order\\Tax\n     *\/\n    public function initTotals()\n    {\n\n        $parent = $this-&gt;getParentBlock();\n        $this-&gt;order = $parent-&gt;getOrder();\n        \n        $this-&gt;source = $parent-&gt;getSource();\n        $store = $this-&gt;getStore();\n        $order = $this-&gt;order-&gt;load($this-&gt;order-&gt;getId());\n        $processingFee = $order-&gt;getData('processing_fee');\n        if ($processingFee) {\n            $charges = new \\Magento\\Framework\\DataObject(\n                [\n                    'code' =&gt; 'processing_fee',\n                    'strong' =&gt; false,\n                    'value' =&gt; $processingFee,\n                    'label' =&gt; __('Processing Fee'),\n                ]\n            );\n            $parent-&gt;addTotal($charges, 'processing_fee');\n        }\n            return $this;\n    }\n}\n<\/pre>\n\n\n\n<p>That&#8217;s it and we are ready to add the processing fee block in order email.<br>if you have any out then please add a comment in comment section below<br>Happy Coding .. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whenever we do customize our store, there the situation comes when we add processing fee to the order.and If we have added fee to the order then we must want that fee to be shown in mails as well, So today we are going to learn , how to add processing fee to the order <a href=\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":170,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,302],"tags":[8136,8137,8138,7592,8135,2056,2070,8139,4991],"class_list":["post-161533","post","type-post","status-publish","format-standard","hentry","category-magento","category-magento2","tag-add-custom-fee","tag-add-initial-fee","tag-add-processing-fee","tag-fee","tag-initial","tag-magento","tag-magento2","tag-order-email","tag-row"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Add processing Fee in Order Email In Magento 2 - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add processing Fee in Order Email In Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Whenever we do customize our store, there the situation comes when we add processing fee to the order.and If we have added fee to the order then we must want that fee to be shown in mails as well, So today we are going to learn , how to add processing fee to the order [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-06T10:41:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-09T07:27:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prabhat Rawat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prabhat Rawat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\"},\"author\":{\"name\":\"Prabhat Rawat\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f\"},\"headline\":\"Add processing Fee in Order Email In Magento 2\",\"datePublished\":\"2019-02-06T10:41:27+00:00\",\"dateModified\":\"2023-01-09T07:27:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\"},\"wordCount\":157,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"add custom fee\",\"add initial fee\",\"add processing fee\",\"fee\",\"initial\",\"magento\",\"Magento2\",\"order email\",\"row\"],\"articleSection\":[\"magento\",\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\",\"name\":\"Add processing Fee in Order Email In Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2019-02-06T10:41:27+00:00\",\"dateModified\":\"2023-01-09T07:27:37+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add processing Fee in Order Email In Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f\",\"name\":\"Prabhat Rawat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Prabhat Rawat\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/prabhat-rawat763\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add processing Fee in Order Email In Magento 2 - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Add processing Fee in Order Email In Magento 2 - Webkul Blog","og_description":"Whenever we do customize our store, there the situation comes when we add processing fee to the order.and If we have added fee to the order then we must want that fee to be shown in mails as well, So today we are going to learn , how to add processing fee to the order [...]","og_url":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2019-02-06T10:41:27+00:00","article_modified_time":"2023-01-09T07:27:37+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Prabhat Rawat","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Prabhat Rawat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/"},"author":{"name":"Prabhat Rawat","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f"},"headline":"Add processing Fee in Order Email In Magento 2","datePublished":"2019-02-06T10:41:27+00:00","dateModified":"2023-01-09T07:27:37+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/"},"wordCount":157,"commentCount":4,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["add custom fee","add initial fee","add processing fee","fee","initial","magento","Magento2","order email","row"],"articleSection":["magento","Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/","name":"Add processing Fee in Order Email In Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2019-02-06T10:41:27+00:00","dateModified":"2023-01-09T07:27:37+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/add-processing-fee-in-order-email-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Add processing Fee in Order Email In Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f","name":"Prabhat Rawat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Prabhat Rawat"},"url":"https:\/\/webkul.com\/blog\/author\/prabhat-rawat763\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/161533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/170"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=161533"}],"version-history":[{"count":6,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/161533\/revisions"}],"predecessor-version":[{"id":363678,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/161533\/revisions\/363678"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=161533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=161533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=161533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}