using WCFM and woocommerce subscriptions i have been looking to find a way that a subscription renewal doesn’t reduce stock. found loads of different code and have been using the code below
problem is if the stock is already at 0 the renewal won’t be processed (i am working on a weekly subscription cost with no end date but can have no more than 6 subscriptions per product).
I’m a coding noob and this is beyond my ability to manipulate. To get this to work the way i need instead of do not reduce stock, i’d want to have it add 1 to the stock then it can reduce it again by 1 when the renewal is processed, this will allow out of stock products to still allow the renewal but no new subscription can be purchased.
can any one help?
add_filter( ‘woocommerce_can_reduce_order_stock’,
function( $reduce_stock, $order ) {
if( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order ) ) {
return false;
}
if( class_exists( 'WC_Subscriptions_Renewal_Order' ) && WC_Subscriptions_Renewal_Order::is_renewal( $order ) ) {
return false;
}
it does what it says and doesn’t reduce stock
Claire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.