1

Magento version: 2.0.0

I try to add the checkout & cart page link to the page header not the toplink, so what's the link of them? I searched my question and got a solution that add a block into the default.xml, but I don't know how to use it in phtml file. so, how to use it?

<block class="Magento\Framework\View\Element\Html\Links" name="top.links">
                <block class="Magento\Framework\View\Element\Html\Link\Current" name="my-link">
                    <arguments>
                        <argument name="label" xsi:type="string" translate="true">My Cart</argument>
                        <argument name="path" xsi:type="string">checkout/cart</argument>
                    </arguments>
                </block>
                <block class="Magento\Framework\View\Element\Html\Link\Current" name="my-link1">
                    <arguments>
                        <argument name="label" xsi:type="string" translate="true">Checkout</argument>
                        <argument name="path" xsi:type="string">checkout</argument>
                    </arguments>
                </block>                   
            </block>

1 Answer 1

5

You can call checkout & cart page link at phtml/block by below code without using layout xml

For PHTML:

Checkout link:

<?php echo $block->getUrl('checkout', ['_secure' => true]);?>

Cart link:

<?php echo $block->getUrl('checkout/cart', ['_secure' => true]);?>

At block class:

Checkout link:

$this->getUrl('checkout', ['_secure' => true]);

and Cart link:

$this->getUrl('checkout/cart', ['_secure' => true]);
0

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.