I need to show custom magento 2 success page for customers, who choose specific carrier and payment method. My questions is: Can I do override on magento success page that will be applied only when customer chooses carrier x and payment y?

Thanks in advance.


2 Answers 2


You can easily get the order information on the success page. So, you can get your specific carrier and payment method. Depending on that you can easily display custom information conditionally to your customers.

To override that order success page you must edit the following path app/design/frontend/vendorname/yourtheme/Magento_Checkout/templates/success.phtml


Modify the below file in your module app/code/Vendor/Module/View/frontend/layout/checkout_onepage_success.xml

<?xml version="1.0"?>
    <referenceContainer name="content">
        <block class="Vendor\Module\Block\Thankyou" name="order.details.success" template="Vendor_Module::order/success.phtml" after="-">           
    <referenceBlock name="checkout.success" remove="true"/>


namespace Vendor\Module\Block;

class Thankyou extends \Magento\Sales\Block\Order\Totals
    protected $checkoutSession;
    protected $customerSession;
    protected $_orderFactory;

    public function __construct(
        \Magento\Checkout\Model\Session $checkoutSession,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Sales\Model\OrderFactory $orderFactory,
        \Magento\Framework\View\Element\Template\Context $context,
        \Magento\Framework\Registry $registry,
        array $data = []
    ) {
        parent::__construct($context, $registry, $data);
        $this->checkoutSession = $checkoutSession;
        $this->customerSession = $customerSession;
        $this->_orderFactory = $orderFactory;

    public function getOrder()
        return  $this->_order = $this->_orderFactory->create()->loadByIncrementId(

    public function getCustomerId()
        return $this->customerSession->getCustomer()->getId();


$order = $block->getOrder();
$payment = $order->getPayment();
if ($order->getShippingMethod() && $payment->getMethod):
<div class="checkout-success">
<?php if($order->getIncrementId()):?>
    <?php if ($block->getCustomerId()) :?>
        <p><?php echo __('Your order number is: '.$order->getIncrementId().')' ?>
        <?php  else :?>
            <p><?php echo __('Your order # is: <span>%1</span>.',$order->getIncrementId()) ?></p>
        <?php endif;?>
        <p><?php echo __('We\'ll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?php endif;?>

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.