0

On the shopping cart page, there are a proceed to checkout button display after order summary. I want to display also before the shopping cart grid.

How to display it?

Any help would be appreciated.

Thanks.

1

Use this below code for display button on top of grid on shopping cart page :

app/code/{Vendor}/{Module}/view/frontend/layout/checkout_cart_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Checkout\Block\Onepage\Link" name="checkout.cart.methods.onepage.top" template="Vendor_Module::onepage/link_top.phtml" before="checkout.cart" />
        </referenceContainer>
    </body>
</page>

app/code/{Vendor}/{Module}/view/frontend/templates/onepage/link_top.phtml

<?php
/** @var $block \Magento\Checkout\Block\Onepage\Link */
?>
<?php if ($block->isPossibleOnepageCheckout()) :?>
    <button type="button"
            data-role="proceed-to-checkout"
            title="<?= $block->escapeHtmlAttr(__('Proceed to Checkout Top')) ?>"
            data-mage-init='{
                "Magento_Checkout/js/proceed-to-checkout":{
                    "checkoutUrl":"<?= $block->escapeJs($block->escapeUrl($block->getCheckoutUrl())) ?>"
                }
            }'
            class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
            <?php if ($block->isDisabled()) :?>
                disabled="disabled"
            <?php endif; ?>>
        <span><?= $block->escapeHtml(__('Proceed to Checkout Top')) ?></span>
    </button>
<?php endif; ?>

Clean cache and check it.

3
  • 1
    Working as expected.. – Ankita Patel Dec 14 '20 at 4:38
  • 1
    good one!.... :) – Pawan Dec 14 '20 at 6:17
  • Thank you !! Happy Coding !! – Rohan Hapani Dec 14 '20 at 6:19
0

Create checkout_cart_index.xml at

app/code/{Vendor}/{Module}/view/frontend/layout/checkout_cart_index.xml

==========OR==========

app/design/frontend/{Package}/{theme}/layout/checkout_cart_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="cart.summary">
            <block class="Magento\Checkout\Block\Onepage\Link" name="checkout.cart.methods.onepage.top" template="{Vendor}_{Module}::onepage/link_upper.phtml" before="-" />
        </referenceContainer>
    </body>
</page>

Create link_upper.phtml at

app/code/{Vendor}/{Module}/view/frontend/templates/onepage/link_upper.phtml

==========OR=========

app/design/frontend/{Package}/{theme}/templates/onepage/link_upper.phtml

<?php
/** @var $block \Magento\Checkout\Block\Onepage\Link */
?>
<?php if ($block->isPossibleOnepageCheckout()) :?>
    <button type="button"
            data-role="proceed-to-checkout"
            title="<?= $block->escapeHtmlAttr(__('Proceed to Checkout Top')) ?>"
            data-mage-init='{
                "Magento_Checkout/js/proceed-to-checkout":{
                    "checkoutUrl":"<?= $block->escapeJs($block->escapeUrl($block->getCheckoutUrl())) ?>"
                }
            }'
            class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
            <?php if ($block->isDisabled()) :?>
                disabled="disabled"
            <?php endif; ?>>
        <span><?= $block->escapeHtml(__('Proceed to Checkout Top')) ?></span>
    </button>
<?php endif?>

Note: You may need to adjust design of upper checkout button

Hope above will help!

2
  • Nope. It's not proper working. It's display inside order summary. I want bottom of the title or beside title. – Ankita Patel Dec 14 '20 at 4:12
  • It is working...you just need to change position using after before element! – Pawan Dec 14 '20 at 6:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.