Skip Navigation

[Resolved] How to show selected product to only login users (Woocommerce View)?

This support ticket is created 5 years, 2 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by Himanshu Agarwal 5 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1197173

Hi there,

I created a custom field (checkbox) for woocommerce products as "Only login user?".

Now i want that if this fields is checked for any product then that product must be show only to login user in product listing page.

I created a view for product listing page.

Now i want to filter product listing like this.

if (user_login)
{
Show all products
}else
{
show only product the "Only login user?" are not checked.
}

Please help me to achieve this.

#1197342

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

I think you should be able to achieve this by combing a wpv-conditional shortcode which tests whether the custom field is checked or not with a toolset_access shortcode which can hide content from guest users.

So, in the loop output section of your View, which will iterate over all of the posts of the required type, you add a conditional test for whether the only-login-user custom field is checked. So inside this condition we would know that the field is checked and only logged-in users can see it.

So in this place, within the wpv-conditional shortcode, you insert a toolset-access shortcode to deny access to guest users.

See

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

and

https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

#1199102

My issue is resolved now. Thank you!

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