Advertisement
palsushobhan

Skip-store-review-if-no-product-rating-in-review

Dec 28th, 2023
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. class WCFM_Store_review_modifier {
  2.     private $review_rating = null;
  3.     public function __construct($comment_id) {
  4.         $this->set_review_rating($comment_id);
  5.         add_filter('wcfmmp_is_allow_product_review_sync_with_store_review', array(&$this, 'can_sync_with_store_review'));
  6.     }
  7.     public function set_review_rating($comment_id) {
  8.         if ( get_option( 'woocommerce_enable_review_rating' ) == 'yes' ) {
  9.             $this->review_rating = intval( get_comment_meta( $comment_id, 'rating', true ) );
  10.         }
  11.     }
  12.     public function can_sync_with_store_review($is_allowed) {
  13.         return $is_allowed && $this->review_rating;
  14.     }
  15. }
  16.  
  17. add_action('comment_post', function($comment_id) {
  18.     new WCFM_Store_review_modifier($comment_id);
  19. }, 49);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement