how to override Proceed to Checkout button in cart page in Magento 2












0















i want to override



<block class="MagentoCheckoutBlockOnepageLink" name="checkout.cart.methods.onepage.bottom" template="Magento_Checkout::onepage/link.phtml" />


this block i am using thish code in
checkout_cart_index.xml page



<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.methods.onepage.bottom">
<block class="NamespaceModulenameBlockCheckoutbutton" name="test" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml" cacheable="false" />
</referenceBlock>

</body>
</page>









share|improve this question

























  • Do you want it only on cart page or minicart as well?

    – Sukumar Gorai
    Nov 20 '18 at 9:07
















0















i want to override



<block class="MagentoCheckoutBlockOnepageLink" name="checkout.cart.methods.onepage.bottom" template="Magento_Checkout::onepage/link.phtml" />


this block i am using thish code in
checkout_cart_index.xml page



<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.methods.onepage.bottom">
<block class="NamespaceModulenameBlockCheckoutbutton" name="test" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml" cacheable="false" />
</referenceBlock>

</body>
</page>









share|improve this question

























  • Do you want it only on cart page or minicart as well?

    – Sukumar Gorai
    Nov 20 '18 at 9:07














0












0








0








i want to override



<block class="MagentoCheckoutBlockOnepageLink" name="checkout.cart.methods.onepage.bottom" template="Magento_Checkout::onepage/link.phtml" />


this block i am using thish code in
checkout_cart_index.xml page



<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.methods.onepage.bottom">
<block class="NamespaceModulenameBlockCheckoutbutton" name="test" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml" cacheable="false" />
</referenceBlock>

</body>
</page>









share|improve this question
















i want to override



<block class="MagentoCheckoutBlockOnepageLink" name="checkout.cart.methods.onepage.bottom" template="Magento_Checkout::onepage/link.phtml" />


this block i am using thish code in
checkout_cart_index.xml page



<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.methods.onepage.bottom">
<block class="NamespaceModulenameBlockCheckoutbutton" name="test" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml" cacheable="false" />
</referenceBlock>

</body>
</page>






magento2 checkout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 12:40









Murtuza Zabuawala

12.7k73362




12.7k73362










asked Nov 20 '18 at 8:23









Shubhajay DasShubhajay Das

578




578













  • Do you want it only on cart page or minicart as well?

    – Sukumar Gorai
    Nov 20 '18 at 9:07



















  • Do you want it only on cart page or minicart as well?

    – Sukumar Gorai
    Nov 20 '18 at 9:07

















Do you want it only on cart page or minicart as well?

– Sukumar Gorai
Nov 20 '18 at 9:07





Do you want it only on cart page or minicart as well?

– Sukumar Gorai
Nov 20 '18 at 9:07










1 Answer
1






active

oldest

votes


















1














Method 1:



Copy the below file from:




/vendor/magento/module-checkout/view/frontend/templates/onepage/link.phtml




to




/app/design/frontend/Vendor/theme/Magento_Checkout/templates/onepage/link.phtml




And update the text or code according to your requirement.



The above will work for cart page only not for minicart.



Method 2:



You can add this in your layout file and use it.



<?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>
<referenceBlock name="checkout.cart.methods.onepage.bottom" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml"/>
</body>
</page>


Method 3:(Updated according to the comment)



Create one module with name Vendor_Module and follow the below steps:



Step 1:
Create layout file like below under




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




and add the below code:



<?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="checkout.cart.methods">
<block class="VendorModuleBlockCheckout" name="checkout.cart.methods.onepage.bottom" template="Vedor_Module::onepage/link.phtml" />
</referenceContainer>
</body>
</page>


Step 2:
Create block file under:




app/code/Vendor/Module/Block/Checkout.php




and add the below code(for testing):



<?php
namespace VendorModuleBlock;

class Checkout extends MagentoCheckoutBlockOnepageLink {
// This function is created for testing purpose, you can add more function as per your requirement
public function getTest(){
return 'Test Button';
}
}


Step 3:
Create link.phtml under




app/code/Vendor/Module/view/frontend/templates/onepage/link.phtml




and add the below codes(example):



