Created
February 26, 2020 09:06
-
-
Save bvdr/acfde9d0aded80c0eb4b7c448cdd0475 to your computer and use it in GitHub Desktop.
Autocomplete orders in WooCommerce
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 | |
| /** | |
| * Autocomplete orders in subscription. | |
| * | |
| * @package CustomWoo | |
| */ | |
| declare( strict_types=1 ); | |
| namespace Custom\Woo\Extras; | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| return; | |
| } | |
| add_action( 'woocommerce_payment_complete', __NAMESPACE__ . '\\woocommerce_subscriptions_auto_complete_order', 999 ); | |
| /** | |
| * Autocomplete orders. | |
| * | |
| * @param int $order_id Order Id. | |
| */ | |
| function woocommerce_subscriptions_auto_complete_order( $order_id ) { | |
| if ( ! $order_id ) { | |
| return; | |
| } | |
| $order = wc_get_order( $order_id ); | |
| $order->update_status( 'completed' ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment