woocommerce_variation_prices хук-фильтрWC 3.0.0

Filters the variation prices array for a variable product.

This filter gives plugins one last chance to modify the variation prices array which has been generated and will be stored locally to the class. This value may differ from the transient cache. It is filtered once before storing locally.

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

add_filter( 'woocommerce_variation_prices', 'wp_kama_woocommerce_variation_prices_filter', 10, 3 );

/**
 * Function for `woocommerce_variation_prices` filter-hook.
 * 
 * @param array      $prices_array Associative array of variation prices indexed by variation ID.
 * @param WC_Product $product      The variable product object.
 * @param bool       $for_display  Whether prices are being retrieved for display.
 *
 * @return array
 */
function wp_kama_woocommerce_variation_prices_filter( $prices_array, $product, $for_display ){

	// filter...
	return $prices_array;
}
$prices_array(массив)

Associative array of variation prices indexed by variation ID.

  • price(массив)
    Array of active prices (variation_id => price).

  • regular_price(массив)
    Array of regular prices (variation_id => price).

  • sale_price(массив)
    Array of sale prices (variation_id => price).
$product(WC_Product)
The variable product object.
$for_display(true|false)
Whether prices are being retrieved for display.

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

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

Где вызывается хук

WC_Product_Variable_Data_Store_CPT::read_price_data()
woocommerce_variation_prices
woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php 551
$this->prices_array[ $price_hash ] = apply_filters( 'woocommerce_variation_prices', $transient_cached_prices_array[ $price_hash ], $product, $for_display );
woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php 554
$this->prices_array[ $opposite_price_hash ] = apply_filters( 'woocommerce_variation_prices', $transient_cached_prices_array[ $opposite_price_hash ], $product, ! $for_display );

Где используется хук в WooCommerce

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