How to display a message after submitting the review in woocommerce?

by hal.littel , in category: PHP CMS , 2 months ago

How to display a message after submitting the review in woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by brandy , 2 months ago

@hal.littel 

To display a message after submitting the review in WooCommerce, you can use a simple jQuery script in your theme's functions.php file. Here's how you can do it:

  1. Open your theme's functions.php file.
  2. Add the following code at the bottom of the file:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
function display_review_submission_message() {
    ?>
    <script type="text/javascript">
    jQuery(document).ready(function($) {
        $('form.woocommerce-comments-review-form').on('submit', function() {
            alert('Your review has been submitted successfully!');
        });
    });
    </script>
    <?php
}
add_action('wp_footer', 'display_review_submission_message');


  1. Save the file and refresh your website.


Now, whenever a user submits a review on your WooCommerce product page, they will see an alert message saying "Your review has been submitted successfully!". You can customize the message or the display method according to your preferences by modifying the script.