• Resolved vethe2

    (@vethe2)


    Hello, I am using your plugin for my site, and without a doubt, this is the best plugin on the market, even with just the free version. I appreciate your work and hope you continue to develop this plugin to the next level.

    I have set up everything, and it works well on my site. Just one more thing to make it perfect: I don’t know how to make my shop product page order in the newest reviews order.

    When a product receives a review, it should go to the top of other products on the shop page. I have tried using hooks of your plugin and WooCommerce, but I cannot make it work.

    This inquiry is my last hope. Please help me!!!! Thank you so much!!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Have you pinned any of your reviews? Pinned reviews are always displayed first, regardless of date.

    Thread Starter vethe2

    (@vethe2)

    Thank you for your prompt response. I apologize for the unclear expression that led to your misunderstanding.

    I wasn’t referring to the sorting of reviews, but rather to the products that have been reviewed.

    For example: I have 3 products A, B, C.

    The 3 products will be displayed on the shop page in the order A, B, C according to the latest modified order.

    If product C receives a review, then on the shop page it will be displayed in the order C, A, B.

    Then, if product B receives a review, the shop page will display: B, C, A.

    I want the shop page to be sorted by the most recently reviewed products by default.

    Although Site Reviews has replaced WooCommerce’s default reviews, it does not directly affect the product posts. Therefore, I cannot sort the products list page (not product single page) by newest review order.

    I tried using this hook to add metadata to the post being reviewed after submission based on the post ID, but it was unsuccessful.

    /**
     * Runs after a review has been created.
     */
    add_action('site-reviews/review/created', function ($review, $command) {
        // do something here.
    }, 10, 2);

    I want that when a review is submitted, metadata will be added to the post based on the post ID in the hidden field of the review form. And based on the last modified metadata, the products list will be sorted by last modified, but I can’t add metadata to the post after each form submission.

    
    add_action('site-reviews/review/created', function ($review, $command) {
        $product_id = $review->post_id;
        update_post_meta($product_id, 'last_modified', current_time('mysql'));
    }, 10, 2);

    I don’t know what else to do. Please help me.

    Thread Starter vethe2

    (@vethe2)

    Hello, I am still waiting.
    Now I can use the Bayesian sorting feature in the Site Reviews Plugin settings. But if I use this sorting method, products with existing reviews will always be at the top, while products without reviews will remain at the bottom. It would be great if when someone reviews a product, that product jumps to the top of the product list. I really hope for your assistance.

    Plugin Author Gemini Labs

    (@geminilabs)

    Although Site Reviews has replaced WooCommerce’s default reviews, it does not directly affect the product posts. Therefore, I cannot sort the products list page (not product single page) by newest review order.

    Actually, if you have enabled the WooCommerce integration, then the “Sort by average rating” in the sorting dropdown on the shop page should work as expected.

    I’m not sure what updating the “last_modified” meta_key on the product will do, but you could do it like this:

    add_action('site-reviews/review/created', function ($review) {
        $productId = $review->assigned_posts[0] ?? 0;
        if ('product' === get_post_type($productId)) {
            update_post_meta($productId, 'last_modified', current_time('mysql'));
        }
    }, 20);
    Thread Starter vethe2

    (@vethe2)

    Thank you for your response. I tried your code, but it still does not work. After I submit a review, the last modified timestamp of the product is not changed. It doesn’t affect it at all. I will try to figure out myself why the hook doesn’t work at all. Thank you for your time.

    Plugin Author Gemini Labs

    (@geminilabs)

    Probably because WordPress stores the modify date directly on the posts table, not meta data.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Make shop page sort in newest review order’ is closed to new replies.