• Resolved crool

    (@crool)


    Hi,
    After update from 2.11.0 to 2.12.2 (3) the front end ordering is not working anymore.
    Using woocommerce and ordering product category.
    Error message:

    [03-Feb-2022 11:45:50 UTC] DEBUG_MSG: 
       [252]./public/class-reorder-post-within-categories-public.php
              + RPWC2 SORT VALIDATION, found post_type 'product' / taxonomy 'product_cat'(689)
    [03-Feb-2022 11:45:50 UTC] DEBUG_MSG: 
              + RPWC2 SORT VALIDATION ABORTED, for orderby: menu_order title

    Can you please help me out here?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    I have a small change. Can you manually upgrade to v2.12.4 RC1 and let me know if it works for you.

    Thread Starter crool

    (@crool)

    Thank you very much. As far i can see it is working oke now. Also on php 8.
    Also thanks for your fast response.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    wc. will release the new version

    Hello @aurovrata

    I’ve looked into the provided RC and I’m not sure this issue is fully resolved.

    I think the issue is with the following line:

    $ob = explode(' ', trim($wp_query->query_vars['orderby']));

    WP_Query orderby can be a String or an Array and the above line will error out when an Array is provided since trim() expects a String. One option may be to force an array then compare against array_keys() and array_values(). I’m not sure if trim() is necessary but this could be mapped to the array before the comparison.

    Here’s the stack trace I get with my Fatal Error:

    Array
    (
        [type] => 1
        [message] => Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /wp-content/plugins/reorder-post-within-categories/public/class-reorder-post-within-categories-public.php:421
    Stack trace:
    #0 /wp-content/plugins/reorder-post-within-categories/public/class-reorder-post-within-categories-public.php(421): trim()
    #1 /wp-includes/class-wp-hook.php(307): Reorder_Post_Within_Categories_Public->override_woocommerce_products()
    #2 /wp-includes/plugin.php(189): WP_Hook->apply_filters()
    #3 /wp-content/plugins/reorder-post-within-categories/public/class-reorder-post-within-categories-public.php(260): apply_filters()
    #4 /wp-content/plugins/reorder-post-within-categories/public/class-reorder-post-within-categories-public.php(147): Reorder_Post_Within_Categories_Public::is_ranked()
    #5 /wp-content/plugins/reorder-post-within-categories/public/class-reorder-post-within-categories-public.php(85): Reorder_Post_Within_Categories_Public->is_manual_sort_query()
    #6 /wp-includes/class-wp-hook.php(307): Reorder_Post_Within_Categories_Public->filter_posts_where()
    #7 /wp-includes/plugin.php(233): WP_Hook->apply_filters()
    #8 /wp-includes/class-wp-query.php(2625): apply_filters_ref_array()
    #9 /wp-includes/class-wp-query.php(3542): WP_Query->get_posts()
    #10 /wp-includes/class-wp-query.php(3653): WP_Query->query()
    #11 /wp-content/themes/custom-theme/template-parts/programs/term-posts.php(36): WP_Query->__construct()
    #12 /wp-includes/template.php(772): require('...')
    #13 /wp-includes/template.php(716): load_template()
    #14 /wp-includes/general-template.php(204): locate_template()
    #15 /wp-content/themes/custom-theme/taxonomy-tax_program_type.php(26): get_template_part()
    #16 /wp-includes/template-loader.php(106): include('...')
    #17 /wp-blog-header.php(19): require_once('...')
    #18 /index.php(17): require('...')
    #19 {main}
      thrown
        [file] => /wp-content/plugins/reorder-post-within-categories/public/class-reorder-post-within-categories-public.php
        [line] => 421
    )
    Plugin Author Aurovrata Venet

    (@aurovrata)

    @howdy_mcgee good point, silly me!

    will fix asap.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    @howdy_mcgee @crool v2.12.4 RC2 should fix it this, would you kindly confirm

    Thread Starter crool

    (@crool)

    I did not see former error. But i add the new fix and everthing is working fine. Testing it.
    this is my log: (php 8)

    [04-Feb-2022 07:43:15 UTC] DEBUG_MSG: 
       [88]./public/class-reorder-post-within-categories-public.php
              + RPWC2 SORT VALIDATION, sorting posts in term: 692
    [04-Feb-2022 07:43:15 UTC] DEBUG_MSG: 
              + RPWC2 SORT VALIDATION, found post_type 'product' / taxonomy 'product_cat'(692)
    [04-Feb-2022 07:43:15 UTC] DEBUG_MSG: 
              + RPWC2 SORT VALIDATION, overriding orderby: menu_order title

    Thanks again!

    @aurovrata Thank you for your quick reply & updates!

    This fixed my reported issue. I’m not sure how important this function is but array_intersect() is going to check against values and IF orderby is an array, 'menu_order','meta_value' would be keys of the array: array( 'menu_order' => 'ASC', 'meta_value' => 'DESC' ).

    Thank you again, and keep being awesome!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    array_intersect() is going to check against values and IF orderby is an array, ‘menu_order’,’meta_value’ would be keys of the array: array( ‘menu_order’ => ‘ASC’, ‘meta_value’ => ‘DESC’ )

    oh that is precious information @howdy_mcgee

    added an extra line to extract the keys in case the derby directive is an array.

    thank you for your help.

    just released v2.12.5 (realised 2.12.4 was already previous v).

    Thank you again, and keep being awesome!

    thank you for the kind words.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘After update sort is not working on front-end’ is closed to new replies.