Skip to content

Developer notes

Table Content
kv_gr_registries One row per registry: owner user_id, co_owner_email, type, title, owner_names, event_date (midnight, shop time zone), privacy P / L / W, password_hash (password_hash()), access_key (link key), status A / C / D, shipping address s_*, ship_to_owner, storefront_id, company_id (Ultimate storefront), reminder flags.
kv_gr_items Products of a registry: product_id, selected options (JSON) + options_key, qty_wanted, priority 1 to 3, note, company_id of the product (Multi-Vendor).
kv_gr_purchases One row per order line bought from a registry (UNIQUE order_id + cart_item_id): qty, state H held (Incomplete order, 1 hour), R reserved (open), P purchased (paid), V void.
kv_gr_orders Order meta: registry, ship_to_owner, gift_message, from_name. Written per order (Multi-Vendor child orders included).
kv_gr_throttle Fixed-window rate limit buckets (hashed visitor key).
  • A registry line carries extra.kv_gr = {registry_id, item_id, sig}; sig is an HMAC (store secret in storage_data kv_gr_secret) over registry, item and product, set only by the add-on’s own add-to-cart path. The core copies request product_data[..][extra] into cart lines, so Purchases::ref() ignores unsigned or altered references, calculate_cart_items strips them and pre_place_order refuses them; the line options must also match the options of the registry item; the generate_cart_id hook keeps it apart from the same product bought for oneself. Session cart.kv_gr holds the ship choice, the gift message and the from line.
  • pre_place_order: customers only (not for Multi-Vendor child orders, the parent placement of the same cart was checked), re-checks registry status, storefront scope, options and quantities under the named lock kvgr_<db>_<prefix>place (released in place_order or at shutdown), prepares the registrant address.
  • calculate_cart_items / calculate_cart_post: the registrant s_* fields are put into cart.user_data for the calculation and the buyer’s values are restored afterwards.
  • create_order: the new order gets the registrant s_* fields and a staff note in details.
  • place_order: order meta and purchase lines are written for every new order (also for Incomplete orders of online payments, which get no status change from the core). change_order_status_post moves the lines; parent orders (is_parent_order = Y) are skipped.
  • get_order_info: while a mask is on, the registrant street lines are replaced by “Address kept private”. The mask is on for storefront orders.* and checkout.complete, and while a customer-area e-mail about such an order is built (mailer_create_message_before area C, off again in mailer_send_post, the next message or change_order_status_post). Admin, vendor and payment steps never mask.

generate_cart_id, calculate_cart_items, calculate_cart_post, pre_place_order, create_order, place_order, change_order_status_post, delete_order, get_order_info, mailer_create_message_before, mailer_send_post, delete_product_post, post_delete_user, before_dispatch (admin cron fallback). All exist with the same arguments in 4.17.2 and 4.21.2.

Template hooks (storefront): products:buy_now (button, product page only), profiles:my_account_menu, checkout:extra_list (cart), checkout:final_section_customer_notes (checkout), orders:info, index:meta (noindex on registry pages). Admin: orders:detailed_after_content.

  • promotions/schema.post.php: condition kv_gr_completion (statement, cart zone, fn_kv_gift_registry_promo_completion).
  • security/csrf_validation.post.php: every storefront POST of gift_registry needs the form security hash.
  • permissions/admin.post.php: privileges view_gift_registries, manage_gift_registries; vendor_multivendor.post.php: vendors only reach gift_registry.purchases (scoped by runtime.company_id).
  • gdpr/user_data.post.php: owner registries and buyer purchase data for the core export and anonymization.
  • block_manager/blocks.post.php: block kv_gift_registry_finder.

GiftWrap::active() checks addons.kv_gift_wrap_messages.status = A and class_exists('\Tygh\Addons\KvGiftWrapMessages\Orders'); GiftWrap::forOrder($order_id) reads its message, sender and wrap names. Nothing else depends on it.

  • gift_registry.search?q=&type=&month=YYYY-MM
  • gift_registry.view?registry_id=N[&key=K]
  • gift_registry.manage, gift_registry.update[?registry_id=N], gift_registry.items?registry_id=N, gift_registry.thanks?registry_id=N, gift_registry.export?registry_id=N

php admin.php --dispatch=gift_registry.cron (console) or index.php?dispatch=gift_registry.cron&key=<cron key>. One pass sends due reminders and after-event e-mails (claimed with a conditional UPDATE, never twice) and clears old rate limit buckets.

tests/cli/e2e.php (inside a dev store), tests/e2e/e2e.mjs (HTTP: guest, owner, co-owner, buyer, admin, vendor), tests/cli/lifecycle.php (self-repair after an in-place update).