Site logo

[Support request] WC related products hook

Home Forums Support [Support request] WC related products hook

Home Forums Support WC related products hook

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #717075
    Moritz

    Hi there,

    I have a question / problems regarding GP with WC regarding related products.

    I know that GP offers several settings regarding WooCommerce display options in the customizer.
    There is also a setting to change the “Related/Upsell Columns”.

    I need to change the query of the related products output.
    In short: Every product has a specific meta-field, if the field-value equals “something”, than the product should not show up in the related products. So I need to add a meta-query to the related post query.

    The thing is, all the code I already tried to change the query of the related products isnt working.

    Even just changing just the “post_per_page” or “columns” isnt working, something like this. (this code is sitting in a small custom plugin)

    add_filter( 'woocommerce_output_related_products_args', 'prfx_change_related_products_count' );
    function prfx_change_related_products_count( $args ) {
         $args['posts_per_page'] = 4;
         $args['columns'] = 1;
    
         return $args;
    }

    I also tried different WC hooks but the related posts output just doesnt change at all.
    It seems that only the customizer settings get applied but not my code.

    Is it possible that the customizer setting is overwriting my code or that GP uses it own hooks?!

    Thanks,
    have a nice day!

    #717429
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    woocommerce_output_related_products_args should work – GP doesn’t use that filter.

    Are you trying to exclude specific products from the related products area if they have a custom meta field?

    If so, maybe this will help?: https://stackoverflow.com/a/50345889/2391422

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