WC_Product_Variation::get_customs_prop │ private │ WC 1.0

Gets a customs value, falling back to the parent value in view context when the variation has none.

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

Хуки из метода

Возвращает

string|null.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_customs_prop( $prop, $context );
$prop(строка) (обязательный)
Customs prop name.
$context(строка) (обязательный)
View or edit context.

Код WC_Product_Variation::get_customs_prop() WC 11.3.0

private function get_customs_prop( string $prop, $context ) {
	$value = $this->get_prop( $prop, $context );
	if ( 'view' === $context && null === $value ) {
		/**
		 * Filters a resolved customs value: woocommerce_product_variation_get_customs_commodity_code,
		 * woocommerce_product_variation_get_customs_country_of_origin, or woocommerce_product_variation_get_customs_description.
		 *
		 * The dynamic portion of the hook name, `$prop`, refers to the customs prop name. Runs for the variation's
		 * own value via get_prop() (may be null), and again with the parent value when the variation inherits it.
		 *
		 * @since 11.3.0
		 *
		 * @param string|null          $value     Customs value.
		 * @param WC_Product_Variation $variation Product variation.
		 */
		$value = apply_filters( $this->get_hook_prefix() . $prop, $this->parent_data[ $prop ], $this );
	}
	return $value;
}