Skip Navigation

[Resuelto] WooCommerce Additional Meta Key Values In Views Loop

This support ticket is created hace 8 años, 3 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 respuesta, has 2 mensajes.

Last updated by Beda hace 8 años, 2 meses.

Assisted by: Beda.

Autor
Mensajes
#363206

Hi guys,

We're trying to create a custom loop that pulls additional 'meta_key' information from the '_woocommerce_order_itemmeta' table. In the default Views Loop we see that the following WooCommerce 'product' fields/post meta are able to be inserted into the loop:

* Add to cart button - product listing pages
* Product price
* Add to cart button - single product page
* Product image
* Add to cart message
* Product tabs - single product page
* Onsale badge
* Product attributes
* Related Products
* Product Rating - single product page
* Product Rating - product listing pages
* Product Category Image
* Product Upsell
* Breadcrumb
* Product meta
* Cart Count
* Reviews

What we've done so far: because WooCommerce registers their post types as not public (i.e. 'public' => false), we've added the following to our functions.php file to be able to pull in 'orders' post types into the Views Loop:

add_filter( 'woocommerce_register_post_type_shop_order', function ( $args ) {
	$args['public'] = true;
	return $args;
});

However, what we're not clear on is how to get additional meta_key values recognized by Views (for instance the '_qty' meta key value from the _woocommerce_order_itemmeta table. We do know that we can write a shortcode and then add that shortcode under the 'Views > Compatability' setting, but we're not sure if that's the right approach both from a performance and ease-of-implementation perpective.

As such could you please guide us on how we can get additional meta_key values for CPTs recognized in the Views loop?

Thanks in advance!

#363326

Hidden Custom fields can be added to Views under Views > Settings > Hidden custom fields.

That will make the Fields visible in the Query Options and in the Post field section when inserting ShortCodes in a View Loop Editor.

Otherwise a ShortCode is always a good approach as it gets triggered only when you / where you insert it, but with above approach you should be fine too.

Please let me know if the above solution works for you, I look forward to your reply!

Thank you for your patience.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.