pixelperfectat / magento2-module-discount-lines-hyva-theme
Hyvä default theme cart renderer for the Discount Lines module: one totals line per discount
Package info
github.com/pixelperfectat/magento2-module-discount-lines-hyva-theme
Language:HTML
Type:magento2-module
pkg:composer/pixelperfectat/magento2-module-discount-lines-hyva-theme
Requires
- php: ^8.3
- magento/framework: ^103.0
- pixelperfectat/magento2-module-discount-lines: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.6
- pixelperfectat/coding-standard: ^0.2.1
Suggests
- hyva-themes/magento2-default-theme: Hyvä default theme (free, not on Packagist) provides the cart totals this module renders into
- hyva-themes/magento2-theme-module: Hyvä theme module (free, not on Packagist), required by the default theme
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-01 15:41:37 UTC
README
Renders one totals line per discount (coupon, automatic rule, gift, free shipping) on the cart page of the
Hyvä default theme, using the data and display variant
(A to D) provided by
pixelperfectat/magento2-module-discount-lines.
Requirements
pixelperfectat/magento2-module-discount-lines- Hyvä default theme and Hyvä theme module (free, installed from Hyvä's own repository, not from Packagist)
Installation
composer require pixelperfectat/magento2-module-discount-lines-hyva-theme bin/magento setup:upgrade
How it works
- Replaces the
discountblock (Magento_Checkout::php-cart/totals/discount.phtml, re-declared by the theme'sMagento_Taxlayout, so a plain template override would not win) with its own block on thehyva_checkout_cart_indexpage. The Hyvä cart totals are rendered client side with Alpine.js, so the lines are read fromsegment.extension_attributes.discount_linesof the totals data and update together with the totals. Without lines (module disabled, or a quote without stored lines) the original Hyvä markup (title and value) is rendered. - The layout lives in the
hyva_checkout_cart_indexhandle, which Hyvä's theme module only adds when a Hyvä theme is active, so other themes of the same install keep their own cart. Because the theme'sdiscountblock is removed and replaced,referenceBlock name="discount"customisations in your theme must targetpp.discount-linesinstead. - The "You save" sum of variant C is calculated in the browser from the lines, rounded to cents, and formatted with
hyva.formatPrice. - Loads the base stylesheet
PixelPerfect_DiscountLines::css/discount-lines.css. 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. - The remove button on a coupon chip posts the cart coupon form (
checkout/cart/couponPostwithremove=1) throughhyva.postCart, so the cart page reloads its content like it does for the coupon form.
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.
- The Hyvä theme
discountblock is replaced by this package's blockpp.discount-lines; customisations of the original block (referenceBlock name="discount") must targetpp.discount-linesinstead. - Only active on Hyvä themes (layout handle
hyva_checkout_cart_index); other themes keep their own cart. - See the base README for the complete list of known limits.
Screenshots
Placeholder data only, in docs/screenshots/:
Development
composer install composer check
License
MIT, see LICENSE.