Discount
https://github.com/magesuite/discount
This module adds extended logic for price discounts.
Â
Installation
This module is required by module MageSuite_Frontend
composer require "creativestyle/magesuite-discount" ^1.0.0
Admin settings
Settings for extended discount logic are placed in:
Stores -> Configuration -> Catalog -> Catalog -> Storefront
Â
Settings:
Field | Options | Note |
---|---|---|
Minimal Sale Percentage | insert number, default: 1 | The discount badge will be visible only if discount is bigger than this value. |
Sale badge visibility on frontend calculated from Special Price |  Yes/No  | When this option is set to "Yes" then product badges visibility will be calculated from Special Price. |
Sale badge percentage calculation type |
| Defines whether percentage should be calculated based on cheapest and most expensive simple product, or biggest percentage between special and regular price within single configuration. |
Backend
TODO - BE documentation and review of documentation is needed
Frontend
On the frontend side, discount helper is used in badge templates
for PDP:
theme-creativeshop/src/Magento_Catalog/templates/product/view/badges/sale.phtml
for product tile:
theme-creativeshop/src/MageSuite_ProductTile/templates/fragments/badge.phtml
Â
XML configuration
Details of discount badge can be configured in XML layout. See theme-creativeshop/src/Magento_Catalog/layout/catalog_product_view.xml
and theme-creativeshop/src/MageSuite_ProductTile/layout/product_tile.xml
Â
PDP configuration
<block class="Magento\Catalog\Block\Product\View\Description" name="product.badge.sale" template="Magento_Catalog::product/view/badges/sale.phtml">
<arguments>
<argument xsi:type="string" name="html_tag">li</argument>
<argument xsi:type="string" name="wrapper_css_class">cs-page-product__badge-item</argument>
<argument xsi:type="string" name="css_class">cs-page-product__badge cs-page-product__badge--discount</argument>
<argument xsi:type="string" name="text_css_class">cs-page-product__badge-text</argument>
<argument xsi:type="string" name="label" translate="true"></argument>
<argument xsi:type="boolean" name="value_display">true</argument>
<argument xsi:type="string" name="value_prefix">-</argument>
<argument xsi:type="string" name="value_suffix">%</argument>
<argument xsi:type="string" name="badge_type">discount</argument>
<argument xsi:type="boolean" name="enable_updating_badge_configurables">true</argument>
<argument xsi:type="string" name="configurables_default_badge_text" translate="true">Up to</argument>
</arguments>
</block>
Â
Product tile configuration
<referenceBlock name="product.tile.badge.discount">
<arguments>
<argument xsi:type="string" name="badge_type">discount</argument>
<argument xsi:type="boolean" name="enable_updating_badge_configurables">true</argument>
<argument xsi:type="string" translate="true" name="configurables_default_badge_text">Up to</argument>
</arguments>
</referenceBlock>
Â
Frontend screens
Â