woocommerce_loop_add_to_cart_args filter-hookWC 9.7.0

Allow filtering of the add to cart button arguments.

Usage

add_filter( 'woocommerce_loop_add_to_cart_args', 'wp_kama_woocommerce_loop_add_to_cart_args_filter', 10, 2 );

/**
 * Function for `woocommerce_loop_add_to_cart_args` filter-hook.
 * 
 * @param  $array   
 * @param  $product 
 *
 * @return 
 */
function wp_kama_woocommerce_loop_add_to_cart_args_filter( $array, $product ){

	// filter...
	return $array;
}
$array
-
$product
-

Changelog

Since 9.7.0 Introduced.

Where the hook is called

ProductButton::render()
woocommerce_loop_add_to_cart_args
woocommerce_template_loop_add_to_cart()
woocommerce_loop_add_to_cart_args
woocommerce/src/Blocks/BlockTypes/ProductButton.php 143-155
$args = apply_filters(
	'woocommerce_loop_add_to_cart_args',
	array(
		'class'      => $html_classes,
		'attributes' => array(
			'data-product_id'  => $product->get_id(),
			'data-product_sku' => $product->get_sku(),
			'aria-label'       => $product->add_to_cart_description(),
			'rel'              => 'nofollow',
		),
	),
	$product
);
woocommerce/includes/wc-template-functions.php 1394
$args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product );

Where the hook is used in WooCommerce

Usage not found.