Skip Navigation

[Resolved] Problem with shortcode

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 3 replies, has 2 voices.

Last updated by David Gimenez 2 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#2264697

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)){ 
<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);

it there any way to solve this?

Thanks in advanced!

#2264761

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

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 "<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);

Let me know if this helps.

Thanks,
Shane

#2267837

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!!!

#2267839

My issue is resolved now. Thank you!