Skip to main content

Posts

Magento 2 Minicart - Display line item subtotal rather than unit price

url: https://magento.stackexchange.com/questions/173028/magento-2-minicart-display-line-item-subtotal-rather-than-unit-price     Final Solution, You can get item qty using $qty = $item->getQty(); Now just you have to set $block->getUnitDisplayPriceInclTax()*$qty to get lineItem subtotal for each item. app/design/frontend/{Packagename}/{themename}/Magento_Weee/templates/checkout/cart/item/price/sidebar.phtml   <?php /** @var $block \Magento\Weee\Block\Item\Price\Renderer */ $item = $block ->getItem(); $originalZone = $block ->getZone(); $block ->setZone(\Magento\Framework\Pricing\Render::ZONE_CART); /* custom logic*/ $qty = $item ->getQty(); ?> <?php if ( $block ->displayPriceInclTax() || $block ->displayBothPrices()): ?> < span class = "price-including-tax" data-label = " <?php echo $block ->escapeHtml(__( 'Incl. Tax' )); ?> " > <?php if ( $block ->displayPriceWithWeeeDetai...
Recent posts

Magento 2 get cart totals

 <?php $totals = $block->getTotals() ; ?> <table class="data table totals">     <tbody>         <?php foreach($totals as $key => $total) :?>             <?php if(!empty($total->getValue())) :?>                 <tr>                     <td><?= $total->getTitle()->getText() ?></th>                     <td>                         <span class="price"><?= $this->helper('Magento\Framework\Pricing\Helper\Data')->currency(nu...

Magento 2 Get Cart Quote Total in minicart.phtml

  This Below line is workig for all cases if cache is enable its working fine, < span data-bind = "html: getCartParam('subtotal')" > </ span >     Add this in  minicart.phtml <?php $quote = $block ->getTotalsCache(); $getSubTotal = $quote [ 'subtotal' ]->getData( 'value' ); $getGrandTotal = $quote [ 'grand_total' ]->getData( 'value' ); $getShippingRate = $quote [ 'shipping' ]->getData( 'value' ); $finalSubTotal = $this ->helper( 'Magento\Framework\Pricing\Helper\Data' )->currency(number_format( $getSubTotal , 2 ), true , false ); $finalShippingTotal = $this ->helper( 'Magento\Framework\Pricing\Helper\Data' )->currency(number_format( $getShippingRate , 2 ), true , false ); $finalGrandTotal = $this ->helper( 'Magento\Framework\Pricing\Helper\Data' )->currency(number_format( $getGrandTotal , 2 ), true , f...

script to change single product add to cart text

  add this in addtocart.phtml page <script>     require([         'jquery',         'mage/mage',         'Magento_Catalog/product/view/validation',         'Magento_Catalog/js/catalog-add-to-cart'     ], function ($) {         'use strict';         $('#product_addtocart_form').mage('validation', {             radioCheckboxClosest: '.nested',             submitHandler: function (form) {                 var widget = $(form).catalogAddToCart({                     bindS...

add minicart to custom header

 <move element="minicart" destination="Custom_header" before="-" />     <!--referenceContainer name="page.wrapper" remove="true"/-->         <referenceBlock name="header.container" remove="true" />            <referenceContainer name="page.wrapper">             <block class="Magento\Framework\View\Element\Template"             name="Custom_header"             template="Magento_Theme::html/customheader.phtml"             before="-"/>                             </referenceContainer> ////*****************************************************************////...

Solution to Change Currency Symbol Position in Magento 2

Note : You can use any extension   1. Create events.xml file at app/code/vendor/Exenstion/etc/frontend   <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">     <event name="currency_display_options_forming">         <observer name="change_currency_position" instance="vendor\Exenstion\Observer\ChangeCurrencyPosition"/>     </event> </config>  2. Create ChangeCurrencyPosition.php  file at app/code/vendor/Exenstion/Observer   <?php namespace vendor\Exenstion\Observer; use Magento\Framework\Event\ObserverInterface; class ChangeCurrencyPosition implements ObserverInterface {     public function execute(\Magento\Framework\Event\Observer $observer)     {      ...