2

[Magento 1]

I want to show prices on checkout inclusive of GST (Indian). Currently, it's adding the tax separately on checkout page resulting in increase final price. We would like to configure it in the way that CGST & SGST are bifurcated & displayed, but are not added separately.

Ex. If the price on the product is Rs.1000 & GST amount is 18%, it should show like this on checkout:

Price: Rs.1000

CGST (9%): Rs.90

SGST (9%): Rs.90

Total: Rs.1000

which means the cart shouldn't add the GST separately but it should be inclusive in the final price. Same should appear on email invoices as well. How can I do it?

Also, this shouldn't affect the price on the product page because prices entered by me would be inclusive of all taxes.

0

You can use observer that can change the price correctly.

/** * @param Varien_Event_Observer $observer */ 
    public function applyDiscount(Varien_Event_Observer $observer) 
    {
     /* @var $item Mage_Sales_Model_Quote_Item */ 
    $item = $observer->getQuoteItem(); 
    if ($item->getParentItem()) { 
    $item = $item->getParentItem(); 
    } 
    // Discounted 25% off 
    $percentDiscount = 0.25; 
    // This makes sure the discount isn’t applied over and over when refreshing 

    $specialPrice = $item->getOriginalPrice() - ($item->getOriginalPrice() * $percentDiscount);
     // Make sure we don’t have a negative if ($specialPrice > 0) { $item->setCustomPrice($specialPrice); $item->
    setOriginalCustomPrice($specialPrice); $item->getProduct()->setIsSuperMode(true); } }

http://magentotutorial.org/programmatically-add-product-cart-price-change-magento/

If you want to change label on checkout page/ review page, you need go to

/app/design/frontend/base/default/template/checkout/onepage/review/info.phtml 

find this :

<th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
            <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
            <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
            <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>

and add your`s methods labels. like this :

            <th colspan="<?php echo 'custom label' ?>" class="a-center"><?php echo 'custom'?></th>

that`s all .

With kind regards, Alex.

0

There are two aspects to such an implementation.

One is are the calculation proper or not.

If Yes then its just the template level changes that you need to do. SO search for the template file and modify it.

  • Well, I know that already. I'd appreciate if you have a solution to share. – Mohit Singh Nov 18 '18 at 8:27
0

try this

create etc/sales.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Sales:etc/sales.xsd">
    <section name="quote">
        <group name="totals">
            <item name="CustomDiscount" instance="Vendor\CustomDiscount\Model\Quote\Discount" sort_order="420"/>
        </group>
    </section>
</config>

create Vendor/CustomDiscount/Model/Quote/Discount/discaount.php

<?php
namespace Vendor\CustomDiscount\Model\Quote;

class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
{
    protected $quoteValidator = null;
    protected $_qtyArrays = array();

    /**
     * @param \Magento\Quote\Model\QuoteValidator $quoteValidator
     */
    public function __construct(\Magento\Quote\Model\QuoteValidator $quoteValidator,  \Magento\Store\Model\StoreManagerInterface $storeManager,
            \Magento\Directory\Model\CurrencyFactory $currencyFactory)
    {
        $this->quoteValidator = $quoteValidator;
         $this->storeManager = $storeManager;
        $this->currencyFactory = $currencyFactory;
    }

    public function collect(
    \Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total
    ) {
        parent::collect($quote, $shippingAssignment, $total);
        $appliedCartDiscount);
            $baseDiscount = 10;
           $discount =  $this->_priceCurrency->convert($baseDiscount);
           $total->addTotalAmount('customdiscount', -$discount);
           $total->addBaseTotalAmount('customdiscount', -$baseDiscount);
           $total->setBaseGrandTotal($total->getBaseGrandTotal() - $baseDiscount);
           $quote->setCustomDiscount(-$discount);
       return $this;
        }

        return $this;
    }


    /**
     * Add discount total information to address.
     *
     * @param \Magento\Quote\Model\Quote               $quote
     * @param \Magento\Quote\Model\Quote\Address\Total $total
     *
     * @return array|null
     */
    public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
    {
        $result = null;

        $amount = $total->getDiscountAmount();
        if ($amount != 0) {
            $description = $total->getDiscountDescription();
            $result = [
                'code' => $this->getCode(),
                'title' => strlen($description) ? __('Custom Discount (%1)', $description) : __('Discount'),
                'value' => $amount,
            ];
        }
        return $result;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.