Addons

Product Q&A

Collect shopper questions directly on product pages, moderate them in wp-admin, and show approved answers inline. Everything ships in the free build.

Components

  • Frontend block: Injected via kitbix_commerce_after_product. Layout can be accordion or card.
  • REST API: /kitbix-commerce/v1/product-qna handles submissions, /product-qna/moderation powers the admin table.
  • Database: Installer creates the kitbix_product_qna table on bootstrap.
  • Admin UI: Adds “Product Q&A” under Kitbix Commerce with pending counts and moderation actions.

Settings reference

Field Key Description
Layout Style layout_style Dropdown with “Accordion” and “Card”. Determines markup class names so your theme can target them.

Submission lifecycle

  1. A visitor fills the question form (name + email required) rendered by views/product-qna.php.
  2. JavaScript posts to the REST endpoint with a transient-backed nonce (createSubmissionToken()).
  3. ProductQnaEntry::create() stores the submission in pending status unless a duplicate pending entry exists for the same email/product.
  4. Moderators answer or approve entries from Kitbix Commerce → Product Q&A, which updates status via the moderation REST routes.
  5. Approved entries render on the product page with relative timestamps supplied by formatEntries().

Testing checklist

  • Enable the addon in Kitbix Commerce → Addons and choose a layout.
  • Submit a question as a customer (check browser console for REST errors).
  • Approve the question in wp-admin; confirm it flips to “Published” and appears on the product page.
  • Switch the layout setting and reload; markup should update without cache clears.

Common pitfalls

  • Nonce failures when caching forms aggressively. Regenerate by reloading the product page.
  • No email provided → submission rejected with status 422 (handled in UI, but log this when debugging).
  • Expecting auto-publish. Every entry starts Pending; add SOPs so support reviews daily.
Reminder: Disabling the addon keeps existing entries in the database. Re-enable later and they’ll display again.