woocommerce_blocks_product_grid_add_to_cart_attributes хук-фильтрWC 8.6.0

Filter to manipulate (add/modify/remove) attributes in the HTML code of the generated add to cart button.

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

add_filter( 'woocommerce_blocks_product_grid_add_to_cart_attributes', 'wp_kama_woocommerce_blocks_product_grid_add_to_cart_attributes_filter', 10, 2 );

/**
 * Function for `woocommerce_blocks_product_grid_add_to_cart_attributes` filter-hook.
 * 
 * @param array      $attributes An associative array containing default HTML attributes of the add to cart button.
 * @param WC_Product $product    The WC_Product instance of the product that will be added to the cart once the button is pressed.
 *
 * @return array
 */
function wp_kama_woocommerce_blocks_product_grid_add_to_cart_attributes_filter( $attributes, $product ){

	// filter...
	return $attributes;
}
$attributes(массив)
An associative array containing default HTML attributes of the add to cart button.
$product(WC_Product)
The WC_Product instance of the product that will be added to the cart once the button is pressed.

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

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

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

AbstractProductGrid::get_add_to_cart()
woocommerce_blocks_product_grid_add_to_cart_attributes
woocommerce/src/Blocks/BlockTypes/AbstractProductGrid.php 680
$attributes = apply_filters( 'woocommerce_blocks_product_grid_add_to_cart_attributes', $attributes, $product );

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

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