Advertisement
geminilabs

Untitled

Oct 9th, 2024 (edited)
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. function konte_woo_display_product_reviews () {
  2.     global $product;
  3.     if (true !== $product->get_reviews_allowed()) {
  4.         return;
  5.     }
  6.     $lang = apply_filters('wpml_current_language', '');
  7.     $forms = [
  8.         'el' => 1820,
  9.         'en' => 2393,
  10.     ];
  11.     $formId = $forms[$lang] ?? '';
  12.     $productId = $product->get_id();
  13.     $isVerificationDisabled = 'no' === get_option('woocommerce_review_rating_verification_required');
  14.     $isVerifiedOwner = wc_customer_bought_product('', get_current_user_id(), $productId);
  15.     echo '<span class="reviews-title">'.esc_html__('Reviews', 'konte-child').'</span>';
  16.     echo do_shortcode("[site_reviews_summary assigned_posts='{$productId}' hide='rating']");
  17.     echo do_shortcode("[site_reviews pagination='ajax' display='5' filters='true' assigned_posts='{$productId}' form='{$formId}']");
  18.     if ($isVerificationDisabled || $isVerifiedOwner) {
  19.         echo do_shortcode("[site_reviews_form assigned_posts='{$productId}' form='{$formId}']");
  20.     } else {
  21.         esc_html_e('Only logged in customers who have purchased this product may leave a review.', 'konte-child');
  22.     }
  23. }
  24. add_action('woocommerce_after_single_product', 'konte_woo_display_product_reviews', 21);
  25.  
  26. function konte_woo_remove_product_reviews_tab ($tabs) {
  27.     unset($tabs['reviews']);
  28.     return $tabs;
  29. }
  30. add_filter('woocommerce_product_tabs', 'konte_woo_remove_product_reviews_tab', 98);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement