• Resolved cartseg

    (@cartseg)


    Hello,

    I have a question regarding Woocommerce hooks on single page: I want to add a text link before the Add to cart button hook in the single product page… so users can see info on sizes/dimensions etc… how to do that?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @cartseg ,

    You can use woocommerce_before_add_to_cart_button hook,

    
    add_action('woocommerce_before_add_to_cart_button','ced_before_add_to_cart_notice');
    
    function ced_before_add_to_cart_notice(){
    //your text here
    }

    Thanks,

    Thread Starter cartseg

    (@cartseg)

    thank you very much!

    Thread Starter cartseg

    (@cartseg)

    @cedcommerce I have tried putting this:

    <a href="#">Text link</a>

    instead of //your text here but it gives me a critical error. Any idea why?
    Thanks

    • This reply was modified 6 years, 2 months ago by cartseg.
    Thread Starter cartseg

    (@cartseg)

    I cannot make it work 🙁

    Plugin Support Kel C. a11n

    (@kellymetal)

    Hi there,

    The text will need to be in quotes to set it aside from the PHP code, and you will need to use echo to print it to the page — so taking your example, something like this:

    
    add_action('woocommerce_before_add_to_cart_button','ced_before_add_to_cart_notice');
    function ced_before_add_to_cart_notice(){
        echo '<a href="#">Text link</a>';
    }
    

    I hope that helps!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Text link before add to cart hook’ is closed to new replies.