Skip Navigation

[Résolu] Need to get upsell pro

This support ticket is created Il y a 5 années et 11 mois. 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
- 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)

Marqué : 

This topic contains 1 réponse, has 2 voix.

Last updated by Minesh Il y a 5 années et 11 mois.

Assisted by: Minesh.

Auteur
Publications
#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: Anglais (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

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