{"id":46054,"date":"2016-04-15T14:25:32","date_gmt":"2016-04-15T14:25:32","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=46054"},"modified":"2024-02-23T09:26:18","modified_gmt":"2024-02-23T09:26:18","slug":"display-custom-pricefee-sales-order-view-page","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/","title":{"rendered":"How to Display Custom Price fee in Sales Order View Page"},"content":{"rendered":"\n<p>You can learn how to add&nbsp;a custom amount in order total from here:<\/p>\n\n\n\n<p>http:\/\/webkul.com\/blog\/add-custom-pricefee-order-total-magento2\/<\/p>\n\n\n\n<p>Now, if you want to display the custom price fee on the sales order view page, then you can follow the following process:<\/p>\n\n\n\n<p>firstly, you need to create a sales_order_view.xml file in the folder:<\/p>\n\n\n\n<p>app\/code\/Webkul\/Test\/view\/frontend\/layout<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n\n    &lt;body&gt;        \n        &lt;referenceContainer name=&quot;order_totals&quot;&gt;\n            &lt;block class=&quot;Webkul\\Test\\Block\\Sales\\Order\\Test&quot; name=&quot;customfee&quot;\/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>Now, you need to define a block file in which you need to define the init_totals() function, which adds a custom fee amount to your order view.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\Test\\Block\\Sales\\Order;\n\nuse Magento\\Sales\\Model\\Order;\n\nclass Test extends \\Magento\\Framework\\View\\Element\\Template\n{\n    \/**\n     * @var Order\n     *\/\n    protected $_order;\n    \/**\n     * @var \\Magento\\Framework\\DataObject\n     *\/\n    protected $_source;\n    \/**\n     * @param \\Magento\\Framework\\View\\Element\\Template\\Context $context\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\Template\\Context $context,\n        array $data = &#091;]\n    ) {\n        parent::__construct($context, $data);\n    }\n    public function getSource()\n    {\n        return $this-&gt;_source;\n    }\n\n    public function displayFullSummary()\n    {\n        return true;\n    }\n    public function initTotals()\n    {\n        $parent = $this-&gt;getParentBlock();\n        $this-&gt;_order = $parent-&gt;getOrder();\n        $this-&gt;_source = $parent-&gt;getSource();\n        $title = &#039;Custom Fee&#039;;\n        $store = $this-&gt;getStore();\n        if($this-&gt;_order-&gt;getCustomfee()!=0){\n            $customAmount = new \\Magento\\Framework\\DataObject(\n                    &#091;\n                        &#039;code&#039; =&gt; &#039;customfee&#039;,\n                        &#039;strong&#039; =&gt; false,\n                        &#039;value&#039; =&gt; $this-&gt;_order-&gt;getCustomfee(),\n                        &#039;label&#039; =&gt; __($title),\n                    ]\n                );\n            $parent-&gt;addTotal($customAmount, &#039;customfee&#039;);\n        }\n        return $this;\n    }\n    \/**\n     * Get order store object\n     *\n     * @return \\Magento\\Store\\Model\\Store\n     *\/\n    public function getStore()\n    {\n        return $this-&gt;_order-&gt;getStore();\n    }\n    \/**\n     * @return Order\n     *\/\n    public function getOrder()\n    {\n        return $this-&gt;_order;\n    }\n    \/**\n     * @return array\n     *\/\n    public function getLabelProperties()\n    {\n        return $this-&gt;getParentBlock()-&gt;getLabelProperties();\n    }\n    \/**\n     * @return array\n     *\/\n    public function getValueProperties()\n    {\n        return $this-&gt;getParentBlock()-&gt;getValueProperties();\n    }\n}<\/pre>\n\n\n\n<p>Here, the init_totals() function adds the custom fee to your order by using the addTotal() method.<\/p>\n\n\n\n<p>$customAmount is an object of dataObject that stores the label, code, and value for a custom fee.<\/p>\n\n\n\n<p>&#8216;customfee&#8217; is the custom amount field name.<\/p>\n\n\n\n<p>After this, your custom fee amount is visible on the customer&#8217;s order view page.<\/p>\n\n\n\n<p>I hope this blog will help you with How to Display Custom Price fees on the Sales Order View Page. You may also check our wide range of best <a data-wpel-link=\"internal\" href=\"https:\/\/store.webkul.com\/Magento-2.html\" target=\"_blank\" rel=\"noopener\">Magento 2 Extensions<\/a>.<\/p>\n\n\n\n<p>Please reach out to our team via a&nbsp;<a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\" target=\"_blank\" rel=\"noreferrer noopener\" data-wpel-link=\"exclude\">support ticket<\/a>&nbsp;if you have any queries.<\/p>\n\n\n\n<p>Try this and if you have any queries then just comment below \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can learn how to add&nbsp;a custom amount in order total from here: http:\/\/webkul.com\/blog\/add-custom-pricefee-order-total-magento2\/ Now, if you want to display the custom price fee on the sales order view page, then you can follow the following process: firstly, you need to create a sales_order_view.xml file in the folder: app\/code\/Webkul\/Test\/view\/frontend\/layout Now, you need to define a <a href=\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[2070],"class_list":["post-46054","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Display Custom Price fee in Sales Order View Page<\/title>\n<meta name=\"description\" content=\"In this blog we will discuss How to Display Custom Price fee in Sales Order View Page\" \/>\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\/display-custom-pricefee-sales-order-view-page\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Display Custom Price fee in Sales Order View Page\" \/>\n<meta property=\"og:description\" content=\"In this blog we will discuss How to Display Custom Price fee in Sales Order View Page\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/\" \/>\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=\"2016-04-15T14:25:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-23T09:26:18+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=\"Bulbul\" \/>\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=\"Bulbul\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/\"},\"author\":{\"name\":\"Bulbul\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/c9c6288b3950490ffdb37cb2a526996e\"},\"headline\":\"How to Display Custom Price fee in Sales Order View Page\",\"datePublished\":\"2016-04-15T14:25:32+00:00\",\"dateModified\":\"2024-02-23T09:26:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/\"},\"wordCount\":218,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"Magento2\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/\",\"url\":\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/\",\"name\":\"How to Display Custom Price fee in Sales Order View Page\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2016-04-15T14:25:32+00:00\",\"dateModified\":\"2024-02-23T09:26:18+00:00\",\"description\":\"In this blog we will discuss How to Display Custom Price fee in Sales Order View Page\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Display Custom Price fee in Sales Order View Page\"}]},{\"@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\/c9c6288b3950490ffdb37cb2a526996e\",\"name\":\"Bulbul\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Bulbul\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/bulbul896\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Display Custom Price fee in Sales Order View Page","description":"In this blog we will discuss How to Display Custom Price fee in Sales Order View Page","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\/display-custom-pricefee-sales-order-view-page\/","og_locale":"en_US","og_type":"article","og_title":"How to Display Custom Price fee in Sales Order View Page","og_description":"In this blog we will discuss How to Display Custom Price fee in Sales Order View Page","og_url":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-04-15T14:25:32+00:00","article_modified_time":"2024-02-23T09:26:18+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":"Bulbul","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Bulbul","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/"},"author":{"name":"Bulbul","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/c9c6288b3950490ffdb37cb2a526996e"},"headline":"How to Display Custom Price fee in Sales Order View Page","datePublished":"2016-04-15T14:25:32+00:00","dateModified":"2024-02-23T09:26:18+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/"},"wordCount":218,"commentCount":4,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["Magento2"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/","url":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/","name":"How to Display Custom Price fee in Sales Order View Page","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2016-04-15T14:25:32+00:00","dateModified":"2024-02-23T09:26:18+00:00","description":"In this blog we will discuss How to Display Custom Price fee in Sales Order View Page","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/display-custom-pricefee-sales-order-view-page\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Display Custom Price fee in Sales Order View Page"}]},{"@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\/c9c6288b3950490ffdb37cb2a526996e","name":"Bulbul","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Bulbul"},"url":"https:\/\/webkul.com\/blog\/author\/bulbul896\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/46054","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\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=46054"}],"version-history":[{"count":7,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/46054\/revisions"}],"predecessor-version":[{"id":424036,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/46054\/revisions\/424036"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=46054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=46054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=46054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}