View Categories

Helpdesk Developer Reference: Shortcode, Post Type and Data

This developer reference for Helpdesk Support Ticketing System for WooCommerce lists the shortcode, endpoint, post type, taxonomies, meta keys, database tables and capability the plugin uses. Settings live at WPFactory > Support Tickets > Settings (also under Support Tickets > Settings). Verified against version 3.0.4.

Shortcode and endpoint #

Name Type What it does
[stsw_user_tickets] Shortcode (no attributes) Outputs the front-end ticket area: the current user’s ticket list, replies and the new ticket form. Shows the WooCommerce login form to visitors who are not logged in.
tickets Rewrite endpoint (EP_PAGES) Adds /my-account/tickets/. Flush permalinks after activation. An order query variable filters the list to one order, for example /my-account/tickets/?order=123.

Post type and taxonomies #

Name Type Notes
stsw_tickets Post type Not public, no REST, supports title only. The ticket message is the post content. Uses capability_type page.
stsw_tickets_status Taxonomy (hierarchical) Default terms Open, In Progress, Closed. The Dashboard counts the slugs open and in-progress.
stsw_tickets_priority Taxonomy (hierarchical) Default terms Low, Normal, High. Color stored in term meta STSWooCommerceProcolor.
stsw_tickets_subject Taxonomy (hierarchical) No default terms. Subject assignee user ID stored in term meta STSWooCommerceProAssignee.

Ticket meta keys #

Meta key Value
STSWooCommerceProticketuser User ID of the customer who opened the ticket
STSWooCommerceProticketagent User ID of the assigned agent
STSWooCommerceProticketorder Linked WooCommerce order ID
images Comma-separated URLs of files attached to the original ticket

Database tables #

Helpdesk creates two custom tables (schema version stored in the stswpro_tickets_table_db_version option):

Table Holds Columns
{prefix}stsw_responses Public responses id, user, post_id, creationdate (GMT), agent, content, attachments (comma-separated attachment IDs)
{prefix}stsw_priv_responses Private notes id, user, post_id, creationdate (GMT), agent, content

When a ticket is permanently deleted, its rows in stsw_responses and its attached media are deleted too. Private notes are not removed.

Capability #

  • stsw_tickets controls access to the Support Tickets menu. The Administrator role gets it on activation, and the role saved in Default User Role for Ticket Assignment gets it on save.
  • The Settings tab and saving settings require the administrator role.
  • Deleting a response over AJAX requires manage_woocommerce or ownership of the ticket.

Hooks #

Hook Type Notes
wpfactory_wc_sts_pro_output_settings Action Fires when the Support Tickets admin page renders. Helpdesk uses it to output its own dashboard and settings.

Helpdesk also hooks into standard WooCommerce filters to add its UI: woocommerce_account_menu_items (Tickets tab), woocommerce_my_account_my_orders_actions (Get Help button), woocommerce_my_account_my_orders_columns (Tickets column) and the woocommerce_view_order action (Tickets section on the order page). You can adjust or remove these with your own callbacks at a later priority.

Example: query a customer’s open tickets #

$tickets = get_posts( array(
	'post_type'   => 'stsw_tickets',
	'numberposts' => -1,
	'meta_key'    => 'STSWooCommerceProticketuser',
	'meta_value'  => get_current_user_id(),
	'tax_query'   => array(
		array(
			'taxonomy' => 'stsw_tickets_status',
			'field'    => 'slug',
			'terms'    => 'open',
		),
	),
) );

Need a hand? Our team answers every ticket on the Helpdesk support forum.