Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1197385
    Rich R
    Participant

    Hello!

    I wanted to see what the best way you recommend I go if I wanted to remove this button on selected pages.

    It’s the one titled “promo pricing available” and it’s next to the “add to cart” button on all products but we have some used items that do not qualify for special pricing.

    I am currently using this line of code recommended by this forum.

    add_action(‘woocommerce_after_add_to_cart_button’,’cmk_additional_button’);
    function cmk_additional_button() {
    echo ‘Promo Pricing Available – CALL NOW!‘;
    }

    Thanks!

    #1197773
    Darshana
    Moderator

    Hi there,

    You can use the following code for that and set your WooCommerce Post ID (Eg:96). You can locate post IDs as follows (https://community.theme.co/kb/how-to-locate-post-ids/).

    
    add_action('woocommerce_after_add_to_cart_button','cmk_additional_button');
    function cmk_additional_button() {
      if (!is_single('96')) {
        echo "<a href='http://your.link/to' class='my-promo-btn x-btn'>Promo Pricing Available – CALL NOW!</a>";
      }
    }
    

    Hope that helps.

    #1205191
    Rich R
    Participant

    Thanks!

    That will come in handy for when I need to remove a button from a single product.

    However, I am looking for a way to apply it to a specific category of products.

    In this case, I am referring to the “used equipment” page where there are over 40 products that will not need the “Call for Promo” button.

    I have tried… is_single, is_page, is_category, array, all the post id’s, etc with no luck.

    What else do you think I should try?

    #1205405
    Rupok
    Member

    Hi there,

    In that case I could suggest you to remove with CSS.
    You can add this under Custom > CSS in the Customizer.

    .product_cat-used-equipment .my-promo-btn.x-btn {
      display: none;
    }

    Hope this helps.

    #1205466
    Rich R
    Participant

    Thank you that works!

    Should I remove the old/dead code from functions.php?

    #1205545
    Joao
    Moderator

    Hi Rich,

    Please use just the code Darshana provided you.

    Thanks,

    Joao

  • <script> jQuery(function($){ $("#no-reply-1197385 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>