WordPress has become the most widely used content management system (CMS) with 60 percent market share. It’s no surprise that the WooCommerce plugin has become one of the most widely used e-commerce solutions which now rivals other major standalone ecommerce solutions such as Magento, Shopify, Zen Cart and many others.
Not only is WooCommerce an e-commerce component that easily integrates into WordPress but it also works efficiently if you’re looking to run a basic product catalog to showcase products or run an affiliate based website.
On two separate websites I’ve added the following code which is an accordion based contact form which is displayed on WooCommerce product pages. The code works to display the contact form on the same page rather than having them click a button and be redirected to a new page.
I’ll admit this code can be more elegantly written but for all intensive purposes it offers a solution that many would find useful. I’ve also searched other WordPress and PHP forums for a similar solution similar however none seem to exist so I decided to share my own solution which is derived from some code I found posted on JSFiddle.
When button is clicked:
Add the following code below to your functions.php file: