Skip to content

Instantly share code, notes, and snippets.

@m4munib
Created August 4, 2024 13:22
Show Gist options
  • Select an option

  • Save m4munib/8a2a0bd51d9b5f8a05c192d9556f6c27 to your computer and use it in GitHub Desktop.

Select an option

Save m4munib/8a2a0bd51d9b5f8a05c192d9556f6c27 to your computer and use it in GitHub Desktop.
Adding custom event - shopmagic
<?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