Skip Navigation

[Resolved] I cannot change the woocommerce product archive.

This support ticket is created 5 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.

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
- 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/Karachi (GMT+05:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Waqar 5 years, 8 months ago.

Assisted by: Waqar.

Author
Posts
#1207544

Hello

I try to create a woo product archive, I set the woo views plugin correcty to use it's own template, WooCommerce Views plugin default product archive template, but it is not changing. The single template is working.

#1207589
#1207598

Ok, I deactivated all plugins not toolset or woo and change to twenty seventeen. The archive is the same default one.

#1207823

Hi Jozsef,

Thanks for the update and sorry to learn that issue still persists.

Would it be possible for you to share a clone or snapshot of your website with us?
(it can be from this website or from another test website where the issue is reproducible)

We usually recommend the free Plugin “Duplicator” (http://wordpress.org/plugins/duplicator/) for this porpoise.

If you already know how Duplicator works, you can skip the instruction video and just send me the installer file and the zipped package you downloaded.

Duplicator Instructions:
hidden link

( note: I'll need both files and you'll probably want to use DropBox, Google Drive, or similar services, as the snapshot file will be quite big )

IMPORTANT: Remember to create or keep an admin account for me before creating the snapshot, or I won’t be able to log in. You may delete the new admin account once the snapshot has been built.

I will set your next answer as private so you can provide me the information securely.

regards,
Waqar

#1208166
#1208542

Hi Jozsef,

Thank you for sharing the duplicator package.

I've just sent a request through Google Drive so that you can approve its access.

regards,
Waqar

#1209247

I've given you access on friday. Can you access it?

#1209392

Hi Jozsef,

Thank you for allowing access to the duplicator package.

I was able to deploy your website's clone successfully on my server and I'm currently performing a few tests.

Will update you with results, as soon as, I have some findings.

Thank you for your patience.

regards,
Waqar

#1209805

Hi Jozsef,

Thank you for waiting.

During troubleshooting, I noticed that in your website's WooCommerce settings, were set to "Show categories" and not "Show products" on the shop page.
( you'll find this option at WP Admin -> Appearance -> Customize -> WooCommerce -> Product Catalog - hidden link )

Since the WordPress Archive View for Products is designed to show products, it is not applied to the shop page, when product categories are showing, instead of the products.

To make sure the product archive is applied to your shop page, you can change that option to "Show products".

If you'd like to show product categories on the shop page, you can create a new view that shows the product categories and add it in your product archive view, above the loop.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1210568

Ok, but I need to show categories > subcategories > products from subcategories. I have products only in subcategories. And I need to show the category structure until I arrive to products. What would be the correct approach to do this? I thought that maybe by using content templates for product category taxonomy archive will do this but again, nothing happens.

#1211892

Hi Jozsef,

Thanks for writing back.

The setup that your website requires involves a couple of steps:

1. First, you'll need a custom function to detect if the current page is an archive for a subcategory for Products.

Please add the following code, at the bottom of your active theme's "functions.php" file:


function is_subcategory($cat_id = null) {
	if (is_tax('product_cat')) {

		if (empty($cat_id)){
			$cat_id = get_queried_object_id();
		}

		$cat = get_term(get_queried_object_id(), 'product_cat');
		if ( empty($cat->parent) ){
			return 0;
		}else{
			return 1;
		}
	}
	return 0;
}

2. Next, go to WP Admin -> Toolset -> Settings and in "Front-end Content" tab, scroll to "Functions inside conditional evaluations" section and add "is_subcategory" in the "Function name" field to register it.
( ref: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/ )

3. Go to WP Admin -> Appearance -> Customize -> WooCommerce -> Product Catalog and select "Show products" for both "Shop page display" and "Category display" options.

4. Create a new view "View to show product cats" from WP Admin -> Toolset -> Views and configure it to show only those "Product Categories" which have no parent, as shown in this screenshot:
hidden link

This view will be used to show only the grandparent categories on the shop page.

5. Open your "Products" archive view ( hidden link ) and remove everything in between "<wpv-loop wrap="4" pad="true"> ... </wpv-loop>" tags and insert the shortcode for the newly created view (from the step 4) after "[wpv-layout-start]".
screenshot: hidden link

Now, your main shop page should be only showing the list of grandparent product categories.

6. Next, create a new WordPress archive view for the "Product categories" taxonomy archive from WP Admin -> Toolset -> WordPress Archives.
screenshot: hidden link

Design this view, how you'd like your products to show, on subcategory archive pages.

7. To show the list of subcategories and not the products, when the parent level product category archive page is showing, duplicate the view "View to show product cats" that was created in step 4 and name the duplicated view as "View to show product sub-cats".

The only way this duplicated view would be different from the original one would be that the "Query Filter" should be set to "Select taxonomy terms whose parent is the current taxonomy archive."
screenshot: hidden link

8. The last step would be to make the WordPress archive view created in step 6, to show this "View to show product sub-cats" view conditionally.

Open the view "Product categories" (step 6) and in the "Output Editor" section, replace:


[wpv-filter-meta-html]
[wpv-layout-meta-html]

With:


[wpv-conditional if="( is_subcategory() eq '1' )"]
[wpv-filter-meta-html]
[wpv-layout-meta-html]
[/wpv-conditional]

[wpv-conditional if="( is_subcategory() eq '0' )"]
[wpv-view name="view-to-show-product-sub-cats"]
[/wpv-conditional]

As a result, on the archive page for the parent category, it will show the list of sub-categories (from a view created in step 7).

And when on the archive page for the subcategory, it will show the products from that subcategory (from a view created in step 6).

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar