• Resolved broder

    (@broder)


    I would like to sort products based on gslr average or glsr ranking meta field with my filter plugin. This works but it only sorts (and filters) products where this field exists. But when sorting you would want all products to show up. To solve this problem I have made this work around where if I save a post and both fields do not exist, I add the post meta manually and set it to 0:

    if (!$product->meta_exists( '_glsr_average' ) && !$product->meta_exists( '_glsr_ranking' ) ) {
    add_post_meta($post_id, '_glsr_average', '0', $unique = true);
    add_post_meta($post_id, '_glsr_ranking', '0', $unique = true);
    }

    When a review is submitted everything updates fine, but I was wondering if there is any harm in doing this? Thanks in advance.

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

    (@geminilabs)

    See the meta_query part of the code in the FAQ which shows how to do this correctly:

    • This reply was modified 1 year, 8 months ago by Gemini Labs.
    Thread Starter broder

    (@broder)

    Thanks for the reply, out of the box I can’t alter any query. So that’s why I asked. I will ask the plugin author about this.

    • This reply was modified 1 year, 8 months ago by broder.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set posts without reviews rating to 0’ is closed to new replies.