Trong kênh WooCommerce của Genesis Slack, một người dùng đã hỏi:
Câu hỏi hoàn toàn ngẫu nhiên nhưng có ai biết cách xóa nút “Chọn Tùy chọn” trong Trang chính của WooCommerce Shop không?
woocommerce_loop_add_to_cart_link
có thể sử dụng móc lọc để loại bỏ các nút Chọn tùy chọn cho từng sản phẩm biến.
Thêm phần sau vào functions.php của chủ đề con :
// Remove "Select options" button from (variable) products on the main WooCommerce shop page.
add_filter( 'woocommerce_loop_add_to_cart_link', function( $product ) {
global $product;
if ( is_shop() && 'variable' === $product->product_type ) {
return '';
} else {
sprintf( '%s',
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
esc_html( $product->add_to_cart_text() )
);
}
} );