Skip Navigation

[Resolved] Can't override product archive template php file in Woocommerce Blocks

This support ticket is created 3 years, 8 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Kyle 3 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#2058789

I want to override archive-product.php, previously I would go to the WoocommerceViews/Blocks settings page and change the template usage to the theme, then have my override file in the template. The settings page is gone from the menu and can't be accessed at ..admin.php?page=wpv_wc_views.

How can I override this page template now?

I am using:
Toolset Blocks 1.5.1
Toolset WooCommerce Blocks Version 3.0

#2058839

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kyle,

Thank you for getting in touch.

In our Latest Woocommerce blocks plugin these settings have been removed and will be triggered automatically when you create a custom template and assign it to the Product post type.

So you should be able to just go to Toolset -> WordPress Archive and create your custom product archive page and your template should apply automatically.

Thanks,
Shane

#2059305

Hi Shane,

Thank you for the reply.

I have created a custom Product Archive in Toolset and I have created an override file in my theme for product archives (archive-product.php). I need this template in addition to the Toolset Archive so that I can make changes to the H1 which is in archive-product.php.

I have placed my copy of archive-product.php directly in the theme folder and tried in a woocommerce subfolder of my theme, neither work.

Kind Regards,
Kyle

#2060039

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kyle,

It should be noted that WooCommerce Blocks won't be able to use your custom archive-product.php template to display any custom Archive template created at Toolset -> WordPress Archives.

This is because the archive-product.php template that you want to use won't have the integrations required for Toolset to display the custom archives.

Our Custom Archive should allow you to overwrite the H1 tag on the product archive page, does this not happen when you assign a custom archive to your Products?

If the archive is empty then the page should be blank and you can add your components to the page. Perhaps some screenshots will help me to understand better but if you're going to create a custom archive with Toolset then our template file is going to be used.

Thanks,
Shane

#2061009
product archive structure.jpg

It's a problem that WooCommerce Blocks does not use archive-product.php, since there are elements that fall outside of the blocked editor, such as the page title and description.

Also, unless I am missing something, Toolset does not allow me to add a DYNAMIC Archive title in an H1 tag from the block editor for the archive. This Toolset archive is used for all product categories, so I can't add a static title in the block editor.

I have attached an image that shows how the page is structured. The page title and breadcrumb are part of the page template, even if I can add both of these in the block editor, how would I remove them from the PHP file if I can't override it? The inability to override template files because of Woocommerce blocks is a bit of a problem, it breaks standard WordPress template hierarchy rules, and we could change this previously in the settings page of Toolset.

#2062069

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kyle,

The way you would overwrite these elements is by the use of the Woocommerce Hooks.
hidden link

These areas of the template require the use of Hooks to overwrite. Only the product listing area can be overwritten from our Custom Templates.

This also holds true for non-woocommerce archives as well. Generally on archives the Titles require the use of their respective hooks to overwrite them

Please let me know if this clears up the issue for you.
Thanks,
Shane

#2066097

It has not always been this way, that you would need hooks for Title since you could override the entire page. Anyway, thank you for the help, I have found a way to achieve the layout that I want.