12
votes

As I understand by default Woocommerce shop page uses product archive template. What I am looking for, is to use a custom template for shop page.

Here is what I did:

  1. Create template "my-shop"
  2. Create page "My shop" -> choose template "my-shop"
  3. Choose "My shop" as Woocommerce shop page

But none of the changes I made to "my-shop" template are present on the shop page.

What am I missing here? I would not like to change product archive itself, just the shop page.

Is there a way to disable product archive from being a default for shop page?

Thanks

5

5 Answers

5
votes

I know it's too late and you may have figured it out by now. In any case, the changes that you would like to make to the WooCommerce Shop Page need to be done in the archive-product.php and it would be safer to create a child theme and do these changes. Making enhancements and customizations in a Child theme is best practice so that you can update the parent theme at any time and it won't affect your store.

I hope this helps, for more information on how you can use WooCommerce short-codes to customize your store can be found here.

3
votes

To add to Silver Ringvee's answer - he used is_page but that only works on wordpress pages. For woocommerce you need to use something like is_woocommerce() . See Woocommerce conditional tags page.

My example code uses the is_shop conditional tag as that was the page you wanted to change. the code get_template_part( 'content', 'shop' ); will call the file content-shop.php in your theme root folder. This code is to be added at the top of wp-content\themes\*theme*\woocommerce\archive-product.php that you can copy from wp-content\plugins\woocommerce\templates\archive-product.php

You can add it just before get_header( 'shop' ); line 23 in my file - and the entire page will be drawn from your template. If you want to keep the header of the shop page, then put this code after the get_header code. Remember to include a footer in your file as well

if (is_shop()) {
 get_template_part( 'content', 'shop' );
} else  {  
#normal archive-product code here
}
0
votes

The solution (not perfect) that I figured to work best, until someone finds a way to actually change the template from dashboard:

Adding:

<?php
if (is_page( 'Page Title' ) ):
  # Do your stuff
endif;
?>

to content-product.php in my theme's woocommerce folder.

-2
votes

If you prefer to go with code, you can create a redirect from the original shop page to your page via wp_redirect.

add_action('template_redirect', 'bc_010101_redirect_woo_pages');
function bc_010101_redirect_woo_pages()
{


 if (is_shop())
 {

  wp_redirect('your_shop_url_here');
  exit;
 }
}

More detailed tutorial can be found here

-14
votes

This is not possible to create custom template for shop page , just copy and paste woocommerce Templates into you theme folder and Try to work in content-product.php template .