file = $file; } /** * Register functionality after other plugins have loaded. * * @return void */ public function register(): void { Migration::run(); \Teropress\UltimateDiscountEngine\Campaign\Reporting::register(); if ( is_admin() ) { \Teropress\UltimateDiscountEngine\Extension\Compatibility::register(); } $woocommerce = new WooCommerce(); if ( ! $woocommerce->is_available() ) { add_action( 'admin_notices', array( $woocommerce, 'render_notice' ) ); return; } // Provider labels use translations, which must load on init or later. add_action( 'init', array( \Teropress\UltimateDiscountEngine\Extension\Api::class, 'boot' ), 5 ); \Teropress\UltimateDiscountEngine\Mcp\Integration::register(); \Teropress\UltimateDiscountEngine\Campaign\Offers\Usage::install(); add_action( 'woocommerce_checkout_order_created', array( \Teropress\UltimateDiscountEngine\Campaign\Offers\Usage::class, 'checkout' ), 30 ); add_action( 'woocommerce_store_api_checkout_order_processed', array( \Teropress\UltimateDiscountEngine\Campaign\Offers\Usage::class, 'checkout' ), 30 ); add_action( 'woocommerce_order_status_changed', array( \Teropress\UltimateDiscountEngine\Campaign\Offers\Usage::class, 'transition' ), 10, 3 ); add_action( 'woocommerce_before_delete_order', array( \Teropress\UltimateDiscountEngine\Campaign\Offers\Usage::class, 'delete_order' ) ); ( new \Teropress\UltimateDiscountEngine\Campaign\Bogo\Notices() )->register(); ( new \Teropress\UltimateDiscountEngine\Admin\OfferCatalog() )->register(); ( new \Teropress\UltimateDiscountEngine\Campaign\Evaluation\CartAdapter() )->register(); add_action( 'rest_api_init', array( new \Teropress\UltimateDiscountEngine\Rest\Controller(), 'register' ) ); ( new \Teropress\UltimateDiscountEngine\Campaign\Pricing() )->register(); ( new \Teropress\UltimateDiscountEngine\Campaign\Analytics() )->register(); ( new \Teropress\UltimateDiscountEngine\Campaign\CartDiscount() )->register(); ( new \Teropress\UltimateDiscountEngine\Campaign\CartDiscountDisplay( $this->file ) )->register(); ( new \Teropress\UltimateDiscountEngine\Campaign\FreeShipping() )->register(); ( new \Teropress\UltimateDiscountEngine\Campaign\FreeShippingDisplay( $this->file ) )->register(); $tier_table = new \Teropress\UltimateDiscountEngine\Campaign\TierTable( $this->file ); add_action( 'wp_enqueue_scripts', array( $tier_table, 'enqueue' ) ); add_action( 'wc_ajax_teropress_ude_tier_cart', array( $tier_table, 'refresh_cart' ) ); if ( is_admin() ) { ( new Admin( $this->file ) )->register(); } } /** * Validate requirements without creating persistent state. * * @return void */ public static function activate(): void { if ( ! ( new WooCommerce() )->is_available() ) { wp_die( esc_html__( 'Ultimate Discounts Engine for WooCommerce requires WooCommerce 9.8 or newer to be installed and active.', 'ultimate-discount-engine' ), esc_html__( 'Plugin dependency check failed', 'ultimate-discount-engine' ), array( 'back_link' => true ) ); } } }