pixelperfectat / magento2-module-discount-lines-luma
Luma cart and checkout renderer for the Discount Lines module: one totals line per discount
Package info
github.com/pixelperfectat/magento2-module-discount-lines-luma
Language:JavaScript
Type:magento2-module
pkg:composer/pixelperfectat/magento2-module-discount-lines-luma
Requires
- php: ^8.3
- magento/framework: ^103.0
- magento/module-checkout: ^100.0
- magento/module-sales-rule: ^101.0
- pixelperfectat/magento2-module-discount-lines: ^1.0
Requires (Dev)
- infection/infection: ^0.35
- phpunit/phpunit: ^9.6
- pixelperfectat/coding-standard: ^0.2.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-01 15:41:40 UTC
README
Renders one totals line per discount (coupon, automatic rule, gift, free shipping) in the Luma cart summary and the
Luma checkout sidebar, using the data and display variant (A to D) provided by
pixelperfectat/magento2-module-discount-lines.
Requirements
pixelperfectat/magento2-module-discount-lines- Magento 2.4 with the Luma checkout (KnockoutJS)
Installation
composer require pixelperfectat/magento2-module-discount-lines-luma bin/magento setup:upgrade
How it works
- A RequireJS mixin on
Magento_SalesRule/js/view/summary/discount(checkout sidebar) andMagento_SalesRule/js/view/cart/totals/discount(cart page) swaps the template forPixelPerfect_DiscountLinesLuma/summary/discount-linesand reads the lines fromtotals().total_segments[discount].extension_attributes.discount_lines. They update together with the totals. Without lines (module disabled, or a quote without stored lines) the core title and value are rendered. - Variant, icon URLs and translated texts reach the browser through
window.checkoutConfig.ppDiscountLines(Service\CheckoutConfigProvider). - The "You save" sum of variant C is calculated in the browser in integer cents and only shown with more than one line.
- Labels and codes are bound with
text:only; rule descriptions never reach the page. - The remove button on a coupon chip is a real button with the label "Remove coupon CODE". In the checkout sidebar it
calls the core
cancel-couponaction (totals update in place). On the cart page it posts the cart coupon form (checkout/cart/couponPost,remove=1), because that page renders its coupon form on the server. - Loads the base stylesheet
PixelPerfect_DiscountLines::css/discount-lines.css;view/frontend/web/css/source/_module.lessonly resets Luma's table and button styles for the lines. Colours come from the CSS custom properties--pp-dl-chip-bg,--pp-dl-chip-ink,--pp-dl-auto-bg,--pp-dl-auto-inkand--pp-dl-save; override them on:rootin your theme.
Variants
Set under Stores > Configuration > Sales > Discount Lines: A (label with chip below), B (chip as the label, default), C (grouped block with "You save" total), D (quiet icon and monospace).
Configuration
Configured in the base package under Stores > Configuration > Sales > Discount Lines (store-view scope):
pp_discount_lines/general/enabled (default 1) and pp_discount_lines/display/variant (A to D, default B).
See the base README for the full table.
Contract
The data this package renders (extension_attributes.discount_lines, row data key discount_line, the label rule
and the line kinds) is described in the
contract section of the base README.
Known limits
- Orders placed before the base module was installed keep the merged core row.
- Existing carts show the core row until the next totals collect.
- A line list is shown whenever lines exist, even when core would hide the discount row (a quote with only a gift or free-shipping line).
- On the cart page the coupon remove button posts the cart coupon form, because that page renders its coupon form on the server.
- See the base README for the complete list of known limits.
Screenshots
Placeholder data only, in docs/screenshots/:
Development
composer install composer check
composer check runs composer validate, PHP lint, PHP_CodeSniffer, PHPStan, PHPUnit and Infection mutation testing
(fails below MSI 85 or covered-code MSI 90). Infection needs a coverage driver: enable pcov, or Xdebug with
XDEBUG_MODE=coverage. composer infection runs the mutation tests on their own.
License
MIT, see LICENSE.