Search by

hryvinskyi / magento2-free-gift-admin-ui

hryvinskyi

Admin screens of the free gift modules: the cart price rule action "Free gift for every X spent" with its gift SKUs, and the settings of the spent amount, the cart progress bar goal and the gift line note.

Package info

github.com/hryvinskyi/magento2-free-gift-admin-ui

Type:magento2-module

pkg:composer/hryvinskyi/magento2-free-gift-admin-ui

Statistics

Installs: 2

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.0 2026-11-27 09:22 UTC

This package is auto-updated.

Last update: 2026-11-27 09:26:37 UTC


README

The admin screens of the free gift modules: the action Free gift for every X spent with its gift SKUs on the cart price rule form, and the settings of the spent amount, the free gift goal of the cart progress bar and the gift line note.

What it does for a store

  • A rule form for gifts. Marketing › Promotions › Cart Price Rules, the Actions section: the Apply list offers Free gift for every X spent. Choosing it shows the field Free Gift SKUs, where one or more SKUs are entered separated by commas or new lines; any other action hides the field. The saved SKUs show again, in their saved order and separated by commas, when the rule is opened. Clearing the field and saving removes the rule's gift SKUs.

  • The meaning of the rule's other fields for this action:

    Field Meaning
    Discount Amount gifts per step
    Discount Qty Step (Buy X) amount to spend per step
    Maximum Qty Discount is Applied To the most gifts; empty for no limit

    Websites, customer groups, dates, coupon, Conditions and priority are the ones of every cart price rule; the rule's Actions conditions choose the lines that count towards the spent amount.

  • Settings in one place. Stores › Configuration › Sales › Free Gift holds whether a store view gives free gifts, how the spent amount is counted, the goal of the cart progress bar and the gift line note.

Requirements

  • PHP 8.1 to 8.5.
  • hryvinskyi/magento2-free-gift ^1.1, hryvinskyi/magento2-free-gift-api ^1.0 and hryvinskyi/magento2-cart-progress-bar ^1.0 (its link policy checks Link URL).
  • The platform's Framework, SalesRule, Backend, Config, Store and Ui modules (what composer.json and etc/module.xml declare).

Installation

composer require hryvinskyi/magento2-free-gift-pack
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Configuration

Stores › Configuration › Sales › Free Gift. The section is allowed by the ACL resource Hryvinskyi_FreeGiftAdminUi::config (Free Gift).

General

Path Label Default Scope
free_gift/general/enabled Free Gifts Yes default, website, store view

Set to No for a store view whose carts must never get a free gift, for example one that marketplace orders are imported into: its carts hold no gift line and store no spent amount, and the cart progress bar offers no gift goal there. The gift rules themselves are per website and customer group, so this is the way to leave one store view of a website out.

Spent Amount

How the spent amount of a cart is counted. Read for the website of the cart.

Path Label Default Scope
free_gift/spent/include_tax Include Tax Yes default, website
free_gift/spent/subtract_discount Subtract Discounts Yes default, website

Goal in the Cart Progress Bar

The free gift goal that hryvinskyi/magento2-free-gift-frontend contributes to the bar of hryvinskyi/magento2-cart-progress-bar. Where the bar shows, and whether it shows at all, is set under Cart Progress Bar. All fields below Enabled depend on it.

Path Label Default Scope
free_gift/bar/enabled Enabled No default, website, store view
free_gift/bar/rule_id Rule none default, website, store view
free_gift/bar/priority Priority 10 default, website, store view
free_gift/bar/link_url Link URL none default, website, store view
free_gift/bar/label_initial Initial Message none default, website, store view
free_gift/bar/label_progress Progress Message none default, website, store view
free_gift/bar/label_achieved Achieved Message none default, website, store view
free_gift/bar/label_terms Terms none default, website, store view
  • Rule lists the cart price rules whose action is Free gift for every X spent, as #<id> <name>. The goal is the rule's spend step.
  • Priority orders the goals of the bar: the bar shows the unreached goal with the lowest number first. Whole numbers, 0 or more.
  • Link URL is where a click on the bar leads; empty for a bar that is not a link. It takes exactly the links the bar prints: an address that starts with http:// or https://, or a path on the store that starts with a single / (/lamp.html). Any other value (//other.example/x, ftp://…, javascript:…) is refused on save with a message. The rule is the cart progress bar's link policy, which the bar applies again when it prints the link.
  • The four messages take the placeholders {{goal}} (the amount to spend) and {{goal_left}} (the amount still to spend). Initial Message shows while the cart has spent nothing, Progress Message while the goal is not reached, Achieved Message once it is reached. Terms are the conditions of the offer, shown with the bar.

Gift Line

Path Label Default Scope
free_gift/cart/gift_line_note Gift Line Note none default, website, store view

The note shown under the name of a gift in the cart; empty for no note. A theme's cart item template prints it through the view model of hryvinskyi/magento2-free-gift-frontend.

Registrations

Where What
plugin on Magento\SalesRule\Model\Rule\Metadata\ValueProvider::getMetadataValues (after) adds Free gift for every X spent (free_gift_spent) to the options of Apply
plugin on Magento\SalesRule\Model\Rule\DataProvider::getData (after) adds the gift SKUs of each stored rule to the form data as free_gift_skus
view/adminhtml/ui_component/sales_rule_form.xml the field free_gift_skus in the Actions fieldset and the show and hide rules on Apply
source model Hryvinskyi\FreeGiftAdminUi\Model\Config\Source\GiftRules the options of Rule
backend model Hryvinskyi\FreeGiftAdminUi\Model\Config\Backend\LinkUrl trims Link URL and refuses a link the bar would not print