Disable Add to cart button replacement

Posted by: negru13

26th February 2022, 1:03 pm

negru13

@negru13

26 Feb 2022
1:03 pm

Hi,

How can I disable the replacement of an "Add to cart" button on a specific page and then add just the download button through a shortcode?

If I exclude the product from the settings the shortcode output will dissapear also.

Why do I need to do this? Cuz:

I have a "Name your price" plugin that lets the user set any price to a product if he wants to contribute to the project, and the problem is that the product price is set on "0$", the "Download now" button appears and replaces the standard "Add to cart" button that facilitates the donation (if any) from the user. So in this situation, if the user writes in the custom price field a value of 1$ it has no redirection with that value to the checkout page.

So, my thought on this and what I'm trying to do is to check the price from the input field for a value greater than 0 and if returns true, to show to the user the standard "Add to cart" button. If the value is null or equal to "0" to show the "Download now" button through a shortcode right next below the custom price field with:

echo do_shortcode('[download_now id="54639" text="Download"]');

How can I do this?

Thank you,

Adrian D.

  • Developer
    Richard Webster

    @rwebster

    26 Feb 2022
    3:49 pm

    Hi mate, you can disable the hiding of the add to cart with a snippet. Is it only 1 product you want that for?

  • negru13

    @negru13

    26 Feb 2022
    5:27 pm

    Hi Richard,

    Thank you for your answer, no, I would like to do that for multiple products. This is the first. Can you show me how the snippet must be?

    BR

  • negru13

    @negru13

    3 Mar 2022
    3:43 am

    Could you tell me at least what action do I need to remove in order to make the default add to cart button appear? I mean programmatically.

  • Developer
    Richard Webster

    @rwebster

    3 Mar 2022
    11:55 am

    Hi mate, sorry for the late response. The following snippet will prevent the removal/hiding of the ability to purchase valid free downloads:

    remove_action('somdn_hide_cart_style', 'somdn_hide_cart_style_output');
    remove_filter('woocommerce_is_purchasable', 'somdn_prevent_purchase', 10);
  • negru13

    @negru13

    4 Mar 2022
    12:30 am

    Thx, mate! It would be great to add compatibility for the Name your price plugins. And maybe a small dev doc with the hooks. Cheers!

    Last modified: 4th March 2022, 12:49 am by negru13

This topic is closed to new replies.