Skip Navigation

[Resolved] Need to get upsell pro

This support ticket is created 6 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 6 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#875282

Tell us what you are trying to do?

Just need to add a view to my single product template page that lists upsell products- how do I filter for that? Cheers.

#875827

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to get upsell product IDs you need to use custom shortcode that returns all the upsell product IDs.

For example:


function func_get_product_upsell_ids() {
global $post;

$product = new WC_Product($post->ID);
$upsells = $product->get_upsell_ids();

return join(",",$upsells);

}
add_shortcode( 'get_upsell_ids', 'func_get_product_upsell_ids' );

And create a view, add Query filter and filter it by Post Id and select filter by shortcode attribute:

[wpv-view name="view-name" ids="[get_upsell_ids]"]

Where:
- ids is a view's shortcode attribute that contains the value returns by shortcode [get_upsell_ids].
- Please DO NOT FORGET to register the shortcode name get_upsell_ids at:
=> Toolset => Settings => Front-end Content => Third-party shortcode arguments

More info:
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes
=> https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/#source-for-compare-value