WC_REST_Product_Variations_V2_Controller::check_variation_parentprotectedWC 9.2.0

Checks that a variation belongs to the specified parent product.

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

Хуков нет.

Возвращает

true|false. TRUE if variation and parent product exist. FALSE otherwise.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->check_variation_parent( $variation_id, $parent_id ): bool;
$variation_id(int) (обязательный)
Variation ID.
$parent_id(int) (обязательный)
Parent product ID to check against.

Список изменений

С версии 9.2.0 Введена.

Код WC_REST_Product_Variations_V2_Controller::check_variation_parent() WC 10.9.4

protected function check_variation_parent( int $variation_id, int $parent_id ): bool {
	$variation = $this->get_object( $variation_id );
	if ( ! $variation || $parent_id !== $variation->get_parent_id() ) {
		return false;
	}

	$parent = wc_get_product( $variation->get_parent_id() );
	if ( ! $parent ) {
		return false;
	}

	return true;
}