Skip to content

Instantly share code, notes, and snippets.

@jhimross
Created January 27, 2022 04:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhimross/a832c3936ae942bce961b4639b157b68 to your computer and use it in GitHub Desktop.
Save jhimross/a832c3936ae942bce961b4639b157b68 to your computer and use it in GitHub Desktop.
Iconic Linked Variations - Force show out of stock Linked Variations
/**
* 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