• nullkohol

    (@nullkohol)


    Hi there,
    thanks to your fantastic documentation, I easily found the filter I need. It’s “woocommerce_gzd_unit_price_html” and works fine until I publish a grouped product. Then it crashes. Here are the – I think – relevant parts of the error message.

    PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 2 passed in /***/wp-includes/class-wp-hook.php on line 324 and exactly 3 expected in***/wp-content/themes/nk-fse-child/functions.php:196,
    ***/wp-includes/class-wp-hook.php(324): {closure}('Preis pro apply_filters('Preis pro <spa…', Array),
    ***/wp-content/plugins/woocommerce-germanized/includes/class-wc-gzd-product-grouped.php(305): apply_filters('woocommerce_gzd…', 'Preis pro <spa…', Object(WC_GZD_Product_Grouped))


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author vendidero

    (@vendidero)

    Hi there,

    yes, this is inconsistent behaviour. Currently not all those filter usages have 3 arguments. You should adjust your filter usage to 2 arguments instead. I’ll fix that issue within our next update. Thanks for reporting!

    Best,
    Dennis

    Thread Starter nullkohol

    (@nullkohol)

    Hi Dennis,

    good to hear that you’ll fix that ?? When is that update planned?

    How would I go about changing that? If I leave out the third parameter in my filter (I don’t use it anyway), won’t I get something like an “too many arguments” error when the filter is actually called with three arguments? Or is there something like overloading in php (I am not very familiar with php, but that’s something you could do in Java).

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    planned for today ??

    How would I go about changing that?

    You pass the number of arguments expected to the add_filter hook, e.g.:

    add_filter( 'woocommerce_gzd_unit_price_html', function( $first_arg, $second_arg ) {
    return $first_arg;
    }, 10, 2 );

    See: https://developer.www.ads-software.com/reference/functions/add_filter/

    Best,
    Dennis

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