I have a products with the following size parameters:
- Length (Woocomerce standard)
- Width (Woocomerce standard)
- Height (Woocomerce standard)
- Diameter
- Thickness
- Circuit
In the product edit page I have only Length, Width, Height (Woocomerce standard)
I would like to add my other sizes parameters
How can I add this extra sizes properly?
Is there any filter for this?
There is multiple ways…
1) Using Product attributes: (without any coding need):
Advantage: Those other dimention attributes will be displayed on product pages.
Disadvantages:
WC_Product
methods to get those custom product attributes like the default dimension ones. So is going to be more complicated to get them outside the product page.2) Using custom setting fields:
This code goes on function.php file of your active child theme (or theme).
You will get that for products:
And that for product variations (in variable products "variations settings):
Now to display and get those values, you will have to override the woocommerce template via your theme as explained in this documentation.
The file to copy and override via your theme is:
single-product/product-attributes.php
template.You will have to add some code to it to display your custom additional dimension labels and values just after the displayed default dimentions.
To output the correct values you will use
get_post_meta()
function.For example to display the
diameter
value you will use:You can use custom_fields or product attributes for this.