ciative 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 Returns an associative array derived from the default array passed as an argument and added the extra HTML attributes. */ $attributes = apply_filters( 'woocommerce_blocks_product_grid_add_to_cart_attributes', $attributes, $product ); return sprintf( '%s', esc_url( $product->add_to_cart_url() ), wc_implode_html_attributes( $attributes ), esc_html( $product->add_to_cart_text() ) ); } /** * Extra data passed through from server to client for block. * * @param array $attributes Any attributes that currently are available from the block. * Note, this will be empty in the editor context when the block is * not in the post content on editor load. */ protected function enqueue_data( array $attributes = [] ) { parent::enqueue_data( $attributes ); $this->asset_data_registry->add( 'minColumns', wc_get_theme_support( 'product_blocks::min_columns', 1 ) ); $this->asset_data_registry->add( 'maxColumns', wc_get_theme_support( 'product_blocks::max_columns', 6 ) ); $this->asset_data_registry->add( 'defaultColumns', wc_get_theme_support( 'product_blocks::default_columns', 3 ) ); $this->asset_data_registry->add( 'minRows', wc_get_theme_support( 'product_blocks::min_rows', 1 ) ); $this->asset_data_registry->add( 'maxRows', wc_get_theme_support( 'product_blocks::max_rows', 6 ) ); $this->asset_data_registry->add( 'defaultRows', wc_get_theme_support( 'product_blocks::default_rows', 3 ) ); } /** * Get the frontend style handle for this block type. * * @return string[] */ protected function get_block_type_style() { // Currently these blocks rely on the styles from the All Products block. return [ 'wc-blocks-style', 'wc-blocks-style-all-products' ]; } }