registry = new Registry(); $this->rules = new RuleRepository(); $this->wallet = new Ledger(); } /** * Register hooks and built-in rule types, then let other plugins extend the core. */ public function boot(): void { if ( $this->booted ) { return; } $this->booted = true; Installer::maybe_upgrade(); $this->register_builtins(); ( new CartHooks( $this->registry, $this->rules ) )->register(); ( new EventRunner( $this->registry, $this->rules ) )->register(); ( new RulesController( $this->registry, $this->rules ) )->register(); $preview = new Preview( $this->registry, $this->rules ); ( new PricePreviewController( $preview ) )->register(); ( new ProductExtension( $preview ) )->register(); ( new Privacy( $this->wallet ) )->register(); ( new AdminPage() )->register(); /** * Fires once the core is ready. Paid plugins register conditions and actions here. * * @param Plugin $plugin The core instance. */ do_action( 'joinery_core_init', $this ); } /** * The free conditions and actions that ship with the core. */ private function register_builtins(): void { $this->registry->register_condition( new CustomerRole() ); $this->registry->register_condition( new CartQuantity() ); $this->registry->register_condition( new CartSubtotal() ); $this->registry->register_condition( new ProductCategory() ); $this->registry->register_condition( new DateRange() ); $this->registry->register_action( new PercentageOff() ); $this->registry->register_action( new CartPercentageOff() ); } /** * Condition and action registry. */ public function registry(): Registry { return $this->registry; } /** * Rule storage. */ public function rules(): RuleRepository { return $this->rules; } /** * Customer wallet. */ public function wallet(): Ledger { return $this->wallet; } }