Skip Navigation

[Resolved] Is there a Woocommerce field that will display Products Ordered in an order?

This thread is resolved. Here is a description of the problem and solution.

Problem:

The customer asked is there a Woocommerce field that will display products ordered in an order?

Solution:

Guided that the Toolset offers a "wpv-ordered-product-ids" shortcode which returns the comma-separated list of products that are included in order.

A custom shortcode will be needed, that gets those product IDs and then shows their titles with links, separated by commas.
( ref: https://toolset.com/forums/topic/is-there-a-woocommerce-field-that-will-display-products-ordered-in-an-order/#post-2254183 )

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-ordered-product-ids

This support ticket is created 3 years 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 – 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/Karachi (GMT+05:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by martham 3 years ago.

Assisted by: Waqar.

Author
Posts
#2253927

Please look at the page here:

hidden link

We are trying to emulate the page located here:

hidden link

The only thing we're missing is the field on the original page that shows:

Title: Individual Member

This field pulls the Ordered Product Title from the store order. I'm not seeing a field that will do that in Toolset. I currently have the field defined as

[wpv-woo-product-meta]

But that's only producing a blank space. I also tried the field called Ordered Products, but that only produces numerical output, which I assume is the ID # for the product.

#2254183

Hi,

Thank you for contacting us and I'd be happy to assist.

The Toolset offers a "wpv-ordered-product-ids" shortcode which returns the comma-separated list of products that are included in the order:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/


[wpv-ordered-product-ids]

You can use this shortcode in a custom registered shortcode that gets those product IDs and then show their titles with links, separated by commas.


add_shortcode('get_ordered_product_titles', 'get_ordered_product_titles_func');
function get_ordered_product_titles_func() {
	$product_ids = do_shortcode('[wpv-ordered-product-ids]');
	if(!empty($product_ids)) {
		$output = array();
		$product_ids_arr = explode(',', $product_ids);
		foreach ($product_ids_arr as $product_ids_arr_item) {
			$output[] = do_shortcode('[wpv-post-link item="'.$product_ids_arr_item.'"]');
		}
		return implode(', ', $output);
	}
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

After that, you can use this newly registered custom shortcode in the view loop for the orders, like this:


[get_ordered_product_titles]

Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#2254285

That worked PERFECTLY on our test orders! Thanks a bunch! I'll let you know if anything seems wrong here when we start getting real orders with more products after making this site live, but I think this should work fine. I'll mark this as resolved. Thanks again. Outstanding help here.

#2254287

My issue is resolved now. Thank you!