Rule 1: a question is a WordPress comment
A question is a comment of type gmqa_question on the product. An answer is a comment of type gmqa_answer whose parent is the question. That one decision hands four jobs to WordPress:
- Moderation — the Comments screen, where both types appear in the type filter as Product questions and Product answers.
- Spam — a question goes in through WordPress' own
wp_new_comment(), so its flood check, duplicate check and comment blocklist run, and your anti-spam plugin sees it. - Privacy — WordPress' personal data exporter and eraser find a question by its author's address like any other comment. The plugin registers its own exporter and eraser beside them for what it adds (whether the asker asked to be emailed, and a buyer's order).
Every question and every answer posted from the storefront is held for moderation, whatever WordPress' own comment settings would have decided. An approved question is your decision, not a returning commenter's. Spam stays spam.
A question is at most 2,000 characters.
Rule 2: nothing is public until it is answered
A question is shown only when it is approved and has at least one approved answer. An approved question nobody has answered is as invisible as a pending one: an unanswered question at the top of a product page costs sales, and a public queue is an invitation to spam.
Answering is the moderation decision. When you press Answer and publish, the question is approved first and then your answer is published.
The tab shows up to 50 answered questions. Each reads "Q:" then "A:", and an answer from a past buyer carries Bought this product after their first name.
Questions stay out of your reviews
WooCommerce counts reviews and averages star ratings by comment type, so a question is outside both. The plugin also keeps both comment types out of the product's comment count, out of storefront comment lists such as the reviews list, and out of the comment feeds. In wp-admin they stay visible, because that is where you moderate them.
The ask form
The form is an ordinary form post that works with no JavaScript.
- A signed-in customer asks as themselves; a name or address typed in the form is ignored.
- A guest gives a name and an email address (unless Let shoppers who are not signed in ask is off).
- A hidden field no person can see catches simple bots. A bot that fills it is told its question was sent, and nothing is stored.
- The form carries a nonce. A page served from a full-page cache for more than a day may carry an expired one; the shopper is told "The page had been open too long. Please reload it and try again."
The asker's email: opt-in, and sent once
The box Email me when my question is answered is never ticked for anybody. When the first answer to a question becomes public, the asker is emailed "Your question about product has been answered" with the question, the answer and a link to the product.
The question is claimed first, by writing _gmqa_notified on it, and the email goes only if that claim succeeded. A second answer, or an answer unapproved and approved again, never sends a second email.
One FAQPage block, shared with Gatemi Product Info
Two FAQPage blocks on one page is a rich-result problem. So Product Questions and Gatemi Product Info share one block through two filters, the same in all four plugins:
gatemi_faq_schema_owner— Product Info answersgatemi-product-infowhenever it will print the block. When somebody owns the block, Product Questions only adds to it.gatemi_faq_schema_items— the list of plain-text question-and-answer pairs. Product Questions adds its answered questions at priority 20, skipping any question already in the list, and only on products where its tab is shown.
With Product Info active there is one block, Product Info's, with Product Info's own questions first and the answered customer questions after — even on a product with no Product Info questions. Without Product Info (or with its full edition's structured data switched off), Product Questions prints the block itself. Either way there is exactly one. Full edition: with Most helpful first, the answer named in the block is the one the page lists first.
See How Gatemi Product Info works for the other side of the contract.
Asking past buyers — Full edition
With When a question is approved, email it to people who bought the product on:
- Approving a question schedules one background run a minute later (cron hook
gmqa_ask_buyers). Nothing is sent from the request that approved it. Ask past buyers on the waiting list schedules the same run. - The run looks through the store's processing and completed orders, newest first — 50 at a time, up to 500 orders in one run — for orders containing the product (a variation counts as its product). A run that reaches 500 orders with buyers still to find records the page it got to on the question (
_gmqa_scan_page) and queues another run, which carries on from there. Once every order has been read, the marker is removed and the next run starts from the newest again. - Each buyer's address is written onto the question before their email is sent, so one buyer is asked about one question once, however many runs there are. The asker is never asked. One address is asked once, whatever its capitalisation.
- At most Buyers asked per question buyers are asked, counted across runs, and only while the question is public-ready and still unanswered.
The email "A question about product — can you help?" carries a link. The link is signed with your site's secret keys over the question, the order and the order's own key, so it cannot be made up from an order number, and it stops working if the order key changes. When it is opened, the answer box appears on the product page. The answer is checked again on posting — the order must still exist, still be paid for and still contain the product. It is held for you under Answers waiting to be read, and one order answers one question once.
Votes and sorting — Full edition
Helpful (n) under each published answer is a form post. One vote per visitor: a signed-in customer by account, a guest by a random cookie (gmqa_visitor) whose hash is stored — never the cookie itself, never an address. With Most helpful first, answers are listed by votes and questions by their best answer.
CSV import — Full edition
Import questions and answers takes a CSV with a question column, an answer column and a sku or product_id column; name is optional. Headers are matched loosely (Q, A, Product ID, Asked By, author), the delimiter is detected, and a spreadsheet's byte-order mark is ignored.
- Every imported row is published as answered by the shop. A row with no answer is skipped, because an unanswered question is never public.
- Each question is fingerprinted, so a file run twice imports once.
- Preview only — decide everything and write nothing is ticked by default. The preview finds exactly the problems the real run would.
- Every problem is reported by line. A run takes at most 2,000 rows.
