Created
August 4, 2024 13:22
-
-
Save m4munib/8a2a0bd51d9b5f8a05c192d9556f6c27 to your computer and use it in GitHub Desktop.
Adding custom event - shopmagic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class ShopMagicMyCustomEvent extends \WPDesk\ShopMagic\Workflow\Event\Builtin\OrderCommonEvent { | |
| public function get_name() : string { | |
| return __( 'My Custom Event', 'my-text-domain' ); | |
| } | |
| public function get_description(): string { | |
| return __( 'My custom event description', 'my-text-domain' ); | |
| } | |
| public function initialize() : void { | |
| add_action( 'your_wp_hook', function() { | |
| // Get all Woo Order - Your logic | |
| $this->order = $order; | |
| $this->run_actions(); | |
| }); | |
| } | |
| } | |
| function integrate_my_custom_shopmagic_event( array $hashmap ) { | |
| $hashmap['shopmagik_custom_event'] = new ShopMagicMyCustomEvent(); | |
| return $hashmap; | |
| } | |
| add_filter('shopmagic/core/events', 'integrate_my_custom_shopmagic_event'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment