,

How To Enable Discussion (Questions & Answers) on WooCommerce Single Product Page?

GET IN TOUCH

Need to Fix Your WordPress Site?

If you have purchased anything on Amazon, you might have seen a section called Customer Questions & Answers near the rating & review section. You can find questions & their answers if you search there. These customer’s questions are answered by the Merchant or by the other users.

We are going to build a similar feature for WooCommerce products. On the product single page (PDP), we’ll add another tab called Questions & Answers.

Let’s add some code snippets

It’ll add a new section next to the Reviews Tab.

But we want to give an option where customers can ask Questions. Also, we need to display all the questions & answers.

We can use the comment feature of WordPress as a question box. There is a function called comment_form() to show a comment form. Also, we’ll use wp_list_comments to display all the discussions.

Now the code looks like this. It will create an odd-looking section like below. You can ignore the layout for the time being.

Now we need to refactor the code so we can build a more useable plugin. After a few changes & code refactoring, I’m able to show comments in Tabs & now each Question will be opening on the new page under that product where admin/customers can answer that Question.

Here is the plugin added to GitHub.

Let me explain a few codes from this plugin.

On the Customers Q&As Tab, we are adding a link to Question (Parent Comment) a link. So now the comment would open on a new page with a link like yourstore.com/{product-name}/discussion/{comment_id}

Let’s add some URL rewrite rules.

You can dig deeper into the plugin & explore the code.

Here are the final outcomes.

So this plugin would be adding a new tab on WooCommerce Store PDP for Q&As. Now, customers can ask Questions on the Product page. It can be answered by the admin or store manager in the Reviews section of wp-admin or by going to the question page in the front-end.

Adding Questions to your eCommerce store is a good way to clear doubts & do SEO.

Leave a Reply

Your email address will not be published. Required fields are marked *