Developer guide

Architecture, stored data, endpoints, templates, JavaScript events and examples. All hooks are listed in the Hooks reference.

FreePro

Architecture

FreePro
NamespaceSiteryn\SiterynRequestAQuoteSiterynPro\SiterynRequestAQuote
BootPlugin::run() on plugins_loaded once PHP, WordPress and WooCommerce are confirmed, then siteryn_raq_loadedBoots on siteryn_raq_loaded, fires siteryn_raq_pro_loaded; rules, workflow, PDFs, emails and negotiation run only while licensed (siteryn_raq_pro_features_loaded)
Extension APIPlugin::API_VERSION = 1.0Requires Free 1.0.0 and API 1.0
Handlessiteryn-raq (storefront CSS and JS), admin siteryn-raq-adminsiteryn-raq-pro (storefront CSS and target-price JS), siteryn-raq-pro-admin, plus a rules script on the Quote Rules tab
Settings pageadmin.php?page=siteryn-request-a-quote, tabs general, button, quote_page, form, emails, quotes, go_premium, system_statusSame page, tabs pro_rules, pro_workflow, pro_negotiation, pro_pdf, pro_emails, pro_license
Capabilitymanage_woocommerce for the settings page, quote requests and every admin action

Free's admin is built from a field registry: Pro adds its tabs through siteryn_raq_settings_sections and siteryn_raq_settings_fields and saves into its own option registered with Settings::register_addon_option().

Data stored

WhereKeyContents
Optionssiteryn_raq_settingsFree settings
siteryn_raq_version · siteryn_raq_page_idInstalled version · the automatically created quote page
siteryn_raq_pro_settings · siteryn_raq_pro_rules · siteryn_raq_pro_versionPro settings · quote rules (not autoloaded) · Pro version
siteryn_raq_pro_license_key · _status · _updatePro license data
Post typesiteryn_raq_quoteQuote requests (not public, no REST). Statuses siteryn-raq-new; Pro adds siteryn-raq-review, -sent, -accepted, -rejected (Declined), -expired, -ordered
Post meta_siteryn_raq_customer, _customer_id, _email, _message, _items, _fields, _currency, _locale, _languageThe request: contact details, items snapshot (product, variation, name, attributes, SKU, quantity, price, data, meta), extra form fields
_siteryn_raq_pro_offer, _pro_access_hash, _pro_notes, _pro_order_idPro: offer (prices, valid until, message, sent time), hashed customer link key, history (up to 200 entries), linked order
User meta{prefix}siteryn_raq_itemsA logged-in customer's quote list
WooCommerce sessionsiteryn_raq_items, siteryn_raq_form_flash, siteryn_raq_last_quoteA guest's list; form errors for the no-JS reload; the last sent request (for the thank-you page)
Order meta_siteryn_raq_quote_idPro: the quote an order was created from (created_via = siteryn-request-a-quote)
Transientssiteryn_raq_rl_*, siteryn_raq_done_*, siteryn_raq_outdated_templatesRate limit counters (1 hour), duplicate-submission guard (1 day), outdated-template cache (1 day)
Cronsiteryn_raq_pro_expire_offers (daily) · siteryn_raq_pro_license_refresh (twice daily)Pro only

Endpoints

Storefront requests use WooCommerce's ?wc-ajax= endpoint, are POST only and check the siteryn_raq_quote_list nonce (a fresh nonce comes back with every response). The URLs are in window.siterynRaq.endpoints.

ActionTypeDoes
siteryn_raq_add_itemwc-ajaxAdd product_id, quantity, variation_id, attribute_*
siteryn_raq_update_item · siteryn_raq_remove_itemwc-ajaxSet quantity of key (0 removes) · remove key
siteryn_raq_get_listwc-ajaxThe list state (count, total quantity, items)
siteryn_raq_submit_quotewc-ajaxSend the request; returns the number and the thank-you HTML
siteryn_raq_pro_item_metawc-ajax (Pro)Save a line's target_price
siteryn_raq_action = add/update/remove/submitPOST fieldThe same actions without JavaScript, with the _siteryn_raq_nonce field
siteryn_raq_save_settings · siteryn_raq_pro_save_rules · siteryn_raq_pro_quote_action · siteryn_raq_pro_licenseadmin-ajaxSave a settings tab · save rules · save/send offer, set status, convert, add note · license actions
siteryn_raq_reset_settings · siteryn_raq_pro_pdfadmin-postReset a tab · download a request's PDF

