Skip Navigation

[Resolved] Custom View to display Upsell/Related Products

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)

This topic contains 6 replies, has 2 voices.

Last updated by Minesh 1 year, 2 months ago.

Assisted by: Minesh.

Author
Posts
#2647971
Screenshot_2.jpg
Screenshot_1.jpg

I have read many upsell views related articles on this KB and got to:

1) created a shortcode snippet
/**
* Register shortcode to return list of upsell IDs
*/
add_shortcode( 'upsells', function(){

global $post;

$upsell_ids = get_post_meta( $post->ID, '_upsell_ids', true );

if ( isset( $upsell_ids ) ){
$upsell_list = implode( ",", $upsell_ids );
return $upsell_list;
}
});

2) registered the shortcode argument (screenshot 2)

3) created a view with the slug "upsells-related-products" and set the filter as per screenshot 1

4) added this shortcode in my Elementor Single Product Page template
[wpv-view name="upsells-related-products" ids="[upsells]"]

Problem: it shows all the products and after the last product, it shows "]
When I place [upsells] outside of the wpv-view, I get the correct Upsel products 1866,1869
But it does not work inside the shortcode.

#2648249

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I will have to check the code where you integrated it with your site.

Can you please share problem URL as well as admin access details so I can review your current code and check whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2648689

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've created the following content template and added your upsell product view inside this content template:
- hidden link

And then I've edit your existing elementor product template:
- hidden link

And added the content template created above as given under:

[wpv-post-body view_template="upsell-product-view-container"]

Can you please confirm it works as expected.

#2648691

A view inside a content template, would not have thought about that. Is this the general rule when using shortcodes inside a view. Not to insert them directly into the web page, but first into a content template?

#2648693

Minesh
Supporter

Languages: English (English )

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

No - its because in your elementor template the elementor template does not able to parse the view with view shortcode argument id="[upsell]".

So that is why we move the view inside the content template and therefore we created and new content template and move the view to it so the view is parsed without any issues.

#2648695

Is there any way I could have a View of 8 Upsell/Related products where the upsell products are displayed first and then, if room for related products, those are added?
Like 3 upsell products and then 5 related products inside the grid of 2x4? Now the 8 related products are dangling a bit silly below the upsell products.

#2648699

Minesh
Supporter

Languages: English (English )

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

As per our support policy - we entertain only one question per ticket, This will help other users searching on the forum as well as help us write problem resolution summery for the original question reported with this ticket.

May I kindly ask you to open a new ticket with every new question you may have. Currently, I will split this ticket with your new question and you can mark this ticket as resolved.

We can continue with the following split ticket:
- https://toolset.com/forums/topic/split-custom-view-to-display-upsell-related-products-display-upsell-and-related-product-when-upcell-is-product-is-less-than-eight/