Plugin Directory

Changeset 2569074


Ignore:
Timestamp:
07/21/2021 10:12:12 AM (5 years ago)
Author:
fastflow
Message:

Update for WC Subscription statuses

Location:
fast-woo-tags/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fast-woo-tags/trunk/fast-woo-tags.php

    r2359873 r2569074  
    44 * Plugin URI: https://www.fastflow.io/products/fast-woo-tag
    55 * Description: Woocommerce addon for Fast Flow Tags
    6  * Version: 1.1.2
     6 * Version: 1.2
    77 * Author: FastFlow
    88 * Author URI: https://www.fastflow.io
     
    2525              add_action( 'admin_footer', array($this, 'fast_woo_tag_product_script'));
    2626              add_action( 'woocommerce_new_order', array($this, 'fast_woo_tag_new_order'), 99, 1);
     27              add_action( 'woocommerce_subscription_payment_failed', array($this, 'fast_woo_tag_sub_payment_failed'), 99, 2);
     28              add_action( 'woocommerce_subscription_status_cancelled', array($this, 'fast_woo_tag_sub_payment_status_actions'), 99, 1);
     29              add_action( 'woocommerce_subscription_status_expired', array($this, 'fast_woo_tag_sub_payment_status_actions'), 99, 1);
     30              add_action( 'woocommerce_subscription_status_on-hold', array($this, 'fast_woo_tag_sub_payment_status_actions'), 99, 1);
    2731          }
    2832
     
    161165            if (!in_array( $new_tag->term_id, array_column($fast_tags, 'term_id') ) ){
    162166              wp_set_object_terms($user_id, (int)$new_tag->term_id, 'fast_tag', true);
     167              do_action('after_tag_applied_hook',(int)$new_tag->term_id, $user_id);
    163168            }
     169          }
     170
     171          public function fast_woo_tag_sub_payment_failed($subscription, $new_status){
     172            $order_id = $subscription->get_parent_id();
     173            $order = wc_get_order( $order_id );
     174            $user_id = $order->get_user_id();
     175            $new_tag = get_term_by('slug', 'wc-'.$new_status, 'fast_tag' );
     176            $fast_tags = wp_get_object_terms($user_id, 'fast_tag');
     177            if (!in_array( $new_tag->term_id, array_column($fast_tags, 'term_id') ) ){
     178              wp_set_object_terms($user_id, (int)$new_tag->term_id, 'fast_tag', true);
     179              do_action('after_tag_applied_hook',(int)$new_tag->term_id, $user_id);
     180            }
     181            update_user_meta($order->get_user_id(), 'fwc_total_credit_amount', 0);
     182          }
     183
     184          public function fast_woo_tag_sub_payment_status_actions($subscription){
     185            $order_id = $subscription->get_parent_id();
     186            $order = wc_get_order( $order_id );
     187            $user_id = $order->get_user_id();
     188            $new_tag = get_term_by('slug', 'wc-'.$order->get_status(), 'fast_tag' );
     189            $fast_tags = wp_get_object_terms($user_id, 'fast_tag');
     190            if (!in_array( $new_tag->term_id, array_column($fast_tags, 'term_id') ) ){
     191              wp_set_object_terms($user_id, (int)$new_tag->term_id, 'fast_tag', true);
     192              do_action('after_tag_applied_hook',(int)$new_tag->term_id, $user_id);
     193            }
     194            update_user_meta($order->get_user_id(), 'fwc_total_credit_amount', 0);
    164195          }
    165196
  • fast-woo-tags/trunk/readme.txt

    r2537632 r2569074  
    6060== Changelog ==
    6161
     62= 1.2 =
     63
     64Added hooks for WC Subscription plugin failed subscriptions status
     65
     66woocommerce_subscription_status_cancelled
     67woocommerce_subscription_status_expired
     68woocommerce_subscription_status_on-hold
     69
    6270= 1.1.2 =
    6371
Note: See TracChangeset for help on using the changeset viewer.