Search code examples
phpwoocommercevisual-composer

Add PHP code to a button created using Visual Composer in a woocommerce powered website


I have created a form using visual composer. In this form I want to assign a PHP function defined in functions.php to the submit button.

How can I do this?


Solution

  • You Can Do Like This

    // Your Shortcode to output the custom PHP in Visual Composer.
    function my_vc_shortcode( $atts ) {
       // Your Custom Php Code Here 
       return '<h2>This is my custom PHP output!</h2>';
    }
    add_shortcode( 'my_vc_php_output', 'my_vc_shortcode');
    

    Check Source Code Here:

    1. https://theremotedev.com/custom-php-code-visual-composer-pages/
    2. Insert PHP code into the Visual Composer