Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active October 13, 2019 23:49
Show Gist options
  • Save srikat/c98bb6e2bafdba19a3f43cee5c3ad7ac to your computer and use it in GitHub Desktop.
Save srikat/c98bb6e2bafdba19a3f43cee5c3ad7ac to your computer and use it in GitHub Desktop.

Revisions

  1. srikat revised this gist Aug 20, 2018. No changes.
  2. srikat revised this gist Aug 20, 2018. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,18 @@
    // 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 {
    return sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
    sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
    esc_url( $product->add_to_cart_url() ),
    esc_attr( isset( $quantity ) ? $quantity : 1 ),
    esc_attr( $product->id ),
    esc_attr( $product->get_sku() ),
    esc_attr( isset( $class ) ? $class : 'button' ),
    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() )
    );
    }

    } );
  3. srikat revised this gist Feb 23, 2017. No changes.
  4. srikat revised this gist Feb 23, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // Remove "Select options" button from (variable) products on the main WooCommerceshop page.
    // 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;

  5. srikat created this gist Feb 23, 2017.
    17 changes: 17 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // Remove "Select options" button from (variable) products on the main WooCommerceshop page.
    add_filter( 'woocommerce_loop_add_to_cart_link', function( $product ) {
    global $product;

    if ( is_shop() && 'variable' === $product->product_type ) {
    return '';
    } else {
    return sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
    esc_url( $product->add_to_cart_url() ),
    esc_attr( isset( $quantity ) ? $quantity : 1 ),
    esc_attr( $product->id ),
    esc_attr( $product->get_sku() ),
    esc_attr( isset( $class ) ? $class : 'button' ),
    esc_html( $product->add_to_cart_text() )
    );
    }
    } );