Created
January 27, 2022 04:41
-
-
Save jhimross/a832c3936ae942bce961b4639b157b68 to your computer and use it in GitHub Desktop.
Iconic Linked Variations - Force show out of stock Linked Variations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Iconic Linked Variations - Force show out of stock Linked Variations. | |
* | |
* @param array $product_data Product Data. | |
* @param int $product_id Product ID. | |
* | |
* @return array | |
*/ | |
function iconic_lv_force_show_out_of_stock_products( $product_data, $product_id ) { | |
foreach ( $product_data['attributes'] as &$attribute ) { | |
foreach ( $attribute['terms'] as &$term ) { | |
if ( 'instock' != $term['linked_variation_data']['variation']['stock_status'] ) { | |
$term['linked_variation_data']['variation']['stock_status'] = 'instock'; | |
$term['linked_variation_data']['match'] = false; | |
} | |
} | |
} | |
return $product_data; | |
} | |
add_filter( 'iconic_wlv_group_data', 'iconic_lv_force_show_out_of_stock_products', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment