0

My Account Page Sales order invoice page Back to My Orders link how to move after Order Information in magento 2.3.6

http://magento2.com/sales/order/invoice/order_id/22361/

vendor/magento/module-sales/view/frontend/templates/order/invoice.phtml

<div class="order-details-items invoice">
<?= $block->getChildHtml('invoice_items') ?>
<div class="actions-toolbar">
    <div class="secondary">
        <a href="<?= $block->escapeUrl($block->getBackUrl()) ?>" class="action back">
            <span><?= $block->escapeHtml($block->getBackTitle()) ?> 
            </span>
        </a>
    </div>
</div>
vendor/magento/module-sales/Block/Order/invoice.php

<?php
 /**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
 namespace Magento\Sales\Block\Order;

 use Magento\Customer\Model\Context;

 /**
 * Sales order view block
 *
 * @api
 @since 100.0.2
 */
 class Invoice extends \Magento\Sales\Block\Order\Invoice\Items
{
/**
 * @var string
 */
protected $_template = 'Magento_Sales::order/invoice.phtml';

/**
 * @var \Magento\Framework\App\Http\Context
 */
protected $httpContext;

/**
 * @var \Magento\Payment\Helper\Data
 */
protected $_paymentHelper;

/**
 * @param \Magento\Framework\View\Element\Template\Context $context
 * @param \Magento\Framework\Registry $registry
 * @param \Magento\Framework\App\Http\Context $httpContext
 * @param \Magento\Payment\Helper\Data $paymentHelper
 * @param array $data
 */
public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    \Magento\Framework\Registry $registry,
    \Magento\Framework\App\Http\Context $httpContext,
    \Magento\Payment\Helper\Data $paymentHelper,
    array $data = []
) {
    $this->_paymentHelper = $paymentHelper;
    $this->httpContext = $httpContext;
    parent::__construct($context, $registry, $data);
    $this->_isScopePrivate = true;
}

/**
 * @return void
 */
protected function _prepareLayout()
{
    $this->pageConfig->getTitle()->set(__('Order # %1', $this->getOrder()->getRealOrderId()));
    $infoBlock = $this->_paymentHelper->getInfoBlock($this->getOrder()->getPayment(), $this->getLayout());
    $this->setChild('payment_info', $infoBlock);
}





/**
 * Return back url for logged in and guest users
 *
 * @return string
 */
public function getBackUrl()
{
    if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
        return $this->getUrl('*/*/history');
    }
    return $this->getUrl('*/*/form');
}

/**
 * Return back title for logged in and guest users
 *
 * @return \Magento\Framework\Phrase
 */
public function getBackTitle()
{
    if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
        return __('Back to My Orders');
    }
    return __('View Another Order');
 }


}

enter image description here

3
  • share screnshot
    – Himanshu
    Feb 2, 2021 at 6:45
  • check screnshort @Himanshu Feb 2, 2021 at 6:56
  • Back to My Orders link in move after order information label ??
    – Himanshu
    Feb 2, 2021 at 7:34

1 Answer 1

0

Add code custom theme in magento 2.3

Magento-Sales/layout/sales_order_invoice.xml
 <?xml version="1.0"?>
   <!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
 */
 -->
  <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="Magento\Sales\Block\Order\Invoice" name="back.order.invoice.url" template="Magento_Sales::order/invoice/back-url.phtml" after="sales.order.info"/>
    </referenceContainer>
</body>

Magento_Sales/order/invoice/back-url.phtml

<div class="actions-toolbar">
<div class="secondary">
    <a href="<?= $block->escapeUrl($block->getBackUrl()) ?>" class="action back">
        <span><?= $block->escapeHtml($block->getBackTitle()) ?></span>
    </a>
</div>

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.