Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function init() {
- $this->slug = 'upsell';
- // Custom Fields
- add_filter( 'wpf_meta_field_groups', array( $this, 'add_meta_field_group' ), 15 );
- add_filter( 'wpf_meta_fields', array( $this, 'add_meta_fields' ) );
- // Add settings
- add_filter( 'upsell_product_field_group', array( $this, 'add_settings' ), 100, 2 );
- add_filter( 'upsell_coupon_field_group', array( $this, 'add_coupon_settings' ), 100, 2 );
- add_filter( 'wpf_configure_settings', array( $this, 'register_settings' ), 15, 2 );
- // Apply tags when order/subscription is created
- add_action( 'upsell_process_checkout_completed', array( $this, 'order_created' ) );
- // Apply tags when refunded
- add_action( 'upsell_order_status_refunded', array( $this, 'order_refunded' ) );
- // Apply tags when a subscription is cancelled
- add_action( 'upsell_subscription_soft_cancelled', array( $this, 'subscription_status_changed' ) );
- add_action( 'upsell_subscription_cancelled', array( $this, 'subscription_status_changed' ) );
- // Apply tags when a subscription payment has failed
- add_action( 'upsell_subscription_status_failed', array( $this, 'subscription_status_changed' ) );
- // Apply tags when a subscription has expired
- add_action( 'upsell_subscription_status_expired', array( $this, 'subscription_status_changed' ) );
- // Batch operations
- add_filter( 'wpf_export_options', array( $this, 'export_options' ) );
- add_filter( 'wpf_batch_upsell_init', array( $this, 'batch_init' ) );
- add_action( 'wpf_batch_upsell', array( $this, 'batch_step' ) );
- }
- /**
- * Handle subscription status changes
- *
- * @param object $sub
- */
- public function subscription_status_changed( $sub ) {
- $this->apply_tags_for_subscription_status( $sub );
- $this->sync_subscription_fields( $sub );
- }
- /**
- * Apply tags for sub status change
- *
- * @param object $sub
- */
- public function apply_tags_for_subscription_status( $sub ) {
- $status = $order->getAttribute( 'status' );
- /// do the stuff
- }
- /**
- * Sync fields for sub status change
- *
- * @param object $sub
- */
- public function sync_subscription_fields( $sub ) {
- $status = $order->getAttribute( 'status' );
- /// do the stuff
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement