WooCommerce Product Search for Forms
Advanced product search with Select2 for WooCommerce quote forms. Supports product names, SKUs, and variation attributes.
by Wbcom Designs · github.com/vapvarun/wc-product-search-forms · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/vapvarun/wc-product-search-forms/archive/refs/heads/main.zipA WordPress plugin by Wbcom Designs that provides advanced product search functionality with Select2 integration for WooCommerce quote forms. Supports searching by product names, SKUs, and displays variation attributes.
Features
- Advanced product search with Select2 integration
- Search by product name or SKU
- Display product variations with their attributes
- Support for partial SKU matching
- Integration with Gravity Forms
- Auto-populate user data in forms
- Quantity selection for each product
- Responsive and user-friendly interface
Installation
- Download the plugin files
- Upload to your WordPress plugins directory (
/wp-content/plugins/wc-product-search-forms/) - Activate the plugin through the WordPress admin
Directory Structure
wc-product-search-forms/
├── assets/
│ └── js/
│ └── product-search.js
├── includes/
├── languages/
├── readme.txt
├── README.md
└── wc-product-search-forms.php
Configuration
The plugin uses constants for configuration. Edit these in the main plugin file:
// In wc-product-search-forms.php, around line 50
define('WCPSF_PAGE_ID', 10028); // Change this to your quote form page ID
define('WCPSF_FORM_ID', 2); // Change this to your Gravity Form ID
HTML Structure Required
Your form should have these elements:
<!-- Product selection dropdown -->
<select id="product-select" multiple="multiple">
<!-- Options will be loaded via AJAX -->
</select>
<!-- Container for quantity table -->
<div id="product-qty-list"></div>
<!-- Hidden input for form submission (adjust the field ID) -->
<input type="hidden" id="input_2_9" name="input_9" />
Note: The hidden input ID should follow the pattern input_{FORM_ID}_{FIELD_ID}
Usage
- Users can search for products by typing in the Select2 dropdown
- Search works for both product names and SKUs
- Product variations are displayed with their attributes
- Users can select multiple products
- Quantity can be adjusted for each selected product
- Form submission includes product names and quantities
API Endpoints
The plugin creates a REST API endpoint:
GET /wp-json/wcpsf/v1/product-search?q={search_term}
Returns an array of products matching the search term:
[
{
"id": 123,
"text": "Product Name (SKU: ABC123)"
},
{
"id": 456,
"text": "Variable Product – Color: Red, Size: Large (SKU: XYZ789)"
}
]
Hooks and Filters
Actions
wcpsf_before_search- Fired before product searchwcpsf_after_search- Fired after product search
Filters
wcpsf_search_results- Filter search results before returningwcpsf_product_label- Filter product label format
Requirements
- WordPress 5.0+
- WooCommerce 3.0+
- PHP 7.2+
- Gravity Forms (optional, for form integration)
Support
For support and feature requests, please contact Wbcom Designs at https://wbcomdesigns.com/
Author
Wbcom Designs
Website: https://wbcomdesigns.com/
License
GPL-2.0+