Magento2 get cart and checkout link in block or phtml
In Magento2 get cart and checkout link in block or phtml then you need to call getUrl() method.It is every easy to get those url at Phtml or block class.
Also, there is no need to write layout xml code for getting cart and checkout page url at magento 2.
If want to get cart & checkout link at PHTML file then try below code:
Checkout Url
<?php echo $block->getUrl('checkout', ['_secure' => true]);?>
Cart Url
<?php echo $block->getUrl('checkout/cart', ['_secure' => true]);?>
If you want to call at block class try with
Checkout link:
$this->getUrl('checkout', ['_secure' => true]);
and Cart link:
$this->getUrl('checkout/cart', ['_secure' => true]);
I hope this will help lots.
No comments:
Post a Comment