Like I mentioned in my reply to your other topic, you are probably best of reading the Plugin API documentation to get you started. If you get errors or anything like that, please post them here so we can look. You also should post the code how you are hooking into this specific filter.
Hi, i know how add filter.
$available_variations[] = apply_filters( 'woocommerce_available_variation', array(
'variation_id' => $child_id,
'attributes' => $variation_attributes,
'image_src' => $image,
'image_link' => $image_link,
'image_title' => $image_title,
'price_html' => $this->min_variation_price != $this->max_variation_price ? '<span class="price">' . $variation->get_price_html() . '</span>' : '',
'availability_html' => $availability_html,
'sku' => $variation->get_sku(),
'weight' => $variation->get_weight() . ' ' . esc_attr( get_option('woocommerce_weight_unit' ) ),
'dimensions' => $variation->get_dimensions(),
'min_qty' => 1,
'max_qty' => $this->backorders_allowed() ? '' : $variation->stock,
'backorders_allowed' => $this->backorders_allowed(),
'is_in_stock' => $variation->is_in_stock(),
'is_downloadable' => $variation->is_downloadable() ,
'is_virtual' => $variation->is_virtual(),
'is_sold_individually' => $variation->is_sold_individually() ? 'yes' : 'no',
), $this, $variation );
But I don’t know how I can return array in my function with these vars.
Please take my advice and read the documentation I linked to. This is not how you should use a filter. Quick example of how it should be done:
add_filter( 'woocommerce_available_variation', 'cj_ woocommerce_available_variation' );
function cj_ woocommerce_available_variation( $variations ) {
array_push( $variations, array( 'test_key' => 'test value' );
return $variations;
}
This adds the array( 'test_key' => 'test value' )
to the array (via the filter woocommerce_available_variation
) and then returns it.