1

Product sale price is custom (different from price-saleprice). Now i want to show row total based on Original mrp(Mrp*qty). Its displaying row total based on custom (sale price * qty). I did below to achieve this Created di.xml

 <?xml version="1.0"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

<type name="Magento\Checkout\Model\DefaultConfigProvider">
    <plugin name="AddAttPlug" type="[company]\[module]\Model\Plugin\ConfigProviderPlugin" />
</type>
</config> 

namespace [company][module]\Model\Plugin;

class ConfigProviderPlugin extends \Magento\Framework\Model\AbstractModel
{

public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $subject, array $result)
{

    $items = $result['totalsData']['items'];

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    for($i=0;$i<count($items);$i++){

        $quoteId = $items[$i]['item_id'];
        $quote = $objectManager->create('\Magento\Quote\Model\Quote\Item')->load($quoteId);
        $originalRowTotal = $quote->getOriginalPriceRowTotal();

        $items[$i]['original_row_total'] = $originalRowTotal;
    }
    $result['totalsData']['items'] = $items;
    return $result;
}

}

[company]/[module]/view/frontend/web/js/checkout/summary/items/details/subtotal.js

define(
[
    'Magento_Checkout/js/view/summary/abstract-total'
],
function (viewModel) {
    "use strict";
    return viewModel.extend({
        defaults: {
            displayArea: 'after_details',
            template: 'Magento_Checkout/summary/item/details/subtotal'
        },
        getValue: function(quoteItem) {
            return this.getFormattedPrice(quoteItem.original_row_total);
        }
    });
}
);

I am getting the value right on proceed to checkout but when i go to next step payment and review that value is going to 0.And form payment review to back to shipping step its again going to 0. row total row total is zero

0
class ConfigProviderPlugin 
{

  /**
    *@var checkoutSession
    */
    protected $checkoutSession;

    /**
    *Constructor
    * @param CheckoutSession $checkoutSession
    */
    public function __construct(CheckoutSession $checkoutSession)
    {
        $this->checkoutSession = $checkoutSession;
    }
    public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $subject, array $result)
    {
        $items = $result['totalsData']['items'];
        foreach ($items as $index => $item) {
          $quoteItem = $this->checkoutSession->getQuote()->getItemById($item['item_id']);
          $result['quoteItemData'][$index]['original_row_total'] = $quoteItem->getOriginalPriceRowTotal();
        }
       return $result;
    }
}

I just replace configProvidePlugin class with above class.

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.