• digitalberry

    (@digitalberry)


    Hi,
    This site is returning a fatal error when any search is input. Can anyone help?

    Fatal error: Uncaught Error: Non-static method WC_Query::get_catalog_ordering_args() cannot be called statically
    in?/home/customer/www/gustowines.co.uk/public_html/wp-content/themes/gustowines/inc/woocommerce.php?on line?370

    Call stack:

    1. rlv_price_sort()
      wp-includes/class-wp-hook.php:326
    2. WP_Hook::apply_filters()
      wp-includes/plugin.php:205
    3. apply_filters()
      wp-content/plugins/relevanssi/lib/search.php:626
    4. relevanssi_do_query()
      wp-content/plugins/relevanssi/lib/search.php:88
    5. relevanssi_query()
      wp-includes/class-wp-hook.php:324
    6. WP_Hook::apply_filters()
      wp-includes/plugin.php:256
    7. apply_filters_ref_array()
      wp-includes/class-wp-query.php:3161
    8. WP_Query::get_posts()
      wp-includes/class-wp-query.php:3852
    9. WP_Query::query()
      wp-includes/class-wp.php:696
    10. WP::query_posts()
      wp-includes/class-wp.php:816
    11. WP::main()
      wp-includes/functions.php:1336
    12. wp()
      wp-blog-header.php:16
    13. require()
      index.php:17

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    What does the rlv_price_sort() function in your theme look like? The one on Relevanssi.com does not use get_catalog_ordering_args(), so you have something custom there.

    Thread Starter digitalberry

    (@digitalberry)

    Not, sure I didn’t built the site, I’ve inherited it to try and fix!

    Plugin Author Mikko Saari

    (@msaari)

    I can tell you if you just show me the function. It’s in /themes/gustowines/inc/woocommerce.php.

    Thread Starter digitalberry

    (@digitalberry)

    Thank you!

    /**

    • Add price sorting to relevanssi search results
      */

    function rlv_price_sort( $hits ) {
    if ( is_search() ) {
    $ordering = WC_Query::get_catalog_ordering_args();
    if ( ( $ordering[‘orderby’] != ‘date ID’) && ($ordering[‘meta_key’] == ”) ) {
    $prices = array();
    foreach ( $hits[0] as $hit ) {
    $price = get_post_meta( $hit->ID, ‘_price’, true);
    if ( !isset( $prices[$price] ) ) {
    $prices[$price] = array();
    }
    array_push($prices[$price], $hit);
    }
    $priceorder = strtolower( $ordering[‘order’] );
    if ( $priceorder == ‘desc’ ) {
    ksort($prices);
    } else {
    krsort($prices);
    }
    $sorted_hits = array();
    foreach ( $prices as $price => $year_hits ) {
    $sorted_hits = array_merge( $sorted_hits, $year_hits );
    }
    $hits[0] = $sorted_hits;
    }
    return $hits;
    }
    }

    add_filter( ‘relevanssi_hits_filter’, ‘rlv_price_sort’ );

    Plugin Author Mikko Saari

    (@msaari)

    The problem is this: $ordering = WC_Query::get_catalog_ordering_args();. You can’t do this. This function cannot be used statically like this; you need to get the actual WC_Query instance, and then do $wc_query->get_catalog_ordering_args(). I don’t know how to fix this, but I’m sure if you ask on WooCommerce support forums, someone can help you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.