Variation product
-
Hello. I have using two things:
apply_filters( 'tinvwl_allow_add_parent_variable_product', true )
And i have added code prevent add variables, only parent.
/**
* Force adding parent variable product to wishlist
*
* @param array $data wishlist product array.
*
* @return array
*/
function tinvwl_force_parent_variable_product( $data ) {
if ( 'variable' === $data['product_type'] ) {
$data['product_variation'] = 0;
}
return $data;
}
add_filter( 'tinvwl_addtowishlist_prepare', 'tinvwl_force_parent_variable_product' );
/**
* Remove extra meta when force adding parent variable product to wishlist
*
* @param array $data wishlist product array.
*
* @return array
*/
function tinvwl_force_parent_variable_product_meta( $data ) {
if ( isset( $data['product_id'] ) ) {
$product = wc_get_product( absint( $data['product_id'] ) );
if ( $product && 'variable' === $product->get_type() ) {
return array();
}
}
return $data;
}
add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_force_parent_variable_product_meta' );If you add product to wishlist its okey, heart is red, but if you select variation, heart is white again, you can select again. How to make if product added to wishlist when you select variations hearth have to be still red (selected).
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.