Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Last active November 29, 2018 17:18
Show Gist options
  • Save jrick1229/3e3916a510e63df08b45e0b5e056b631 to your computer and use it in GitHub Desktop.
Save jrick1229/3e3916a510e63df08b45e0b5e056b631 to your computer and use it in GitHub Desktop.
Don't reduce stock on renewal - Subscriptions
<?php
function wcs_do_not_reduce_renewal_stock( $reduce_stock, $order ) {
if ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order ) ) { // Subscriptions v2.0+
$reduce_stock = false;
} elseif ( class_exists( 'WC_Subscriptions_Renewal_Order' ) && WC_Subscriptions_Renewal_Order::is_renewal( $order ) ) {
$reduce_stock = false;
}
return $reduce_stock;
}
add_filter( 'woocommerce_can_reduce_order_stock', 'wcs_do_not_reduce_renewal_stock', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment