How can I override a sidebar.phtml from:


I have tried in the following ways:

<referenceBlock name="checkout.cart.item.price.sidebar" template="Eone_GiftProducts::cart/item/price/sidebar.phtml" />


<referenceBlock name="checkout.cart.item.price.sidebar">
      <argument name="template" xsi:type="string">Eone_GiftProducts::cart/item/price/sidebar.phtml</argument>

I have tried even with actions tag for setTemplate call but no success

I have tried to remove this block and re add it with my custom template but there is no way to makes him work.

I also tried to makes this change into checkout_cart_sidebar_item_price_renderers handle but with no success.

I must do it for displaying the original price above the price that was displayed in a cart for gift products, I was able to do it on checkout and checkout/cart pages but not able to do it for minicart component. If i modify directly sidebar.phtml from module-checkout it works like a charm but I cant modify core files.

2 Answers 2


Could creating a new block and removing the existing one be a valid solution for you?

For example:

<referenceBlock name="checkout.cart.item.price.sidebar" remove="true" />

<block class="Magento\Checkout\Block\Item\Price\Renderer" name="eone.checkout.cart.item.price.sidebar" template="Eone_GiftProducts::catalog/product/view/summary.phtml" />

If you go down this route be aware you may need to override this function:

File: vendor/magento/module-checkout/Block/Cart/Item/Renderer.php:521

public function getSidebarItemPriceHtml(AbstractItem $item)
        /** @var Renderer $block */
        $block = $this->getLayout()->getBlock('checkout.cart.item.price.sidebar');
        return $block->toHtml();

Hi this seems not work in any case:

<referenceBlock name="checkout.cart.item.price.sidebar" remove="true" />

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.