how to display purchase order number in customer dashboard frontend?












0














I am using Magento 2.1 .
I want to display purchase order number in customer dashboard.



enter image description here










share|improve this question






















  • did you figure out from which file its calling?
    – Abhishek Panchal
    yesterday
















0














I am using Magento 2.1 .
I want to display purchase order number in customer dashboard.



enter image description here










share|improve this question






















  • did you figure out from which file its calling?
    – Abhishek Panchal
    yesterday














0












0








0







I am using Magento 2.1 .
I want to display purchase order number in customer dashboard.



enter image description here










share|improve this question













I am using Magento 2.1 .
I want to display purchase order number in customer dashboard.



enter image description here







magento-2.1 frontend purchase-order






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









kirankiran

3610




3610












  • did you figure out from which file its calling?
    – Abhishek Panchal
    yesterday


















  • did you figure out from which file its calling?
    – Abhishek Panchal
    yesterday
















did you figure out from which file its calling?
– Abhishek Panchal
yesterday




did you figure out from which file its calling?
– Abhishek Panchal
yesterday










1 Answer
1






active

oldest

votes


















0














You need to override recent.phtml template files in Magento_Sales module.

To fetch the purchase order number in the recent.phtml you can use the following code



$_order->getPayment()->getPoNumber()


You can try following code and modify it according to your requirement.



app/code/Anshu/Custom/etc/module.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_Custom" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>


app/code/Anshu/Custom/registration.php



<?php

use MagentoFrameworkComponentComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_Custom',
__DIR__
);


app/code/Anshu/Custom/view/frontend/layout/customer_account_index.xml



<?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">
<body>
<referenceContainer name="content">
<block class="MagentoSalesBlockOrderRecent" name="customer_account_dashboard_top" template="Anshu_Custom::recent.phtml"/>
</referenceContainer>
</body>
</page>


app/code/Anshu/Custom/view/frontend/templates/recent.phtml



