Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpf_subscription_status_hold( $subscription, $status, $old_status ) {
- $user_id = $subscription->get_user_id();
- foreach ( $subscription->get_items() as $line_item ) {
- $product_id = $line_item->get_product_id();
- $settings = get_post_meta( $product_id, 'wpf-settings-woo', true );
- if ( ! empty( $settings ) ) {
- if( $status == 'on-hold' && ! empty( $settings['apply_tags_hold'] ) ) {
- wp_clear_scheduled_hook( 'wpf_subscription_status_hold', array( $subscription, $settings ) );
- wp_fusion()->logger->handle( 'info', $user_id, 'WooCommerce subscription <a href="' . admin_url( "post.php?post=" . $subscription->get_id() . "&action=edit") . '" target="_blank">#' . $subscription->get_id() . '</a> status changed to <strong>on-hold</strong>', array( 'source' => 'wc-subscriptions' ) );
- $user_id = $subscription->get_user_id();
- if( ! empty( $settings['apply_tags_hold'] ) ) {
- wp_fusion()->user->apply_tags( $settings['apply_tags_hold'], $user_id );
- }
- if( ! empty( $settings['remove_tags'] ) ) {;
- wp_fusion()->user->remove_tags( $settings['apply_tags'], $user_id );
- }
- }
- }
- }
- }
- add_action( 'woocommerce_subscription_status_updated', 'wpf_subscription_status_hold', 20, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement