WC_Webhook::__construct( WC_Webhook|int $data )

Load webhook data based on how WC_Webhook is called.


Description Description


Parameters Parameters

$data

(Required) Webhook ID or data.


Top ↑

Source Source

File: includes/class-wc-webhook.php

	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 );
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.