Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::delete_meta()publicWC 1.0

Deletes meta based on meta ID.

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

Хуков нет.

Возвращает

true|false.

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

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->delete_meta( $object, $meta );
$object(WC_Data) (обязательный) (передается по ссылке — &)
WC_Data object.
$meta(\stdClass) (обязательный)
(containing at least ->id).

Код OrdersTableDataStore::delete_meta() WC 8.5.2

public function delete_meta( &$object, $meta ) {
	if ( $this->should_backfill_post_record() && isset( $meta->id ) ) {
		// Let's get the actual meta key before its deleted for backfilling. We cannot delete just by ID because meta IDs are different in HPOS and posts tables.
		$db_meta = $this->data_store_meta->get_metadata_by_id( $meta->id );
		if ( $db_meta ) {
			$meta->key   = $db_meta->meta_key;
			$meta->value = $db_meta->meta_value;
		}
	}

	$delete_meta     = $this->data_store_meta->delete_meta( $object, $meta );
	$changes_applied = $this->after_meta_change( $object, $meta );

	if ( ! $changes_applied && $object instanceof WC_Abstract_Order && $this->should_backfill_post_record() && isset( $meta->key ) ) {
		self::$backfilling_order_ids[] = $object->get_id();
		delete_post_meta( $object->get_id(), $meta->key, $meta->value );
		self::$backfilling_order_ids = array_diff( self::$backfilling_order_ids, array( $object->get_id() ) );
	}

	return $delete_meta;
}