<div class="block block-dashboard-orders">
<?php
$_orders = $block->getOrders();
$count = count($_orders);
?>
<div class="block-title order">
<strong><?= /* @escapeNotVerified */ __('Recent Orders') ?></strong>
<?php if ($count > 0): ?>
<a class="action view" href="<?= /* @escapeNotVerified */ $block->getUrl('sales/order/history') ?>">
<span><?= /* @escapeNotVerified */ __('View All') ?></span>
</a>
<?php endif; ?>
</div>
<div class="block-content">
<?= $block->getChildHtml() ?>
<?php if ($count > 0): ?>
<div class="table-wrapper orders-recent">
<table class="data table table-order-items recent" id="my-orders-table">
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Recent Orders') ?></caption>
<thead>
<tr>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Order #') ?></th>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Purchase Order #') ?></th>
<th scope="col" class="col date"><?= /* @escapeNotVerified */ __('Date') ?></th>
<th scope="col" class="col shipping"><?= /* @escapeNotVerified */ __('Ship To') ?></th>
<th scope="col" class="col total"><?= /* @escapeNotVerified */ __('Order Total') ?></th>
<th scope="col" class="col status"><?= /* @escapeNotVerified */ __('Status') ?></th>
<th scope="col" class="col actions"><?= /* @escapeNotVerified */ __('Action') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($_orders as $_order): ?>
<tr>
<td data-th="<?= $block->escapeHtml(__('Order #')) ?>" class="col id"><?= /* @escapeNotVerified */ $_order->getRealOrderId() ?></td>
<td data-th="<?= $block->escapeHtml(__('Purchase Order #')) ?>" class="col purchaseorder"><?= /* @escapeNotVerified */ $_order->getPayment()->getPoNumber() ?></td>
<td data-th="<?= $block->escapeHtml(__('Date')) ?>" class="col date"><?= /* @escapeNotVerified */ $block->formatDate($_order->getCreatedAt()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?= $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?= $block->escapeHtml(__('Order Total')) ?>" class="col total"><?= /* @escapeNotVerified */ $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Status')) ?>" class="col status"><?= /* @escapeNotVerified */ $_order->getStatusLabel() ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?= /* @escapeNotVerified */ $block->getViewUrl($_order) ?>" class="action view">
<span><?= /* @escapeNotVerified */ __('View Order') ?></span>
</a>
<?php if ($this->helper('MagentoSalesHelperReorder')->canReorder($_order->getEntityId())) : ?>
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(MagentoFrameworkDataHelperPostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?= /* @escapeNotVerified */ __('Reorder') ?></span>
</a>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="message info empty"><span><?= /* @escapeNotVerified */ __('You have placed no orders.') ?></span></div>
<?php endif; ?>
</div>
</div>





share|improve this answer





















  • Thanks for you response. without overriding the recent.phtml template, can we change only recent.phtml file
    – kiran
    yesterday










  • @kiran if you don't want to override using module than you override it in your custom theme. But anyway you have to override it as doing change directly in core file is a bad coding practice.
    – Anshu Mishra
    yesterday











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257042%2fhow-to-display-purchase-order-number-in-customer-dashboard-frontend%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You need to override recent.phtml template files in Magento_Sales module.

To fetch the purchase order number in the recent.phtml you can use the following code



$_order->getPayment()->getPoNumber()


You can try following code and modify it according to your requirement.



app/code/Anshu/Custom/etc/module.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_Custom" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>


app/code/Anshu/Custom/registration.php



<?php

use MagentoFrameworkComponentComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_Custom',
__DIR__
);


app/code/Anshu/Custom/view/frontend/layout/customer_account_index.xml



<?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">
<body>
<referenceContainer name="content">
<block class="MagentoSalesBlockOrderRecent" name="customer_account_dashboard_top" template="Anshu_Custom::recent.phtml"/>
</referenceContainer>
</body>
</page>


app/code/Anshu/Custom/view/frontend/templates/recent.phtml



<div class="block block-dashboard-orders">
<?php
$_orders = $block->getOrders();
$count = count($_orders);
?>
<div class="block-title order">
<strong><?= /* @escapeNotVerified */ __('Recent Orders') ?></strong>
<?php if ($count > 0): ?>
<a class="action view" href="<?= /* @escapeNotVerified */ $block->getUrl('sales/order/history') ?>">
<span><?= /* @escapeNotVerified */ __('View All') ?></span>
</a>
<?php endif; ?>
</div>
<div class="block-content">
<?= $block->getChildHtml() ?>
<?php if ($count > 0): ?>
<div class="table-wrapper orders-recent">
<table class="data table table-order-items recent" id="my-orders-table">
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Recent Orders') ?></caption>
<thead>
<tr>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Order #') ?></th>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Purchase Order #') ?></th>
<th scope="col" class="col date"><?= /* @escapeNotVerified */ __('Date') ?></th>
<th scope="col" class="col shipping"><?= /* @escapeNotVerified */ __('Ship To') ?></th>
<th scope="col" class="col total"><?= /* @escapeNotVerified */ __('Order Total') ?></th>
<th scope="col" class="col status"><?= /* @escapeNotVerified */ __('Status') ?></th>
<th scope="col" class="col actions"><?= /* @escapeNotVerified */ __('Action') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($_orders as $_order): ?>
<tr>
<td data-th="<?= $block->escapeHtml(__('Order #')) ?>" class="col id"><?= /* @escapeNotVerified */ $_order->getRealOrderId() ?></td>
<td data-th="<?= $block->escapeHtml(__('Purchase Order #')) ?>" class="col purchaseorder"><?= /* @escapeNotVerified */ $_order->getPayment()->getPoNumber() ?></td>
<td data-th="<?= $block->escapeHtml(__('Date')) ?>" class="col date"><?= /* @escapeNotVerified */ $block->formatDate($_order->getCreatedAt()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?= $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?= $block->escapeHtml(__('Order Total')) ?>" class="col total"><?= /* @escapeNotVerified */ $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Status')) ?>" class="col status"><?= /* @escapeNotVerified */ $_order->getStatusLabel() ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?= /* @escapeNotVerified */ $block->getViewUrl($_order) ?>" class="action view">
<span><?= /* @escapeNotVerified */ __('View Order') ?></span>
</a>
<?php if ($this->helper('MagentoSalesHelperReorder')->canReorder($_order->getEntityId())) : ?>
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(MagentoFrameworkDataHelperPostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?= /* @escapeNotVerified */ __('Reorder') ?></span>
</a>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="message info empty"><span><?= /* @escapeNotVerified */ __('You have placed no orders.') ?></span></div>
<?php endif; ?>
</div>
</div>





share|improve this answer





















  • Thanks for you response. without overriding the recent.phtml template, can we change only recent.phtml file
    – kiran
    yesterday










  • @kiran if you don't want to override using module than you override it in your custom theme. But anyway you have to override it as doing change directly in core file is a bad coding practice.
    – Anshu Mishra
    yesterday
















0














You need to override recent.phtml template files in Magento_Sales module.

To fetch the purchase order number in the recent.phtml you can use the following code



$_order->getPayment()->getPoNumber()


You can try following code and modify it according to your requirement.



app/code/Anshu/Custom/etc/module.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_Custom" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>


app/code/Anshu/Custom/registration.php



<?php

use MagentoFrameworkComponentComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_Custom',
__DIR__
);


app/code/Anshu/Custom/view/frontend/layout/customer_account_index.xml



<?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">
<body>
<referenceContainer name="content">
<block class="MagentoSalesBlockOrderRecent" name="customer_account_dashboard_top" template="Anshu_Custom::recent.phtml"/>
</referenceContainer>
</body>
</page>


app/code/Anshu/Custom/view/frontend/templates/recent.phtml



<div class="block block-dashboard-orders">
<?php
$_orders = $block->getOrders();
$count = count($_orders);
?>
<div class="block-title order">
<strong><?= /* @escapeNotVerified */ __('Recent Orders') ?></strong>
<?php if ($count > 0): ?>
<a class="action view" href="<?= /* @escapeNotVerified */ $block->getUrl('sales/order/history') ?>">
<span><?= /* @escapeNotVerified */ __('View All') ?></span>
</a>
<?php endif; ?>
</div>
<div class="block-content">
<?= $block->getChildHtml() ?>
<?php if ($count > 0): ?>
<div class="table-wrapper orders-recent">
<table class="data table table-order-items recent" id="my-orders-table">
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Recent Orders') ?></caption>
<thead>
<tr>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Order #') ?></th>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Purchase Order #') ?></th>
<th scope="col" class="col date"><?= /* @escapeNotVerified */ __('Date') ?></th>
<th scope="col" class="col shipping"><?= /* @escapeNotVerified */ __('Ship To') ?></th>
<th scope="col" class="col total"><?= /* @escapeNotVerified */ __('Order Total') ?></th>
<th scope="col" class="col status"><?= /* @escapeNotVerified */ __('Status') ?></th>
<th scope="col" class="col actions"><?= /* @escapeNotVerified */ __('Action') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($_orders as $_order): ?>
<tr>
<td data-th="<?= $block->escapeHtml(__('Order #')) ?>" class="col id"><?= /* @escapeNotVerified */ $_order->getRealOrderId() ?></td>
<td data-th="<?= $block->escapeHtml(__('Purchase Order #')) ?>" class="col purchaseorder"><?= /* @escapeNotVerified */ $_order->getPayment()->getPoNumber() ?></td>
<td data-th="<?= $block->escapeHtml(__('Date')) ?>" class="col date"><?= /* @escapeNotVerified */ $block->formatDate($_order->getCreatedAt()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?= $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?= $block->escapeHtml(__('Order Total')) ?>" class="col total"><?= /* @escapeNotVerified */ $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Status')) ?>" class="col status"><?= /* @escapeNotVerified */ $_order->getStatusLabel() ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?= /* @escapeNotVerified */ $block->getViewUrl($_order) ?>" class="action view">
<span><?= /* @escapeNotVerified */ __('View Order') ?></span>
</a>
<?php if ($this->helper('MagentoSalesHelperReorder')->canReorder($_order->getEntityId())) : ?>
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(MagentoFrameworkDataHelperPostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?= /* @escapeNotVerified */ __('Reorder') ?></span>
</a>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="message info empty"><span><?= /* @escapeNotVerified */ __('You have placed no orders.') ?></span></div>
<?php endif; ?>
</div>
</div>





share|improve this answer





















  • Thanks for you response. without overriding the recent.phtml template, can we change only recent.phtml file
    – kiran
    yesterday










  • @kiran if you don't want to override using module than you override it in your custom theme. But anyway you have to override it as doing change directly in core file is a bad coding practice.
    – Anshu Mishra
    yesterday














0












0








0






You need to override recent.phtml template files in Magento_Sales module.

To fetch the purchase order number in the recent.phtml you can use the following code



$_order->getPayment()->getPoNumber()


You can try following code and modify it according to your requirement.



app/code/Anshu/Custom/etc/module.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_Custom" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>


app/code/Anshu/Custom/registration.php



<?php

use MagentoFrameworkComponentComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_Custom',
__DIR__
);


app/code/Anshu/Custom/view/frontend/layout/customer_account_index.xml



<?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">
<body>
<referenceContainer name="content">
<block class="MagentoSalesBlockOrderRecent" name="customer_account_dashboard_top" template="Anshu_Custom::recent.phtml"/>
</referenceContainer>
</body>
</page>


app/code/Anshu/Custom/view/frontend/templates/recent.phtml



<div class="block block-dashboard-orders">
<?php
$_orders = $block->getOrders();
$count = count($_orders);
?>
<div class="block-title order">
<strong><?= /* @escapeNotVerified */ __('Recent Orders') ?></strong>
<?php if ($count > 0): ?>
<a class="action view" href="<?= /* @escapeNotVerified */ $block->getUrl('sales/order/history') ?>">
<span><?= /* @escapeNotVerified */ __('View All') ?></span>
</a>
<?php endif; ?>
</div>
<div class="block-content">
<?= $block->getChildHtml() ?>
<?php if ($count > 0): ?>
<div class="table-wrapper orders-recent">
<table class="data table table-order-items recent" id="my-orders-table">
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Recent Orders') ?></caption>
<thead>
<tr>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Order #') ?></th>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Purchase Order #') ?></th>
<th scope="col" class="col date"><?= /* @escapeNotVerified */ __('Date') ?></th>
<th scope="col" class="col shipping"><?= /* @escapeNotVerified */ __('Ship To') ?></th>
<th scope="col" class="col total"><?= /* @escapeNotVerified */ __('Order Total') ?></th>
<th scope="col" class="col status"><?= /* @escapeNotVerified */ __('Status') ?></th>
<th scope="col" class="col actions"><?= /* @escapeNotVerified */ __('Action') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($_orders as $_order): ?>
<tr>
<td data-th="<?= $block->escapeHtml(__('Order #')) ?>" class="col id"><?= /* @escapeNotVerified */ $_order->getRealOrderId() ?></td>
<td data-th="<?= $block->escapeHtml(__('Purchase Order #')) ?>" class="col purchaseorder"><?= /* @escapeNotVerified */ $_order->getPayment()->getPoNumber() ?></td>
<td data-th="<?= $block->escapeHtml(__('Date')) ?>" class="col date"><?= /* @escapeNotVerified */ $block->formatDate($_order->getCreatedAt()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?= $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?= $block->escapeHtml(__('Order Total')) ?>" class="col total"><?= /* @escapeNotVerified */ $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Status')) ?>" class="col status"><?= /* @escapeNotVerified */ $_order->getStatusLabel() ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?= /* @escapeNotVerified */ $block->getViewUrl($_order) ?>" class="action view">
<span><?= /* @escapeNotVerified */ __('View Order') ?></span>
</a>
<?php if ($this->helper('MagentoSalesHelperReorder')->canReorder($_order->getEntityId())) : ?>
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(MagentoFrameworkDataHelperPostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?= /* @escapeNotVerified */ __('Reorder') ?></span>
</a>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="message info empty"><span><?= /* @escapeNotVerified */ __('You have placed no orders.') ?></span></div>
<?php endif; ?>
</div>
</div>





share|improve this answer












You need to override recent.phtml template files in Magento_Sales module.

To fetch the purchase order number in the recent.phtml you can use the following code



$_order->getPayment()->getPoNumber()


You can try following code and modify it according to your requirement.



app/code/Anshu/Custom/etc/module.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Anshu_Custom" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>


app/code/Anshu/Custom/registration.php



<?php

use MagentoFrameworkComponentComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Anshu_Custom',
__DIR__
);


app/code/Anshu/Custom/view/frontend/layout/customer_account_index.xml



<?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">
<body>
<referenceContainer name="content">
<block class="MagentoSalesBlockOrderRecent" name="customer_account_dashboard_top" template="Anshu_Custom::recent.phtml"/>
</referenceContainer>
</body>
</page>


app/code/Anshu/Custom/view/frontend/templates/recent.phtml



<div class="block block-dashboard-orders">
<?php
$_orders = $block->getOrders();
$count = count($_orders);
?>
<div class="block-title order">
<strong><?= /* @escapeNotVerified */ __('Recent Orders') ?></strong>
<?php if ($count > 0): ?>
<a class="action view" href="<?= /* @escapeNotVerified */ $block->getUrl('sales/order/history') ?>">
<span><?= /* @escapeNotVerified */ __('View All') ?></span>
</a>
<?php endif; ?>
</div>
<div class="block-content">
<?= $block->getChildHtml() ?>
<?php if ($count > 0): ?>
<div class="table-wrapper orders-recent">
<table class="data table table-order-items recent" id="my-orders-table">
<caption class="table-caption"><?= /* @escapeNotVerified */ __('Recent Orders') ?></caption>
<thead>
<tr>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Order #') ?></th>
<th scope="col" class="col id"><?= /* @escapeNotVerified */ __('Purchase Order #') ?></th>
<th scope="col" class="col date"><?= /* @escapeNotVerified */ __('Date') ?></th>
<th scope="col" class="col shipping"><?= /* @escapeNotVerified */ __('Ship To') ?></th>
<th scope="col" class="col total"><?= /* @escapeNotVerified */ __('Order Total') ?></th>
<th scope="col" class="col status"><?= /* @escapeNotVerified */ __('Status') ?></th>
<th scope="col" class="col actions"><?= /* @escapeNotVerified */ __('Action') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($_orders as $_order): ?>
<tr>
<td data-th="<?= $block->escapeHtml(__('Order #')) ?>" class="col id"><?= /* @escapeNotVerified */ $_order->getRealOrderId() ?></td>
<td data-th="<?= $block->escapeHtml(__('Purchase Order #')) ?>" class="col purchaseorder"><?= /* @escapeNotVerified */ $_order->getPayment()->getPoNumber() ?></td>
<td data-th="<?= $block->escapeHtml(__('Date')) ?>" class="col date"><?= /* @escapeNotVerified */ $block->formatDate($_order->getCreatedAt()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?= $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?= $block->escapeHtml(__('Order Total')) ?>" class="col total"><?= /* @escapeNotVerified */ $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?= $block->escapeHtml(__('Status')) ?>" class="col status"><?= /* @escapeNotVerified */ $_order->getStatusLabel() ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?= /* @escapeNotVerified */ $block->getViewUrl($_order) ?>" class="action view">
<span><?= /* @escapeNotVerified */ __('View Order') ?></span>
</a>
<?php if ($this->helper('MagentoSalesHelperReorder')->canReorder($_order->getEntityId())) : ?>
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(MagentoFrameworkDataHelperPostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?= /* @escapeNotVerified */ __('Reorder') ?></span>
</a>
<?php endif ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="message info empty"><span><?= /* @escapeNotVerified */ __('You have placed no orders.') ?></span></div>
<?php endif; ?>
</div>
</div>






share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Anshu MishraAnshu Mishra

5,12542657




5,12542657












  • Thanks for you response. without overriding the recent.phtml template, can we change only recent.phtml file
    – kiran
    yesterday










  • @kiran if you don't want to override using module than you override it in your custom theme. But anyway you have to override it as doing change directly in core file is a bad coding practice.
    – Anshu Mishra
    yesterday


















  • Thanks for you response. without overriding the recent.phtml template, can we change only recent.phtml file
    – kiran
    yesterday










  • @kiran if you don't want to override using module than you override it in your custom theme. But anyway you have to override it as doing change directly in core file is a bad coding practice.
    – Anshu Mishra
    yesterday
















Thanks for you response. without overriding the recent.phtml template, can we change only recent.phtml file
– kiran
yesterday




Thanks for you response. without overriding the recent.phtml template, can we change only recent.phtml file
– kiran
yesterday












@kiran if you don't want to override using module than you override it in your custom theme. But anyway you have to override it as doing change directly in core file is a bad coding practice.
– Anshu Mishra
yesterday




@kiran if you don't want to override using module than you override it in your custom theme. But anyway you have to override it as doing change directly in core file is a bad coding practice.
– Anshu Mishra
yesterday


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257042%2fhow-to-display-purchase-order-number-in-customer-dashboard-frontend%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

An IMO inspired problem

Management

Has there ever been an instance of an active nuclear power plant within or near a war zone?