7uc1f3r
7uc1f3r

Reputation: 29650

How to have more options while using the woocommerce_available_variation hook

I using the following WooCommerce hook

function dvpi_available_variation( $variations ) {
    echo '<pre class="debug">', print_r($variations), '</pre>'; 
    return $variations;
}
add_filter( 'woocommerce_available_variation', 'dvpi_available_variation' );

This gives me all sorts of details about the variations, but suppose I want to know the (parent) id of the product itself, how do I do this best?

Upvotes: 1

Views: 583

Answers (1)

Kaperto
Kaperto

Reputation: 320

there is 3 parameters on this filter, the 2nd is the product :

add_filter("woocommerce_available_variation", function (array $details, \WC_Product $product, \WC_Product_Variation $variation) {

    return $details;

}, 10, 3);

Upvotes: 2

Related Questions