S31 — Parent item groups in coupons and promotions (pp_pgx)
A retailer sets up a coupon for Supplements and expects it to cover every supplement, but the till's coupon and promotion engines match an item's own item group exactly. This sample's service, outside the retailer's iVendNext, writes the parent out as its child groups and keeps it that way: when the coupon or promotion is saved, and when a new group is added under the parent. The rows appear a few seconds after the save, not in the same save. A promotion's buy and get rows are reported, never written out.
The recipe: A coupon or promotion for a parent item group
What is in it: a service that writes a parent item group in a coupon or a promotion out as its child groups.
Industries: Beauty and cosmetics
Start from it
ivn new acme_groups --from s31
What to change
What a partner usually changes:
- Which rows a record needs:
groups.py, the core, which is pure and knows no retailer. - The feed and the writes:
expander.py, the service: the feed, the record API and the ownership store. - Which record types it watches: the feed registration PP PGX Groups in
manifest.json(Coupon, Promotion Bonus Buys Master, Item Group). - The state file:
state/pgx.sqlitelists the rows the service added. Keep it: without it the service takes a person's child rows for its own.
More: the recipe.
The app's role needs: nothing from the retailer's administrator. The install makes the role PP PGX Integration and the app's own user, and gives the role read on Item Group, Coupon and Promotion Bonus Buys Master, the three record types the feed follows. The manifest's role_rights add write on Coupon and on Promotion Bonus Buys Master. Needs POS build 2.1.0.691 or later: on an earlier site the install warns role_rights as unknown and skips it, and gives the feed's user no read, so the events wait; the service's log says which record type was refused (ivn logs) (What goes where).
Run it
ivn check
ivn try
Then run it from your own computer or scheduler (Try does not run it), from service/pgx/ in the app you made, with the key of a user of your own that holds your app's role ending Integration (your prefix, then Integration) (Generate Keys on that user): PGX_KEY=… PGX_SECRET=… python3 expander.py run --base https://shop.example --state state/pgx.sqlite --watch 15. Once, for what exists: PGX_KEY=… PGX_SECRET=… python3 expander.py reconcile --base https://shop.example --state state/pgx.sqlite.
Try it at the till
- Try installs the app but does not run its service. On the tried site, make a user of your own, give it your app's role ending Integration (your prefix, then Integration) and press Generate Keys on it; then run the service as Run it says, with
--base https://<the tried site>. - In Desk, save a coupon whose get row names a parent item group with child groups (or a promotion that excludes one): within seconds it carries a row for each child group.
Versions
0.2.2
- A What is in it line, so Made says what the app holds. Try it at the till says Try does not run this service, how to run it against the tried site, and what you then see; its card on New app says it is your own service outside iVendNext, as S26's and S27's do, not settings in Desk (its needs card's door is Outside app, and the configuration card Prices, promotions and coupons no longer names S31 as its sample). Words only.
0.2.1
- Run it gives the command that keeps the groups written out, and says Try does not run it. Words only; no service or rule changes.
0.2.0
- Write on Coupon and on Promotion Bonus Buys Master moves into the manifest (
role_rights), and the install gives the feed's user its reads, so the retailer's administrator grants none. Needs POS build2.1.0.691or later.
0.1.0
- First version in the kit: parent item groups in coupons and promotions.
- The set-up steps say the install makes the app's own user (POS 2.1.0.667 or later).
Needs this serves
- A coupon for Supplements should cover every supplement, Protein and Vitamins included — Ready, with limits (5)