我想在 Whatsapp 消息 URL 中添加一个新链接,同时生成消息 sprintf,然后通过 urlencode。
以下代码
$msg = sprintf( __("Hello %s %s, your order #%s has been received. The order amount is %s %s. Your payment method is %s. Please Confirm your order by replying *Confirm*. Please contact us if you have any question regarding your order. You can view your order here ".$orderlink." Thank you.", "woocommerce"),
$order->get_billing_first_name(),
$order->get_billing_last_name(),
$order->get_order_number(),
$order->get_currency(),
$order->get_total(),
$order->get_payment_method_title(),
);
$whatsappnum = WC()->countries->get_country_calling_code( $order->get_billing_country() ) . $order->get_billing_phone();
update_post_meta( $_GET['order_id'], '_wapp_sent_processing', 'true' ); // Mark order as WhatsApp message sent
wp_redirect( 'https://wa.me/' . $whatsappnum . '?text=' . urlencode($msg) ); // Redirect WhatsApp
此消息是为 woocommerce 订单生成的。
尝试以下操作:
$msg = sprintf(
__( "Hello %s %s, your order #%s has been received. The order amount is %s %s. Your payment method is %s. Please Confirm your order by replying *Confirm*. Please contact us if you have any question regarding your order. You can view your order here %s. Thank you.", "woocommerce"),
$order->get_billing_first_name(),
$order->get_billing_last_name(),
$order->get_order_number(),
$order->get_currency(),
$order->get_total(),
$order->get_payment_method_title(),
wc_get_endpoint_url('view-order', $order->get_id() ), // URL
);
$whatsappnum = WC()->countries->get_country_calling_code( $order->get_billing_country() ) . $order->get_billing_phone();
$order->update_meta_data('_wapp_sent_processing', '1'); // Mark order as WhatsApp message sent
$order->save(); // Save
wp_redirect( 'https://wa.me/' . $whatsappnum . '?text=' . urlencode($msg) ); // Redirect WhatsApp
应在 WhatsApp 消息中插入此订单的客户订单查看 URL