WC_Webhook::__construct()publicWC 1.0

Load webhook data based on how WC_Webhook is called.

Метод класса: WC_Webhook{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Webhook = new WC_Webhook();
$WC_Webhook->__construct( $data );
$data(WC_Webhook|int)
Webhook ID or data.

Код WC_Webhook::__construct() WC 8.7.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 );
	}
}