QuoteAdditionalData
GitHub - magesuite/quote-additional-data
This module adds additional data to customerData. Frontend developers can use this data to customize the mini-cart.
Installation
This module is required by theme-creativeshop and is installed out of the box when theme-creativeshop is required
composer require "creativestyle/magesuite-quote-additional-data" ^1.0.0
Admin settings
Stores > Configuration > MageSuite > Quote Additional Data
Under the General
tab, Is Enabled
should be set to yes
Backend
It can be easily extended by implementing one of these interfaces:
MageSuite\QuoteAdditionalData\Api\QuoteAdditionalDataProcessorInterface
MageSuite\QuoteAdditionalData\Api\QuoteItemAdditionalDataProcessorInterface
Then processor needs to be added to the list in di.xml
file in the customization module:
<type name="MageSuite\QuoteAdditionalData\Plugin\Checkout\CustomerData\AbstractItem\AddAdditionalDataToQuoteItem">
<arguments>
<argument name="additionalDataProcessors" xsi:type="array">
<item name="productOriginalPrice" xsi:type="object">MageSuite\QuoteAdditionalData\Model\Checkout\CustomerData\QuoteItemAdditionalDataProcessor\ProductOriginalPrice</item>
</argument>
</arguments>
</type>
<type name="MageSuite\QuoteAdditionalData\Plugin\Checkout\CustomerData\Cart\AddAdditionalDataToQuote">
<arguments>
<argument name="additionalDataProcessors" xsi:type="array">
<item name="rowTotalProductPrice" xsi:type="object">MageSuite\QuoteAdditionalData\Model\Checkout\CustomerData\QuoteAdditionalDataProcessor\RowTotalProductPrice</item>
<item name="discountPercentage" xsi:type="object">MageSuite\QuoteAdditionalData\Model\Checkout\CustomerData\QuoteAdditionalDataProcessor\DiscountPercentage</item>
</argument>
</arguments>
</type>
By default, all processors are enabled but there is a possibility to disable a specific processor:
<type name="MageSuite\QuoteAdditionalData\Model\Checkout\CustomerData\QuoteAdditionalDataProcessor\DiscountPercentage">
<arguments>
<argument name="isEnabled" xsi:type="boolean">false</argument>
</arguments>
</type>
ย
Frontend
ย
There are new entries in CustomerData:
discount_percentage
product_original_price
row_total_product_original_price
They are used in theme-creativeshop/src/Magento_Checkout/web/template/minicart/item/default.html at next ยท magesuite/theme-creativeshop HTML template.
If Additional quote data is enabled and data is present, there is a special price displayed in minicart. discount_percentage
is not currently used in theme-creativeshop, but can be used in child projects to display a discount badge on minicart products.
Example code:
<!-- ko if: item.discount_percentage -->
<div class="cs-minicart-product__discount">
<span class="cs-minicart-product__discount-text" data-bind="text: item.discount_percentage + '%'"></span>
</div>
<!-- /ko -->
row_total_product_original_price
is also available in checkout summary templates, however, theme-creativeshop does not display special prices or discount badge on checkout summary items.
ย
Code example from overridden: Magento_Weee/web/template/checkout/summary/item/price/row_incl_tax.html
file:
<span data-bind="attr: {class: $parents[2].row_total_product_original_price ? 'cart-price cart-price-with-special' : 'cart-price'}">
<span class="price" data-bind="text: getFormattedPrice(getRowDisplayPriceInclTax($parents[2]))"></span>
<span class="old-price" if="$parents[2].row_total_product_original_price" data-bind="html: $parents[2].row_total_product_original_price"></span>
</span>
Styling
Styling of special price is included in theme-creativeshop/src/components/minicart-product/minicart-product.scss
file
$minicart-product_show-special-price
variable should be set to yes in order to include styles.
ย