Skip to content

Instantly share code, notes, and snippets.

@pramodjodhani
Last active October 10, 2025 07:15
Show Gist options
  • Save pramodjodhani/a8170664c662377abc065e391cdc2b5c to your computer and use it in GitHub Desktop.
Save pramodjodhani/a8170664c662377abc065e391cdc2b5c to your computer and use it in GitHub Desktop.
Iconic LV (linked variation) show out of stock products
<?php
// Iconic Linked variation: Custom snippet to mark products as in stock if they're not currently in stock
add_action( 'woocommerce_single_product_summary', 'iconic_lv_add_force_instock_filter', 24 );
function iconic_lv_add_force_instock_filter() {
add_filter( 'woocommerce_product_get_stock_status', 'iconic_lv_force_product_instock_filter', 10, 2 );
}
function iconic_lv_force_product_instock_filter( $stock_status, $product ) {
// Force the product to be in stock regardless of current status
return 'instock';
}
function iconic_lv_force_product_purchasable( $purchasable, $product ) {
return true;
}
// Remove the filter at priority 11
add_action( 'woocommerce_single_product_summary', 'iconic_lv_remove_force_instock_filter', 26 );
function iconic_lv_remove_force_instock_filter() {
remove_filter( 'woocommerce_product_get_stock_status', 'iconic_lv_force_product_instock_filter', 10 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment