- Plugins For WooCommerce
Delivery
Store Essentials
Payments, Product Prices, Currencies
Refunds30 day, no questions asked refund policy
SupportSupport teams across the world
Safe & SecureSafe & Secure online payment
Spend less, get more!
Explore our value-packed WooCommerce plugin bundles
- Case Studies
- Reviews
- Blog
- Plugins For WooCommerce
Delivery
Store Essentials
Payments, Product Prices, Currencies
Refunds30 day, no questions asked refund policy
SupportSupport teams across the world
Safe & SecureSafe & Secure online payment
Spend less, get more!
Explore our value-packed WooCommerce plugin bundles
- Case Studies
- Reviews
- Blog
Overwrite action attribute of WooCommerce Product Review form
Product Reviews are an effective way to help your customers make a decision on the purchase. At Tyche Softwares, we always ask our customers to review our plugins & support on any one of our social media channels. Apart from helping customers make a decision, these reviews also are very encouraging for our team members.
At times, you might want to do some changes in the way the product reviews submitted for WooCommerce products are handled. The changes could be as simple as adding some text to the form or adding a new field or filtering the data that is submitted.
The Product Review form uses the wp-comments-post.php file for adding comments. This is the same file that is used by WordPress for comments from any Posts & Pages as well. If you want to add the reviews in database via some other file, then you will need to change the “action” attribute of the Product Review form.
WordPress provides a filter comment_form_defaults that allows you to change the “action” attribute along with many other parameters. However, if you use that filter to change the “action” attribute, then it will change all the comment forms including that on Posts & Pages.
Instead, we can use another filter provided by WooCommerce woocommerce_product_review_comment_form_args, which only changes the “action” attribute on the Product Review form & not elsewhere. You can add the following code in your plugin or in your child theme’s functions.php file.
In the above example, I have simply pointed the form to a file named comments-post.php within my plugin. The plugin only has a few lines of code:
Adding the above code will submit your Product Review form fields to the comments-post.php file in your plugin & there you can do any changes as you desire. You might want to use a different function instead of the wp_handle_comment_submission() used by WordPress to insert comments in database.
There are several cases when you might want to do that like adding more fields over the default ones, or skipping the validation checks for certain fields.
Increase WooCommerce Store Sales
"This fully customizable plugin has saved us $6,997.81 over the last 5 months in abandoned orders. If you’re on the fence, don’t think twice. Abandoned Cart Pro pays for itself really quickly." - Miroslav Mazalica
Vishal Kothari
Share It:
You may also like
How to Send Customized Email for Custom Order Statuses in WooCommerce?
How to Send Email For Custom Order Status Change in Woocommerce?
How to Automatically Change Order Status Only Within Certain Timeframes in WooCommerce?
How to Send Processing Order Email to Admin Email Notifications in WooCommerce?
5 Best WordPress Hosting Services Comparison for Speed and Security (Get Them If You Also Want to Improve the Performance of Your Woo Site)