skip to Main Content

I need to add custom button down to add to cart in product page that triggers shortcode for popup
please
enter image description here

2

Answers


  1. add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart_button_func' );
    /*
     * Content below "Add to cart" Button.
     */
    function add_content_after_addtocart_button_func() {
    
            // Echo content.
            echo 'Add your code here';
    
    }
    
    Login or Signup to reply.
  2. function buttonElement( $atts, $content = null) {
        extract( shortcode_atts( array(
            'link' => ''
        ), $atts ) );
        return'<a href="'.$link.'">$content</a>';
    };
    add_shortcode('button', 'buttonElement');
    

    So now you have to call the shorcode as below:

    [button link"add__your__button__link" ]Here is button text[/button]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search