Wocommerce Diferent template for only one product - woocommerce

I have a simply question :
Can i use different template for just one product leaving default template untouched ?
My case : I have little shop with 4 products but , i want to modify template just for first product .
Thanks a lot .

Yes, it is totally possible. You can override the single-product.php template from Woocommerce by copying the template in (your-child-theme-root/woocommerce/single-product.php). Then you set a condition using the product id and load the template you created for that specific product. PD: Sorry if my English is not 100%.

Related

Single product page with dynamic content according to product category

I need to update our product template with a new one. In this template, I have two sections whose contents will depend on the product category. My plan is to create different "Elementor Section Templates" for each category and then connect these templates to the product category and somehow display these sections on the single product page. I have created a child theme and can edit the theme's product template and put the demo sections to the page. However, there is a need for logic that I could not figure out. So in this context, my questions are the following:
How can I connect these "section templates" to "woocommerce categories/products"?
How can I use Elementor Pro's editor to create this dynamic logic?
How can I get $product php object when I use the elementor template builder? Is there a way to import this template into another php file to serve as single product template?
Is there an easier/more efficient way to create the templates and connect them to products/categories?
ps: I have elementor pro.
I created the template and import it to singelproduct.php file of the child theme. I can display the template however, the "category" object that I get from $product object is an array of different categories hence no clear way to use this data in an if/else statement.

How to reset a problem in a category on my e-commerce site?

as you can see on my website www.bmhotellerie.it in the Take away category the products are displayed badly, I would like some advice on how to restore
I don't think it is category related. Here is the same issue on the same product, on the shop page :
https://www.bmhotellerie.it/shop/page/3/
It seems you have an unclosed tag somewhere on your product template.
As you can see, your .item-col element is inside another .item-col element.
Usually, it's the template templates/content-product.php that display products within loops :
https://github.com/woocommerce/woocommerce/blob/5.6.0/templates/content-product.php
My first guess will be to look at this template if your theme contains it. If not, maybe there is a hook or another template that create this issue...?

WordPress create category for pages only

I need to assign category for pages,i have tried many of the results found in google search . But while adding a category for Pages it automatically reflects in Posts also. Also tried few plugins (https://wordpress.org/plugins/create-and-assign-categories-for-pages/) . Is there an option for adding categories for pages alone ?
You can create a custom module instead ? with page capabilities and put supports "page_attributes"
What is the purpose to divide the pages? If you want to relate a group of pages create a parent page and use that! it can be used like a category.

My new template file in WooCommerce doesn't work for products with tags

I am new with WooCommerce, and I don't know how to solve this issue. I have product with categories and tag.
In my home page I show two lists, product by tags and product by categories.
When I click in my first list I have to show something like this:
(return a list of this tag order by category)
Tag1
Category 1 (2) number of products
Category 2 (4)
Category 3 (1)
and when I click in Category 1, I show a product like product-tag.php file
For do this I override woocommerce plugin and add this in product-tag.php:
if (is_product_category()) :
include("product-category.php");
else:
if (is_product_tag()) :
include("listTag-product.php");
endif;
endif;
listTag-product.php is a new file that I created, but don't work, by default call to product-tag.php.
How to change this?
I want to use product_tag.php when I click in the list "Category 1 (2)" to show the product.
The problem is that a product tag can also be a product category or the opposite…
For that reason when using if (is_product_category()) the condition is always true and listTag-product.php will never be included…
Looking at WooCommerce templates, I don't see any:
product_tag.php template
product-category.php template…
The related existing WooCommerce templates are:
content-product_cat.php
taxonomy-product_cat
taxonomy-product_tag.php
After all why split this in 2 templates? You don't need that. You will better use the same template with fine tuned conditions inside it. But using conditionals as is_product_category() and is_product_tag() together is not the solution…
Depending on your thoughts, you could better use categories and subcategories instead of categories and tags.
If you want some real help, it will be better to reconsidering all, changing your approach and beginning to explore other ways. Here in Stackoverflow you will need to make a new question with more details and making available the code used in your templates or scripts, explaining with clarity, what is working and what not… For each problem one question at the time.
References:
Managing Product Categories, Tags and Attributes
Display WooCommerce Categories, Subcategories, and Products in Separate Lists

Custom Wordpress Template For Category

I have two categories that need a special template. Each has one post and will display differently. So I read that if the category is named, for example, 'testing' and the template name is 'testing.php' then it should use that correct?
Why would it not? I keep previewing the post and it just redirects to the home page.
Naming the template testing.php won't work. You need to use either a slug or ID of your category, so either category-testing.php or category-ID.php if you know the ID of category (ie. you're not making a theme for release and your IDs are constant).
Category templates, which your version of WordPress has, can do it.
What version of WordPress are you running. WordPress 3.0 is new and will support what you want out of the box as you described.

Resources