<?php if ($block->isPossibleOnepageCheckout()):?>
<button type="button"
data-role="proceed-to-checkout"
title="<?= /* @escapeNotVerified */ __('Proceed to Checkout') ?>"
data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?= /* @escapeNotVerified */ $block->getCheckoutUrl() ?>"}}'
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
<span><?= /* @escapeNotVerified */ __('Proceed to Checkout') ?></span>
</button>
<?php endif?>

<?= $block->getTest(); // Code is added to test if our block is working or not ?>


Thats it. Run the required commands and test.






share|improve this answer


























  • thank you @Sukumar Gorai can't i override it in my custom module using xml file

    – Shubhajay Das
    Nov 20 '18 at 11:10











  • Second method is not working for you?

    – Sukumar Gorai
    Nov 20 '18 at 11:11











  • in second method can i use my custom block as i shown in question

    – Shubhajay Das
    Nov 20 '18 at 11:58











  • Why do you need to change the block class?

    – Sukumar Gorai
    Nov 20 '18 at 13:23











  • i have to change it as per my requirement condition

    – Shubhajay Das
    Nov 20 '18 at 13:39












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%2f250608%2fhow-to-override-proceed-to-checkout-button-in-cart-page-in-magento-2%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









1














Method 1:



Copy the below file from:




/vendor/magento/module-checkout/view/frontend/templates/onepage/link.phtml




to




/app/design/frontend/Vendor/theme/Magento_Checkout/templates/onepage/link.phtml




And update the text or code according to your requirement.



The above will work for cart page only not for minicart.



Method 2:



You can add this in your layout file and use it.



<?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>
<referenceBlock name="checkout.cart.methods.onepage.bottom" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml"/>
</body>
</page>


Method 3:(Updated according to the comment)



Create one module with name Vendor_Module and follow the below steps:



Step 1:
Create layout file like below under




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




and add the below code:



<?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="checkout.cart.methods">
<block class="VendorModuleBlockCheckout" name="checkout.cart.methods.onepage.bottom" template="Vedor_Module::onepage/link.phtml" />
</referenceContainer>
</body>
</page>


Step 2:
Create block file under:




app/code/Vendor/Module/Block/Checkout.php




and add the below code(for testing):



<?php
namespace VendorModuleBlock;

class Checkout extends MagentoCheckoutBlockOnepageLink {
// This function is created for testing purpose, you can add more function as per your requirement
public function getTest(){
return 'Test Button';
}
}


Step 3:
Create link.phtml under




app/code/Vendor/Module/view/frontend/templates/onepage/link.phtml




and add the below codes(example):



<?php if ($block->isPossibleOnepageCheckout()):?>
<button type="button"
data-role="proceed-to-checkout"
title="<?= /* @escapeNotVerified */ __('Proceed to Checkout') ?>"
data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?= /* @escapeNotVerified */ $block->getCheckoutUrl() ?>"}}'
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
<span><?= /* @escapeNotVerified */ __('Proceed to Checkout') ?></span>
</button>
<?php endif?>

<?= $block->getTest(); // Code is added to test if our block is working or not ?>


Thats it. Run the required commands and test.






share|improve this answer


























  • thank you @Sukumar Gorai can't i override it in my custom module using xml file

    – Shubhajay Das
    Nov 20 '18 at 11:10











  • Second method is not working for you?

    – Sukumar Gorai
    Nov 20 '18 at 11:11











  • in second method can i use my custom block as i shown in question

    – Shubhajay Das
    Nov 20 '18 at 11:58











  • Why do you need to change the block class?

    – Sukumar Gorai
    Nov 20 '18 at 13:23











  • i have to change it as per my requirement condition

    – Shubhajay Das
    Nov 20 '18 at 13:39
















1














Method 1:



Copy the below file from:




/vendor/magento/module-checkout/view/frontend/templates/onepage/link.phtml




to




/app/design/frontend/Vendor/theme/Magento_Checkout/templates/onepage/link.phtml




And update the text or code according to your requirement.



The above will work for cart page only not for minicart.



Method 2:



You can add this in your layout file and use it.



<?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>
<referenceBlock name="checkout.cart.methods.onepage.bottom" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml"/>
</body>
</page>


Method 3:(Updated according to the comment)



