skip to Main Content

I want to include the full order link in a message to my whatsapp. After completing the purchase, the customer will click this link to send his order to my whatsapp.

add_action( 'woocommerce_thankyou', 'send_order_link' );
function send_order_link( $order ) {
$link .= '<p><a href="https://wa.me/5513123456789?text=This is my order:'.$order->get_checkout_order_received_url.'">Send order</a></p>'; 
echo $link;
}

2

Answers


  1. Chosen as BEST ANSWER

    I did! I created a template to override the original woocommerce template order-details.php I inserted this line of code in the template:

     <?php $link_whats = "https://wa.me/5513996004985?text=".$order->get_checkout_order_received_url()."MyEncodedText"; echo "<a href='$link_whats' target='_blank'><button>WhatsApp</button></a>" ?>
    

  2. you forgot to call function is not object. call as function

    Instead of:❌

       $order->get_checkout_order_received_url 
    

    Use this:✅

       $order->get_checkout_order_received_url() 
    

    .

     add_action( 'woocommerce_thankyou', 'send_order_link' );
        function send_order_link( $order ) {
        $link .= '<p><a href="https://wa.me/5513123456789?text=This is my order:'.$order->get_checkout_order_received_url.'">Send order</a></p>'; 
        echo $link;
        }
    

    Ref https://wp-kama.com/plugin/woocommerce/function/WC_Order::get_checkout_order_received_url

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search