Skip Navigation

[Resuelto] How to add the meta also to the woocommerce order in admin side

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

Using Toolset form commerce to submit the form and post custom meta fields, how to add the meta also to the order in wordpress admin side.

Solution:

There isn't such kind of feature within Toolset plugins, it needs custom codes, You might consider the action hook "woocommerce_checkout_create_order_line_item" of Woocommerce plugin, for example:

https://toolset.com/forums/topic/how-add-the-meta-also-to-the-woocommerce-order/#post-1118111

Relevant Documentation:

This support ticket is created hace 6 años, 1 mes. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por domenicoS hace 6 años, 1 mes.

Asistido por: Luo Yang.

Autor
Mensajes
#1118099

Hi, is perfect, thanks.
Just the last thing. How add the meta also to the order as in the image?
Now is added only to the cart.

Thank you Luo for your great support

#1118111

Hello,

Same as your previous tickets, there isn't such kind of feature within Toolset plugins, it needs custom codes, according to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/

Here are my suggestions:
You might consider the action hook "woocommerce_checkout_create_order_line_item" of Woocommerce plugin, for example:

/**
 * Display the custom field value in the order admin side
 */
function custom_meta_after_order_itemmeta( $item_id, $item, $product) { 
	$order_id = get_the_ID();
    $cred_meta = get_post_meta( $order_id, '_cred_meta');
	
	$cred_meta = maybe_unserialize( $cred_meta[0] );
	$extra_text = '';
	if(isset($cred_meta[0]['cred_post_id'])){
		$post_id = $cred_meta[0]['cred_post_id'];
		
		$adult_num = get_post_meta($post_id, 'wpcf-adult-number', true);
		$extra_text .= sprintf(
			'<p>%s</p>',
			esc_html( 'Adult number: ' . $adult_num )
		);
	}
	echo $extra_text;
}; 

// add the action
add_action( 'woocommerce_after_order_itemmeta', 'custom_meta_after_order_itemmeta', 10, 3);

See the result here:
enlace oculto

I am on holidays, you might get delay answer, if you have other new questions, please create new tickets, our other supporters will handle them. thanks

#1119658

My issue is resolved now. Thank you!