cancel
Showing results for 
Search instead for 
Did you mean: 

Discount Price on minicart

Discount Price on minicart

I would like to display Discount Price and Tax Price on minicart, but the code following not work

 

DiscountPrice.png

 

formatPrice($this->getDiscountAmount())

formatPrice($this->getQuote()->getTaxAmount())

 

Please help

4 REPLIES 4

Re: Discount Price on minicart

@hea hooi_ngoi

 

are these lines not working for you? or what issue you are facing?

 

$this->getDiscountAmount()

 

$this->getQuote()->getTaxAmount()

Manish Mittal
https://www.manishmittal.com/

Re: Discount Price on minicart

Hi Manish Mittal,

 

I would like to display discount amount and tax amount on minicart, but it show 0 figure, may I know the correct coding to display the amount. Please advise.

 

Regards,

Ngoi

Re: Discount Price on minicart

Hi Manish Mittal,

 

Below are the code for Discount and Tax Amount, correct me if wrong:

 

                <div class="subtotal-">
                    <?php if ($canApplyMsrp): ?>
                        <span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
                    <?php else: ?>
                        <span class="label"><?php echo $this->__('Cart Discount:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getDiscountAmount()) ?>
                        <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
                            <br />
                            <span class="incl-tax">(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)</span>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>

                <div class="subtotal-">
                    <?php if ($canApplyMsrp): ?>
                        <span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER'); ?></span>
                    <?php else: ?>
                        <span class="label"><?php echo $this->__('Cart Tax:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getTaxAmount()) ?>
                        <?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
                            <br />
                            <span class="incl-tax">(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)</span>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>

Re: Discount Price on minicart

extend Customer Cart class:

namespace <Vender>\Checkout\CustomerData;

class Cart extends \Magento\Checkout\CustomerData\Cart

public function getSectionData(){
     return [
            'tax' => $totals['tax']->getValue(),
      ];
}

 On minicart page:

<div><?= __("Total") ?><span data-bind="text: getCartParam('tax')"></span></div>