2

I am working on a Magento 2.1.7 shop. To achieve this, I have created a child-theme of Magento Blank.

On the cart page, I have moved the cart totals below the cart products:

<move element="cart.summary" destination="checkout.cart.items" after="checkout.cart.form"/>

I had wrapped the cart products in a Bootstrap panel:

enter image description here

Now I need to end the panel after the cart totals and all the following elements. So I need to know: What is the .phtml file containing the code below?

<div class="cart-summary">
 // More code here
</div>

Or, alternatively, I just want to move the cart summary so that my page turns into:

enter image description here

1 Answer 1

2

That div with "cart-summary" class is not actually a phtml file. It is a container defined in checkout_cart_index.xml like this <container name="cart.summary" label="Cart Summary Container" htmlTag="div" htmlClass="cart-summary" after="-">.

Inside this container you can find some blocks and some of them are rendered using knockout js. If you want to add more code inside that div, just add more blocks inside the container like this:

<referenceContainer name="cart.summary">
    <block name="cart.summary.custom.block" class="My\Module\Block\Class" template="cart/template.phtml" />
</referenceContainer>

Please let me know if you have any other questions.

10
  • So, are you saying that there is no .phtml file with this code <div class="cart-summary"> // More code here </div>? Commented Feb 23, 2018 at 10:38
  • Yes. as you can see, in the container signature there is a htmlTag property with div value and a htmlClass property with cart-summary value which generates the <div class="cart-summary"></div> element. All the code inside this div is rendered by the blocks defined inside the container in layout file.
    – George M
    Commented Feb 23, 2018 at 11:32
  • How do I move it inside <div class="panel-body"></div>? Commented Feb 23, 2018 at 11:58
  • Try to move Bootstrap panel code inside module-checkout/view/frontend/templates/cart.phtml. In this way, all the content from cart page will be wrapped, from cart items to summary. There you can decide if you want to wrap the cart when it is empty or not.
    – George M
    Commented Feb 23, 2018 at 12:13
  • The <div class="panel-body"> closes too... early and does not include the cart summary. Commented Feb 23, 2018 at 13:05

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.