Create one module with name Vendor_Module and follow the below steps:



Step 1:
Create layout file like below under




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




and add the below code:



<?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="checkout.cart.methods">
<block class="VendorModuleBlockCheckout" name="checkout.cart.methods.onepage.bottom" template="Vedor_Module::onepage/link.phtml" />
</referenceContainer>
</body>
</page>


Step 2:
Create block file under:




app/code/Vendor/Module/Block/Checkout.php




and add the below code(for testing):



<?php
namespace VendorModuleBlock;

class Checkout extends MagentoCheckoutBlockOnepageLink {
// This function is created for testing purpose, you can add more function as per your requirement
public function getTest(){
return 'Test Button';
}
}


Step 3:
Create link.phtml under




app/code/Vendor/Module/view/frontend/templates/onepage/link.phtml




and add the below codes(example):



<?php if ($block->isPossibleOnepageCheckout()):?>
<button type="button"
data-role="proceed-to-checkout"
title="<?= /* @escapeNotVerified */ __('Proceed to Checkout') ?>"
data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?= /* @escapeNotVerified */ $block->getCheckoutUrl() ?>"}}'
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
<span><?= /* @escapeNotVerified */ __('Proceed to Checkout') ?></span>
</button>
<?php endif?>

<?= $block->getTest(); // Code is added to test if our block is working or not ?>


Thats it. Run the required commands and test.






share|improve this answer


























  • thank you @Sukumar Gorai can't i override it in my custom module using xml file

    – Shubhajay Das
    Nov 20 '18 at 11:10











  • Second method is not working for you?

    – Sukumar Gorai
    Nov 20 '18 at 11:11











  • in second method can i use my custom block as i shown in question

    – Shubhajay Das
    Nov 20 '18 at 11:58











  • Why do you need to change the block class?

    – Sukumar Gorai
    Nov 20 '18 at 13:23











  • i have to change it as per my requirement condition

    – Shubhajay Das
    Nov 20 '18 at 13:39














1












1








1







Method 1:



Copy the below file from:




/vendor/magento/module-checkout/view/frontend/templates/onepage/link.phtml




to




/app/design/frontend/Vendor/theme/Magento_Checkout/templates/onepage/link.phtml




And update the text or code according to your requirement.



The above will work for cart page only not for minicart.



Method 2:



You can add this in your layout file and use it.



<?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>
<referenceBlock name="checkout.cart.methods.onepage.bottom" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml"/>
</body>
</page>


Method 3:(Updated according to the comment)



Create one module with name Vendor_Module and follow the below steps:



Step 1:
Create layout file like below under




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




and add the below code:



<?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="checkout.cart.methods">
<block class="VendorModuleBlockCheckout" name="checkout.cart.methods.onepage.bottom" template="Vedor_Module::onepage/link.phtml" />
</referenceContainer>
</body>
</page>


Step 2:
Create block file under:




app/code/Vendor/Module/Block/Checkout.php




and add the below code(for testing):



<?php
namespace VendorModuleBlock;

class Checkout extends MagentoCheckoutBlockOnepageLink {
// This function is created for testing purpose, you can add more function as per your requirement
public function getTest(){
return 'Test Button';
}
}


Step 3:
Create link.phtml under




app/code/Vendor/Module/view/frontend/templates/onepage/link.phtml




and add the below codes(example):



<?php if ($block->isPossibleOnepageCheckout()):?>
<button type="button"
data-role="proceed-to-checkout"
title="<?= /* @escapeNotVerified */ __('Proceed to Checkout') ?>"
data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?= /* @escapeNotVerified */ $block->getCheckoutUrl() ?>"}}'
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
<span><?= /* @escapeNotVerified */ __('Proceed to Checkout') ?></span>
</button>
<?php endif?>

<?= $block->getTest(); // Code is added to test if our block is working or not ?>


Thats it. Run the required commands and test.






share|improve this answer















Method 1:



Copy the below file from:




/vendor/magento/module-checkout/view/frontend/templates/onepage/link.phtml




to




/app/design/frontend/Vendor/theme/Magento_Checkout/templates/onepage/link.phtml




And update the text or code according to your requirement.



The above will work for cart page only not for minicart.



Method 2:



