Skip to content

Developer notes

Technical reference for developers who customize Store Holiday Mode.

Item Value
Add-on id kv_store_holiday_mode
Function prefix fn_kv_store_holiday_mode_
Language variables kv_store_holiday_mode.*
CSS scope .kv-shm-*
PHP namespace Tygh\Addons\KvStoreHolidayMode

The running period is a date-driven fact: start_ts <= now < end_ts in ?:kv_shm_periods, never a session value. start_ts and end_ts are UTC timestamps computed from the saved calendar days and the store time zone (Schedule::window()), so storefront pages are identical for every guest and safe for the full page cache. Every request calls Periods::refresh() (hook before_dispatch), which writes only when a boundary was crossed; that write also drops cached pages and block caches that read the period tables. The cron tick does the same at the exact minute and sends the reopening e-mails.

PHP hook Handler Purpose
before_dispatch fn_kv_store_holiday_mode_before_dispatch Refresh the stored window and state.
pre_add_to_cart ..._pre_add_to_cart Catalog-only mode removes non-exempt products from the request.
pre_place_order ..._pre_place_order The server-side guard: refuses an order with non-exempt products in pause and catalog-only modes (storefront, direct posts, REST).
place_order ..._place_order Stores the expected ship date of the order.
get_order_info ..._get_order_info Adds $order['kv_shm'] (ship date and line).
mailer_send_pre ..._mailer_send_pre Adds the ship date line to order e-mails.
delete_order, delete_company Clean up.

Storefront template hooks: index:body (pre), products:product_detail_bottom (pre), products:add_to_cart and buttons:add_to_cart (override, catalog-only mode), checkout:cart_content_bottom_right_buttons (override while checkout is paused), checkout:form_data (pre), checkout:order_confirmation (pre), pages:page_content (pre). Admin: index:alert_block (pre), orders:order_status (post).

The pre-controller checkout.pre.php sends the shopper back to the cart for checkout.checkout, place_order and process_payment while checkout is paused.

Function Returns
fn_kv_store_holiday_mode_get_period() The running period of the current storefront with mode, bar, notice, contact, vars (formatted dates) or null.
fn_kv_store_holiday_mode_get_cart_block($cart) The period when the cart cannot be checked out now, else null.
fn_kv_store_holiday_mode_get_catalog_block($product_id) The period when the product cannot be added to the cart, else null.
fn_kv_store_holiday_mode_get_order_line($order_id) “Your order ships from …” or an empty string.
Table Content
?:kv_shm_periods One row per period: local first and last day, ship date, store time zone, mode, yearly flag, UTC window and state, exemptions, manual override.
?:kv_shm_period_descriptions Texts per language: bar text, notice, contact note.
?:kv_shm_signups Reopening sign-ups (e-mail, language, address bucket, notified time).
?:kv_shm_order_ship The expected ship date promised to an order.

The tables are kept on uninstall unless Delete all data on uninstall is ticked.

SlotsSync::sync() deletes the rows of ?:kv_ddts_holidays whose name starts with SHM#<period id> and writes one closed day per day of the period (up to 90). Rows of the merchant are never touched.

php admin.php --dispatch=kv_store_holiday_mode.tick or admin.php?dispatch=kv_store_holiday_mode.tick&cron_password=... (schemas/permissions/trusted_controllers.post.php lets the anonymous request reach the controller, which checks the core cron password with hash_equals; store-bound Ultimate administrators are denied the mode by vendor_ultimate.post.php). The tick refreshes periods, mails the reopening sign-ups and purges old sign-ups. Set $config['kv_store_holiday_mode_mail'] = false; in config.local.php to make the add-on only log reopening e-mails (always the case on localhost and .test hosts).

Storefront templates live in design/themes/<theme>/templates/addons/kv_store_holiday_mode/. To customize one, copy it to your own theme’s folder; do not edit the add-on’s files, they are replaced on update.