I have created a custom module and create the files like:
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="checkout.cart.methods">
<block class="Vendor\Module\Block\Checkout" name="checkout.cart.methods.onepage.bottom" template="Vendor_Module::onepage/link.phtml" />
</referenceContainer>
</body>
</page>
app/code/Vendor/Module/Block/Checkout.php
<?php
namespace Vendor\Module\Block;
class Checkout extends \Magento\Checkout\Block\Onepage\Link {
/**
* Get quote object associated with cart. By default it is current customer session quote
*
* @return \Magento\Quote\Model\Quote
*/
public function getQuoteData()
{
$this->_checkoutSession->getQuote();
if (!$this->hasData('quote')) {
$this->setData('quote', $this->_checkoutSession->getQuote());
}
return $this->_getData('quote');
}
}
app/code/Adup/Module/view/frontend/templates/onepage/link.phtml
<?php
// if ($block->isPossibleOnepageCheckout()):
// Get all visible items in cart
$quote = $block->getQuoteData();
$items = $quote->getAllVisibleItems();
$saved_settings = $this->helper( 'Vendor\Module\Helper\Data' )->getConfig( 'checkout-settings/general/module_companyid' );
if((!empty($saved_settings)) && is_array($items) && (!empty($items))){
$updated_url = "beta.test.com/?companyid=" . $saved_settings ."&";
foreach($items as $key => $item) {
$prod_quan = $item->getQty();
$prod_sku = $item->getSku();
$updated_url .= 'sku[]='.$prod_sku."&qty[]=".$prod_quan."" . "&" ;
}
$updated_url = rtrim($updated_url, "&");
?> <a class="action primary checkout" href="<?= $updated_url; ?>"><?= /* @escapeNotVerified */ __('Proceed to Checkout') ?></a>
<?php
}
// endif;
This code is working fine with Magento 2.3.5-p2 but Proceed to checkout button not overriding in Magento 2.3.1
Can anyone please help that how to make that code compatible for all Magento 2 versions.