Product reviews on category pages for variable products issue
-
Hello,
There’s a small issue in the plugin that it doesn’t show reviews on variable products that are shown in the category page, because the plugin gets the variable product id in this function wc_yotpo_get_product_data using product->get_id() but all reviews are in the main product so it won’t show any reviews and here’s the solution that worked
function wc_yotpo_get_product_data($product) { $settings = get_option('yotpo_settings',wc_yotpo_get_default_settings()); $product_id = ($product->get_parent_id() ? $product->get_parent_id() : $product->get_id()); $product_data = array( 'app_key' => esc_attr($settings['app_key']), 'shop_domain' => esc_attr(wc_yotpo_get_shop_domain()), 'url' => esc_attr(get_permalink($product->get_id())), 'lang' => esc_attr($settings['language_code']), 'description' => esc_attr(wp_strip_all_tags($product->get_description())), 'id' => esc_attr($product_id), 'title' => esc_attr($product->get_title()), 'image-url' => esc_attr(wc_yotpo_get_product_image_url($product->get_id())) );
As you can see i check if there’s a parent id first and return it so it would work, please let me know if you have a better solution for the issue.
Thanks for the plugin.
- The topic ‘Product reviews on category pages for variable products issue’ is closed to new replies.