I want to show the Items price striked with discounted price after applying voucher code.
app/code/Vendorr/DiscountShower/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:framework:ObjectManager/etc/config.xsd'>
<type name='MagentoCheckoutModelDefaultConfigProvider'>
<plugin name="AddAttPlug" type="RltSquareDiscountShowerPluginConfigProviderPlugin" />
</type>
</config>
app/code/Vendor/DiscountShower/Plugin/ConfigProviderPlugin
class ConfigProviderPlugin
{
/**
*@var checkoutSession
*/
protected $checkoutSession;
/**
*Constructor
* @param CheckoutSession $checkoutSession
*/
public function __construct(CheckoutSession $checkoutSession)
{
$this->checkoutSession = $checkoutSession;
}
public function afterGetConfig(MagentoCheckoutModelDefaultConfigProvider $subject, array $result)
{
$items = $result['totalsData']['items'];
foreach ($items as $index => $item) {
$quoteItem = $this->checkoutSession->getQuote()->getItemById($item['item_id']);
if ($quoteItem->getDiscountPercent()){
$result['quoteItemData'][$index]['row_total_with_discount'] = $quoteItem->getPrice() - ($quoteItem->getDiscountPercent()/ 100 * $quoteItem->getPrice());
}
}
return $result;
}
}
app/code/vendor/DiscountShower/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.html'
},
getValue: function(quoteItem) {
return this.getFormattedPrice(quoteItem['discount_amount']);
}
});
}
);
app/code/Vendor/DiscountShower/view/frontend/requirejs-config.js
var config = {
map: {
'*': {
'Magento_Checkout/js/view/summary/item/details/subtotal': 'Vendor_DiscountShower/js/checkout/summary/items/details/subtotal'
}
}};
What is I am doing wrong?