0

I want to display application_no if payment method is FN in order details page.

I have created a block.

class Custom extends \Magento\Framework\View\Element\Template
{
    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
         array $data = []
    ) {
        parent::__construct($context, $data);
    }

    // public function getOrderId(){
    //     return $orderId = $this->getRequest()->getParam('order_id');
    // }

    public function getPaymentMethod(){
        // $orderId = $this->getRequest()->getParam('order_id');
        // $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        // $order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderId);
        // $payment = $order->getPayment();
        // // $method = $payment->getMethodInstance();
        // // $methodTitle = $method->getTitle();
        // return $order;
    }
}

Also, I have created a sales_order_view.xml to display my application_no (Tested it with static value and working fine).

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="left">
           <referenceContainer name="payment_additional_info">
                <block class="Limesharp\FinanceNow\Block\Adminhtml\Order\View\Custom" name="sales_order_view_custom" template="order/view/custom.phtml" />
             </referenceContainer>
        </referenceContainer>
    </body>
</page>

Here is my view file -

FN: <?php var_dump($block->getPaymentMethod()); ?>

Now I wanna pass application_no(custom column already in sales_order table) and payment_method. How can I pass this information from block to view of current order and display it conditionally?

New contributor
Abhishek Honrao is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Abhishek Honrao is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.