WC_Webhook::__construct
Load webhook data based on how WC_Webhook is called.
Method of the class: WC_Webhook{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Webhook = new WC_Webhook(); $WC_Webhook->__construct( $data );
- $data(WC_Webhook|int)
- Webhook ID or data.
WC_Webhook::__construct() WC Webhook:: construct code WC 10.5.0
public function __construct( $data = 0 ) {
parent::__construct( $data );
if ( $data instanceof WC_Webhook ) {
$this->set_id( absint( $data->get_id() ) );
} elseif ( is_numeric( $data ) ) {
$this->set_id( $data );
}
$this->data_store = WC_Data_Store::load( 'webhook' );
// If we have an ID, load the webhook from the DB.
if ( $this->get_id() ) {
try {
$this->data_store->read( $this );
} catch ( Exception $e ) {
$this->set_id( 0 );
$this->set_object_read( true );
}
} else {
$this->set_object_read( true );
}
}