woocommerce_blocks_product_grid_add_to_cart_attributes
Filter to manipulate (add/modify/remove) attributes in the HTML code of the generated add to cart button.
Usage
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(array)
- 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.
Changelog
| Since 8.6.0 | Introduced. |
Where the hook is called
woocommerce_blocks_product_grid_add_to_cart_attributes
woocommerce/src/Blocks/BlockTypes/AbstractProductGrid.php 681
$attributes = apply_filters( 'woocommerce_blocks_product_grid_add_to_cart_attributes', $attributes, $product );