Advertisement
verygoodplugins

Untitled

Jun 19th, 2021
1,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1.     public function init() {
  2.         $this->slug = 'upsell';
  3.  
  4.         // Custom Fields
  5.         add_filter( 'wpf_meta_field_groups', array( $this, 'add_meta_field_group' ), 15 );
  6.         add_filter( 'wpf_meta_fields', array( $this, 'add_meta_fields' ) );
  7.  
  8.         // Add settings
  9.         add_filter( 'upsell_product_field_group', array( $this, 'add_settings' ), 100, 2 );
  10.         add_filter( 'upsell_coupon_field_group', array( $this, 'add_coupon_settings' ), 100, 2 );
  11.         add_filter( 'wpf_configure_settings', array( $this, 'register_settings' ), 15, 2 );
  12.  
  13.         // Apply tags when order/subscription is created
  14.         add_action( 'upsell_process_checkout_completed', array( $this, 'order_created' ) );
  15.  
  16.         // Apply tags when refunded
  17.         add_action( 'upsell_order_status_refunded', array( $this, 'order_refunded' ) );
  18.  
  19.         // Apply tags when a subscription is cancelled
  20.         add_action( 'upsell_subscription_soft_cancelled', array( $this, 'subscription_status_changed' ) );
  21.         add_action( 'upsell_subscription_cancelled', array( $this, 'subscription_status_changed' ) );
  22.  
  23.         // Apply tags when a subscription payment has failed
  24.         add_action( 'upsell_subscription_status_failed', array( $this, 'subscription_status_changed' ) );
  25.  
  26.         // Apply tags when a subscription has expired
  27.         add_action( 'upsell_subscription_status_expired', array( $this, 'subscription_status_changed' ) );
  28.  
  29.         // Batch operations
  30.         add_filter( 'wpf_export_options', array( $this, 'export_options' ) );
  31.         add_filter( 'wpf_batch_upsell_init', array( $this, 'batch_init' ) );
  32.         add_action( 'wpf_batch_upsell', array( $this, 'batch_step' ) );
  33.  
  34.     }
  35.  
  36.     /**
  37.      * Handle subscription status changes
  38.      *
  39.      * @param object $sub
  40.      */
  41.     public function subscription_status_changed( $sub ) {
  42.  
  43.         $this->apply_tags_for_subscription_status( $sub );
  44.  
  45.         $this->sync_subscription_fields( $sub );
  46.        
  47.     }
  48.  
  49.     /**
  50.      * Apply tags for sub status change
  51.      *
  52.      * @param object $sub
  53.      */
  54.     public function apply_tags_for_subscription_status( $sub ) {
  55.  
  56.         $status = $order->getAttribute( 'status' );
  57.  
  58.         /// do the stuff
  59.  
  60.     }
  61.  
  62.     /**
  63.      * Sync fields for sub status change
  64.      *
  65.      * @param object $sub
  66.      */
  67.     public function sync_subscription_fields( $sub ) {
  68.  
  69.         $status = $order->getAttribute( 'status' );
  70.  
  71.         /// do the stuff
  72.  
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement