Automattic\WooCommerce\Internal\DataStores\Fulfillments

FulfillmentsDataStore::readpublicWC 1.0

Method to read a fulfillment from the database.

Method of the class: FulfillmentsDataStore{}

No Hooks.

Returns

null. Nothing (null).

Usage

$FulfillmentsDataStore = new FulfillmentsDataStore();
$FulfillmentsDataStore->read( $data ): void;
$data(Fulfillment) (required) (passed by reference — &)
The fulfillment object to read.

FulfillmentsDataStore::read() code WC 10.3.6

public function read( &$data ): void {
	// Read the fulfillment from the database.
	global $wpdb;

	$data_id          = $data->get_id();
	$fulfillment_data = $wpdb->get_row(
		$wpdb->prepare(
			"SELECT * FROM {$wpdb->prefix}wc_order_fulfillments WHERE fulfillment_id = %d",
			$data_id
		),
		ARRAY_A
	);

	if ( empty( $fulfillment_data ) ) {
		throw new \Exception( esc_html__( 'Fulfillment not found.', 'woocommerce' ) );
	}

	$data->set_props( array_diff_key( $fulfillment_data, array( 'fulfillment_id' => true ) ) );
	$data->set_id( (int) $fulfillment_data['fulfillment_id'] );
	$data->read_meta_data( true );
	$data->set_object_read( true );
}