Query arguments on the quote page: quote-received (thank-you after a no-JS send, only for the session that sent it), and with Pro raq-view + key (customer's quote), raq-pdf (customer PDF download) and raq-response (accept/decline result).

Templates

Copy a template to your theme and edit the copy. An admin notice and System Status tell you when a copy is older than the plugin's @version.

TemplateTheme path
add-to-quote-button.php, quote-list.php, quote-form.php, quote-empty.php, quote-success.php, quote-login-required.php, quote-count.phpyourtheme/siteryn-request-a-quote/
emails/siteryn-raq-admin-new-quote.php, emails/siteryn-raq-customer-quote-received.php, emails/siteryn-raq-quote-details.php and their emails/plain/ versionsyourtheme/woocommerce/emails/…
Pro quote-view.php (customer's quote)yourtheme/siteryn-request-a-quote/pro/quote-view.php
Pro emails/siteryn-raq-pro-customer-quote-sent.php, emails/siteryn-raq-pro-admin-quote-response.php, emails/siteryn-raq-pro-offer-table.php (+ plain)yourtheme/woocommerce/emails/…

Templates receive their variables as documented in each file's header. siteryn_raq_template_args filters them, and siteryn_raq_locate_template can point to another file.

JavaScript

Event on documentWhen
siteryn-raq:readyThe storefront script has started
siteryn-raq:updatedAfter any list change; event.detail is the response data (count, quantity, items, message…)
siteryn-raq:submittedAfter a request was sent; event.detail includes quoteId and number
siteryn_raq_pro_license_changed (admin)The license was activated or deactivated on the settings page; detail.active

window.siterynRaqApi exposes send( action, body ) (queued requests, one at a time), announce( text ), showMessage(), setBusy() and applyState( data ). Configuration is in window.siterynRaq, filterable with siteryn_raq_script_config.

document.addEventListener( 'siteryn-raq:submitted', function ( event ) {
	window.dataLayer = window.dataLayer || [];
	window.dataLayer.push( { event: 'quote_request', quote: event.detail.number } );
} );

CSS

Storefront markup uses .siteryn-raq classes. Your color and radius settings are printed as CSS variables on .siteryn-raq and .siteryn-raq-scope: --siteryn-raq-button-bg, -button-text, -button-border, -button-hover-bg, -button-hover-text, -button-radius, --siteryn-raq-accent and -accent-text. Add more with siteryn_raq_css_vars. The quote page's <body> gets siteryn-raq-quote-page; a hidden price uses .siteryn-raq-pro-hidden-price.

Adding a form field

Fields are arrays with type (text, email, tel, textarea, number, date, select with choices, checkbox), label, required, width (half/full), max_length, placeholder and autocomplete. Extra fields are validated, saved with the request, and shown under Additional details and in the emails.

add_filter( 'siteryn_raq_form_fields', function ( $fields ) {
	$fields['postcode'] = array(
		'type'     => 'text',
		'label'    => 'Delivery postcode',
		'required' => true,
		'width'    => 'half',
	);
	return $fields;
} );

More examples

add_filter( 'siteryn_raq_quote_number', function ( $number ) {
	return 'Q-' . $number;
} );
add_action( 'siteryn_raq_quote_created', function ( $quote_id, $quote ) {
	wp_remote_post( 'https://example.com/hook', array(
		'body' => array( 'number' => $quote->get_number(), 'email' => $quote->get_customer_email() ),
	) );
}, 10, 2 );
add_filter( 'siteryn_raq_max_list_items', function () {
	return 200;
} );