• Resolved wenlu

    (@wenlu)


    Hi,

    I’m trying to pass a variable that stored the value from API to a custom thank you page. May I know how can I get the $cert_url from functions.php and use it on custom thank you page?

    Code below is from functions.php

    add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
    function custom_woocommerce_get_cert_url( $order_id ) {
        ......
        $data = json_decode($request);
    	
        $result[]= $data;
    		
        foreach($result[0] as $line) {
            $cert_url = $line;
        }
    
        return $cert_url;
    }

    Note: $cert_url is a variable I want to pass to a custom page.

    On the custom thank you page, I’m trying use code below to create a button to share the cert url to facebook.

    <a href="https://www.facebook.com/sharer?u='.$cert_url.'&t=Digital-Certificate" target="_blank" rel="noopener noreferrer">Share this on Facebook</a>

    Please correct me if there is anything wrong from the code I mentioned above.

    Best Regards,
    Wenlu

    • This topic was modified 2 years, 6 months ago by wenlu.
    • This topic was modified 2 years, 6 months ago by Jan Dembowski. Reason: Formatting
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to pass variable from functions.php to a custom page.’ is closed to new replies.