Skip to content

Developer notes

Table Purpose
kv_pm_plans One row per plan product: product_id (unique), usergroup_id, unit (D, M, Y, L), duration, renew_price (NULL = product price), grace_days, perks, status (A, D).
kv_pm_members One row per customer and plan: status (A active, G grace, E expired, C cancelled), joined_at, started_at, expires_at (0 = lifetime), grace_until, reminder marks, secret for signed links.
kv_pm_orders One row per order line that granted time (idempotency): previous and new expiry, was_new, lifetime, revoked.
kv_pm_log History of a membership.

Access is a row in the core usergroup_links table (status A), written with fn_change_usergroup_status(), so every core hook of user groups fires. A group is removed only when no other running membership of the same customer grants it.

change_order_status_post (grant, stack, revoke), pre_add_to_cart, generate_cart_id, get_cart_product_data_post_options (renewal price), pre_place_order (guest check), update_product_post (plan form), delete_product_post, delete_user, delete_order, before_dispatch (admin fallback of the cron pass). Template hooks: products:product_detail_bottom, profiles:my_account_menu, products:tabs_content (admin).

Multi-Vendor splits a mixed cart into a parent order and one order per seller: parent orders (is_parent_order = Y) are skipped, the line is processed in the order that holds it.

schemas/promotions/schema.post.php adds kv_pm_member (operators equal / not equal, zones catalog and cart). The value is a plan id or any. The core label is written to promotion_cond_kv_pm_member at install.

The product page output depends on the plan, never on the visitor. The per-visitor line comes from kv_paid_memberships.status?product_id=... (JSON, Cache-Control: no-store, not a dispatch the page cache stores). block_cache_properties.post.php puts the license state and the kv_pm_plans table into the block cache so a changed plan or license shows at once.

  • Tygh\Addons\KvPaidMemberships\Members::grant($user_id, $plan, $periods, $order_id, $actor) grants or stacks time; ::cancel(), ::extend(), ::setExpiry() are the manual actions.
  • Tygh\Addons\KvPaidMemberships\Plans::forProduct($product_id) returns the active plan of a product.
  • For tests, Notifier::$spy receives the e-mails instead of the mailer, and $config['kv_paid_memberships_mail_off'] = true in config.local.php suppresses and logs them.

PHP 7.4 syntax, Smarty 4 and 5 safe templates (no template plugins; the only PHP function used in a template is fn_kv_paid_memberships_menu_visible), Twig 2 and 3 safe e-mail templates.