Hello. I'm trying to add a custom field in a order in woocommerce. I got it, but I want to get clickable that custom field and i can't do it.
This works to show the custom field:
function action_woocommerce_order_details_after_customer_details($order) {
echo get_post_meta( $order->id, 'wpcf-codi-qr-amb-el-carnet-de-soci-de-la-familia', true );
}
add_action('woocommerce_order_details_after_customer_details', 'action_woocommerce_order_details_after_customer_details', 10, 1);
But when i want to do it clickable it doesn't work.
function action_woocommerce_order_details_after_customer_details($order) {
$lamevaurl = get_post_meta( $order->id, 'wpcf-codi-qr-amb-el-carnet-de-soci-de-la-familia', true );
if(!empty($lamevaurl)){
<em><u>versteckter Link</u></em>
}
add_action('woocommerce_order_details_after_customer_details', 'action_woocommerce_order_details_after_customer_details', 10, 1);
it there any way to solve this?
Thanks in advanced!
Hi David,
Thank you for getting in touch.
It would appear that you're not actually printing the text onto the page. Please try the following.
function action_woocommerce_order_details_after_customer_details($order) {
$lamevaurl = get_post_meta( $order->id, 'wpcf-codi-qr-amb-el-carnet-de-soci-de-la-familia', true );
if(!empty($lamevaurl)){
echo "<em><u>versteckter Link</u></em>;
}
add_action('woocommerce_order_details_after_customer_details', 'action_woocommerce_order_details_after_customer_details', 10, 1);
Let me know if this helps.
Thanks,
Shane
Hello again Shane. That code does not work for me. However... i made som changes in your code and now is working (thx 2 you).
This is right code:
function action_woocommerce_order_details_after_customer_details($order) {
$lamevaurl = get_post_meta( $order->id, 'wpcf-codi-qr-amb-el-carnet-de-soci-de-la-familia', true );
if(!empty($lamevaurl)){
echo "<a href='".$lamevaurl."'target='_blank' title='Descarrega QR de Soci'>Descarrega el QR del carnet de soci</a>";
}
}
add_action('woocommerce_order_details_after_customer_details', 'action_woocommerce_order_details_after_customer_details', 10, 1);
Thanks again for your help and your support!!!
My issue is resolved now. Thank you!