Skip Navigation

[Resolved] Reveal particular products when correct code is entered

This support ticket is created 3 years, 9 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 10 replies, has 3 voices.

Last updated by patrickM-3 3 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1685505
Screen Shot 2020-07-02 at 11.38.55 AM.png

Tell us what you are trying to do?

I have some products that are only available after a visitor enters a correct code. Half of the products are always visible. At the top of the Shop page, I want a form where the user can enter a single code. The site will then display additional products which that code unlocks. I already have configured categories for all products and I hope to be able to use those and filtering to make this work, but I need to get started.\

Is there any documentation that you are following?

I have followed the Toolset tutorial here: https://toolset.com/learn/create-an-ecommerce-wordpress-site/designing-woocommerce-product-catalog/

At step 7.3, number 1 says "Add an Archive Cell to your layout." Buyt when I create an archive, I only see a generic text editor with the standard buttons for adding Toolset fields, views, forms, etc. There is no Loop Output section, nor is there any indication of cells or any means of adding product fields to them.

Is there a similar example that we can see?

What I see is shown in the uploaded image

What is the link to your site? hidden link

#1685625

I figured out that the block editor needs to be enabled in order to see the block interface. I've got that figured out.

What I need help with is filtering products. Each product has categories and I want to hide products in several of those categories and only display them after I use a form to verify that the visitor has a specific code. I already have a custom post type that associates codes with product categories.

I would like to put a form at the top of the store page and, using the value entered, either hide or show products based on which categories are associated with the entered code. I have used the standard views editor for other custom post types, but how do I filter products while leaving the WooCommerce archive and single product templates as they are already designed?

#1686117

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

I'm afraid, there is no built-in "verification based filtering" feature available, so this will require some workaround and possibly code customizations.

To guide you in the right direction, first I'll need to fully understand the requirement and existing set up.

Few questions that I have about this implementation are:

1. The code verification will need to work only for the logged-in users or should it also work for visitors who are not logged-in?

2. For how long this verification will need to be remembered? Would it:
- be remembered for the current session only
- be remembered for a specific time with respect to the current browser on a particular device (using browser cookies)
- be remembered permanently for a logged-in user after the first verification

3. Exactly how the association between the product categories and custom post type codes works?

You're also welcome to share temporary admin login details along with a link to the shop page, where I can see how it is currently set up.

Note: Your next reply will be private and though no changes will be made on your website, please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1691247

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for sharing these details and sorry about the delay in getting back on this.

I'm currently performing some tests on my website, to suggest the best way to achieve this.

As soon as this testing completes, I'll share my findings with you.

Thank you for your patience.

regards,
Waqar

#1692059

Thanks, Waqar! I've gotten as far as adding a page to search for and find an Energy Star facility. energystardev.kiarmedia.com/find

Just a simple search form with the top 40 matches displayed. This list narrows as additional information is provided until the user sees their facility. Once their location displays, they click that button to be taken to the shop page with 2 URL parameters; 'yrs', which is the value of the EnergyStar field "certification years". The other is 'esid' which is the Energy Star field "ID".

On the shop page, I've replaced the default WooCommerce product category filter with a Plugin called WOOF, which is a more advanced filter that allows users to select multiple product categories at a time.

My plan is to add JavaScript that will read the URL variables and then trigger clicks on all of the product categories that apply. So, if a user picks a facility that was certified in 2018, the JavaScript will trigger mouse clicks on product categories of "New Homes", "Promotionsl Items", "2018 Facilities" & "2018 Buildings".

Once I get the JavaScript working, I plan to use CSS to move the product category filter selector off the left edge of the screen so it is not visible.

I am not sure if this will work as I believe I need to accommodate any AJAX functions the plugin needs. Also, I noticed that the WOOF plugin seems to replace any URL parameters with its own, internal set of variables.

You might have a better way of doing this, but just wanted to let you know what I am trying.

#1692103

One more thing, Waqar, I added a Toolset View to the default sidebar on the Shop Page. All that view does is display the information for the Energy Star who's Post ID is passed via URL variable 'es_pid' to the Shop page.

The problem is that, if I deliberately access that page without setting an URL variable for es_pid, the view in the sidebar displays the first Energy Star, rather than correctly displaying contents when there are not matches. Without an URL variable, the view should not be finding any matches, but I cannot get it to work properly. It always displays the first Energy Star post, rather than correctly finding no matches.

#1692261

I've managed to get it working using this approach, but there is a problem - each time a filter checkbox is clicked, it triggers a store page reload in the products filter plugin. Since I have to go through and potentially click about 12 different categories, that gets obnoxious. I'm checking the plugin to see if I can force it to sit there until JavaScript finishes choosing the product category filters it needs, then load the page once.

#1692533

Hello,

Thanks for the details, I can login your website.

For the question:

each time a filter checkbox is clicked, it triggers a store page reload in the products filter plugin

I assume we are talking about this page:
hidden link

It seems that this form is built with other plugins, might be products filter plugin.

If it is, I suggest you check it with plugin author of "products filter plugin", check if it is possible with their plugin.

In Toolset side, you can follow our document to setup a WordPress archive for post type "products":
https://toolset.com/learn/create-an-ecommerce-wordpress-site/designing-woocommerce-product-catalog/#creating-a-custom-shop-template-steps-to-follow

And add custom search form into above WordPress Archive:
https://toolset.com/learn/create-an-ecommerce-wordpress-site/search-filter-and-results/

In screenshot of above document:
https://toolset.com/wp-content/uploads/2017/04/setting-up-search-options.png
Choose option "Full page refresh when visitors click on the search button with input values auto-updating", so the search form will be triggered only after user click the submit button.

#1693291

Hi Luo! It's good to hear from you again. Hope all is well.

I wanted to use Toolset for configuring a Products archive, but I am worried that I won't be able to use the default WooCommerce store template if I do. I am hoping to configure this store using default templates so the client doesn't have to worry about updating WooCommerce.

I am using Toolset for searching for and finding a facility. Once the facility is selected, the URL parameters contain information about what product categories should be selected. I use Toolset on the Store page only to display a view that shows the specifics for the single facility the user selected. There is no form here and no load/reload issues are caused by Toolset or its settings.

The reloading at this point is only because the particular filtering plugin I am using is doing this. That filtering plugin is necessary because WooCommerce does not allow selection of more than a single product category. I am in touch with the author of the plugin to determine if any reload can be suppressed and then called once the product categories have been set by JavaScript.

I'll let you know what I find out from the plugin author.

#1696955

Hope all are well too.

I have marked this thread as waiting for feedback status, please let me know if you need more assistance for it.

#1703283

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.