...
This module adds additional data to CustomerData. This data can be used by frontend developers customerData. Frontend developers can use this data to customize the mini-cart.
...
Info |
---|
This module is required by theme-creativeshop and is installed out of the box when theme-creativeshop is required |
Code Block |
---|
composer require "creativestyle/magesuite-quote-additional-data" ^1.0.0 |
Admin settings
Store->Settings->Configuration->Magesuite->Quote Stores > Configuration > MageSuite > Quote Additional Data
Under the General
tab, isEnabled
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:
Code Block |
---|
<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:
Code Block |
---|
<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 quoteCustomerData:
discount_percentage
product_original_price
row_total_product_original_price
They are used in https://github.com/magesuite/theme-creativeshop/blob/next/src/Magento_Checkout/web/template/minicart/item/default.html html 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 currently in theme-creativeshop, but can be used in child projects in order to display a discount badge on minicart products.
Example code:
Code Block | ||
---|---|---|
| ||
<!-- 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 price 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:
Code Block | ||
---|---|---|
| ||
<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> |
...