Product attributes
Enable meta fields in product attributes
To enable meta fields for a specific WooCommerce product attribute, add a Taxonomy rule in the group’s field location settings.
Retrieve meta field values
Because WooCommerce doesn't use a dedicated MySQL table for product attribute metadata, the values are stored in the standard wc_options table.
Each meta field follows this key format:
wc_attribute_{boxname}_{fieldname}_{product-attribute_id}Example: wc_attribute_metabox_textfield_3.
There are several ways to retrieve these values using ACPT:
Shortcode
Use the following shortcode:
[acpt_wc_pa pa="1" box="boxname" field="fieldname"]ACPT functions
You can use all standard ACPT functions.
Simply replace post_id with wc_product_attribute.
Example:
get_acpt_field([
'wc_product_attribute' => 3,
'box_name' => 'boxname',
'field_name' => 'fieldname'
]);Legacy WordPress functions
If you prefer, you can access the raw value using the standard get_option() function:
Last updated