Skip Navigation

[Gelöst] Need to get upsell pro

This support ticket is created vor 6 Jahren, 6 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 6 Jahren, 6 Monaten.

Assistiert von: Minesh.

Author
Artikel
#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

Sprachen: Englisch (English )

Zeitzone: 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