You can add this in your layout file and use it.



<?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>
<referenceBlock name="checkout.cart.methods.onepage.bottom" template="Namespace_Modulename::namespace_modulename/checkoutbutton.phtml"/>
</body>
</page>


Method 3:(Updated according to the comment)



Create one module with name Vendor_Module and follow the below steps:



Step 1:
Create layout file like below under




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




and add the below code:



<?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="checkout.cart.methods">
<block class="VendorModuleBlockCheckout" name="checkout.cart.methods.onepage.bottom" template="Vedor_Module::onepage/link.phtml" />
</referenceContainer>
</body>
</page>


Step 2:
Create block file under:




app/code/Vendor/Module/Block/Checkout.php




and add the below code(for testing):



<?php
namespace VendorModuleBlock;

class Checkout extends MagentoCheckoutBlockOnepageLink {
// This function is created for testing purpose, you can add more function as per your requirement
public function getTest(){
return 'Test Button';
}
}


Step 3:
Create link.phtml under




app/code/Vendor/Module/view/frontend/templates/onepage/link.phtml




and add the below codes(example):



<?php if ($block->isPossibleOnepageCheckout()):?>
<button type="button"
data-role="proceed-to-checkout"
title="<?= /* @escapeNotVerified */ __('Proceed to Checkout') ?>"
data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{"checkoutUrl":"<?= /* @escapeNotVerified */ $block->getCheckoutUrl() ?>"}}'
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
<span><?= /* @escapeNotVerified */ __('Proceed to Checkout') ?></span>
</button>
<?php endif?>

<?= $block->getTest(); // Code is added to test if our block is working or not ?>


Thats it. Run the required commands and test.







share|improve this answer














share|improve this answer



share|improve this answer








edited 5 mins ago

























answered Nov 20 '18 at 9:09









Sukumar GoraiSukumar Gorai

6,9303729




6,9303729













  • thank you @Sukumar Gorai can't i override it in my custom module using xml file

    – Shubhajay Das
    Nov 20 '18 at 11:10











  • Second method is not working for you?

    – Sukumar Gorai
    Nov 20 '18 at 11:11











  • in second method can i use my custom block as i shown in question

    – Shubhajay Das
    Nov 20 '18 at 11:58











  • Why do you need to change the block class?

    – Sukumar Gorai
    Nov 20 '18 at 13:23











  • i have to change it as per my requirement condition

    – Shubhajay Das
    Nov 20 '18 at 13:39



















  • thank you @Sukumar Gorai can't i override it in my custom module using xml file

    – Shubhajay Das
    Nov 20 '18 at 11:10











  • Second method is not working for you?

    – Sukumar Gorai
    Nov 20 '18 at 11:11











  • in second method can i use my custom block as i shown in question

    – Shubhajay Das
    Nov 20 '18 at 11:58











  • Why do you need to change the block class?

    – Sukumar Gorai
    Nov 20 '18 at 13:23











  • i have to change it as per my requirement condition

    – Shubhajay Das
    Nov 20 '18 at 13:39

















thank you @Sukumar Gorai can't i override it in my custom module using xml file

– Shubhajay Das
Nov 20 '18 at 11:10





thank you @Sukumar Gorai can't i override it in my custom module using xml file

– Shubhajay Das
Nov 20 '18 at 11:10













Second method is not working for you?

– Sukumar Gorai
Nov 20 '18 at 11:11





Second method is not working for you?

– Sukumar Gorai
Nov 20 '18 at 11:11













in second method can i use my custom block as i shown in question

– Shubhajay Das
Nov 20 '18 at 11:58





in second method can i use my custom block as i shown in question

– Shubhajay Das
Nov 20 '18 at 11:58













Why do you need to change the block class?

– Sukumar Gorai
Nov 20 '18 at 13:23





Why do you need to change the block class?

– Sukumar Gorai
Nov 20 '18 at 13:23













i have to change it as per my requirement condition

– Shubhajay Das
Nov 20 '18 at 13:39





i have to change it as per my requirement condition

– Shubhajay Das
Nov 20 '18 at 13:39


















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f250608%2fhow-to-override-proceed-to-checkout-button-in-cart-page-in-magento-2%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

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto