Woocommerce product category template - wordpress

I wanted to create a page template that is the same design as the woocommerce (please refer to the image below) product category template and display by category in my custom page template. How will start I am a newbie in woocommerce.
default product category template design

First create the page template in your theme's folder. Kindly check following steps.
1) Add mynewtemplate.php in your theme's folder.
2) Add <?php /* Template Name: My new template*/ ?> in newly created file. refer http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/ for more info.
3) At admin side add new page and choose My new template template.
4) You can add following codes in page editor.
There are list of short-codes are available.
[woocommerce_product_filter] — shows a live Product Search Filter.
[woocommerce_product_filter_attribute] — shows a live Product Attribute Filter.
[woocommerce_product_filter_category] — shows a live Product Category Filter.
[woocommerce_product_filter_price] — shows a live Product Price Filter.
[woocommerce_product_filter_tag] — shows a live Product Tag Filter.
[product_category category="shirt"] - Displayed `shirt` category product
https://docs.woocommerce.com/document/woocommerce-product-search/shortcodes/ check for more info.
5) If you don't want to add this in page content area then add your code in mynewtemplate.php
<?php
do_shortcode( '[woocommerce_product_filter]' ); //— shows a live Product Search Filter.
do_shortcode( '[woocommerce_product_filter_attribute]' ); //— shows a live Product Attribute Filter.
do_shortcode( '[woocommerce_product_filter_category]' ); //— shows a live Product Category Filter.
do_shortcode( '[woocommerce_product_filter_price]' ); //— shows a live Product Price Filter.
do_shortcode( '[woocommerce_product_filter_tag]' ); //— shows a live Product Tag Filter.
do_shortcode( '[product_category category="shirt"]' ); // - Displayed `shirt` category product
?>
Hope this will help you.

Related

Products filtered by specific product attribute value in Woocommerce

I have a problem with woocommerce shortcodes. I have products on backend side but after upgrading woocommerce to latest version (3.3.5) I noticed that shortcodes are not same anymore. I used to query product by attribute with [product_attributes] shortcode. According to woocommerce docs this shortcode is turned on [products] with attributes.
This is my shortcode:
<?php echo do_shortcode('[products attribute="collezione_chakra" terms="stella" limit="-1"]'); ?>
As you can see stella attribute has 3 products and also the taxonomy is correct (I think), as you can see here below.
I've also tried using pa_ as taxonomy prefix as you can see below, but not working
<?php echo do_shortcode('[products attribute="pa_collezione_chakra" terms="stella" limit="-1"]'); ?>
What is going wrong? Thanks in advance.

Add shortcode to woocommerce product short description

I'm trying to add a shortcode that will be placed on all single product posts. Specifically on the product's short description. I went to woocommerce templates and found a file "short-description" and I tried placed following code, but it's not working:
<?php echo do_shortcode("[wpqr-code]"); ?>
This shortcode is to supposed to generate and display a qr code on each product post where it is placed.
I found a solution if anyone needs. Place this code in functions.phpfile:
add_action( 'woocommerce_before_add_to_cart_form', 'enfold_customization_extra_product_content', 15 );
function enfold_customization_extra_product_content() {
echo do_shortcode("[wpqr-code]");
}

woocommerce empty product name field

I'm using WooCommerce 2.3.8 and WordPress 4.2.1. Is there a way to remove the product title from an individual product? I used to be able to just put a blank space and the product title would be blank, but now it doesn't let me, it just keeps putting the original product title back in when I update the product. This is only for one category of products. I would like to have a category page of products that have no titles, just the featured images in a grid.
Thank you!
1. Dirty Solution
Use CSS:
All of your list items for a product on a category have css classes named after the categories' name e.g. product_cat-mycatgegory.
You can find the product's title within an <h3> element.
Therefore the following CSS Code would prevent displaying the product's title on the category page.
.product_cat-mycatgegory h3{
display:none;
}
Note that the product title is be still readable via the browser's inspector.
2. Cleaner Solution
You could edit the content-product.php template. Check if a current category is chosen and decide whether to show the title or not. Please check woocommerce's documentation about template structure and overriding.
Pseudocode
<?php
$cat_obj = $wp_query->get_queried_object();
$category_ID = $cat_obj->term_id;
if(!($category_ID == category_ID_without_titles)) :?>
<h3><?php the_title(); ?></h3>
<?php endif;?>

woo commerce - how to show custom fields on published page

I have set 2 custom fields on the wordpress / woocommerce product page called "imballo" and "sottoimballo" with their values. How do I display these on the published page?
Thanks!
You would have to display the custom fields in the WooCommerce Single Product Page template,
You could do it in two ways,
Add a code in an existing hook of the Product Single page. Check hooks here
Modify the template by overriding it in your WordPress theme. Read here
And in the place where you want to display do the following,
<?php
//Please add your HTML structure as needed.
echo get_post_meta(get_the_ID(), 'imballo');
echo get_post_meta(get_the_ID(), 'sottoimballo');
?>

Products disappearing when adding any category on WooCommerce

Has anyone experienced this before? This is my first time working with WooCommerce.
If I don't add products to a category they will show up in the main shop page as well as have a single product page, as soon as I add a category they will not show up on the main shop page, the category page, or the single product page.
I have not manipulated the wp_query in any way on the page.
I am integrating it into my custom theme which is really barebones, the only thing I have changed is the following in my functions.php file:
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'urbantac_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'urbantac_wrapper_end', 10);
function urbantac_wrapper_start() { echo '<div id="products-content" class="products wrap clearfix aligncenter content-container">'; }
function urbantac_wrapper_end() { echo '</div>'; }
I was using another WooCommerce plugin:
http://www.woothemes.com/products/catalog-visibility-options/ to turn off the "store" functionality of WooCommerce and use it as a "catalog"
This adds two settings on the product category pages, and sets defaults to NOT show anyone the content (no idea why this is). The settings are Role Visibility Rules and Location Visibility Rules. It does not mention this anywhere in the documentation for the plugin!
So if you are using this plugin you can no longer create categories directly from a product page, you must first create the category, set the visibility rules, and then create the product.

Resources