• Hello everyone!

    I’m trying to add an overlay via a plugin to the following CSS string:

    .woocommerce-page.et_pb_button_helper_class a.button

    However, all the woocommerce buttons are trigger overlays because the string for them are the same. I therefore need custom coding to isolate this button to add the new string.

    For example, I’m looking to add an ID to the cancel button:

    #cancelbutton

    The new string will look like:

    #cancelbutton .woocommerce-page.et_pb_button_helper_class a.button

    I think I can achieve this by writing a custom function snippet and adding it to my functions file, yet I’m not proficient enough to do this although I imagine it shouldn’t be very difficult?

    Does anyone have suggestions prior to hiring a developer for something that likely wouldn’t take too long?

    Thank you!

    Joseph

    • This topic was modified 6 years, 2 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi there ??

    One way I can think of would be filtering the cart link. I’m not entirely sure if that’s what you are looking for but maybe something like this might work:

    
    add_filter( 'woocommerce_loop_add_to_cart_link', function( $product, $args ) {
      $link = sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
        esc_url( $product->add_to_cart_url() ),
        esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
        'button your-class-here',
        isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
        esc_html( $product->add_to_cart_text() )
      );
      return $link;
    }, 10, 2 );
    
    • This reply was modified 6 years, 2 months ago by Jose Castaneda. Reason: removed extra comma
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Moved to Fixing WordPress, this is not a Developing with WordPress topic.

    Please ask plugin specific questions in that plugin’s sub-forum instead.

    Thread Starter Joseph Meyer

    (@joemeyer)

    Hi Jan!

    Nothing in WP was broken, so I didn’t think “fixing WP” was the appropriate forum. Instead, I thought adding an ID was more relevant in “developing” than “fixing.”

    Either way, thanks so much Jose for your contribution. I think that what I am after is a bit more simple, and I apologize for not being clearer.

    For context:

    I’m using WP Subscriptions + WooCommerce and there is a “cancel” button on their /my-account page. I am using another plugin to generate pop-ups. I want to highlight *only* that button, yet the way WC is currently set up, the “cancel” button uses the same string as all the other buttons. Thus, when we use the pop-up, it triggers on ALL WC buttons. I simply want to the the cancel button’s ID so I can highlight it.

    Thoughts?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add a String to a WC Button’ is closed to new replies.