Last active
November 29, 2018 17:18
-
-
Save jrick1229/3e3916a510e63df08b45e0b5e056b631 to your computer and use it in GitHub Desktop.
Don't reduce stock on renewal - Subscriptions
This file contains hidden or 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
<?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