In Woocommerce 2.2.10 I have a product variation:
$variation = new WC_Product_Variation($variation_id);
and I want to get the attributes:
$attributes = $variation->get_variation_attributes();
returns
$attributes = array (
'attribute_color' => "mint-green",
'attribute_size' => "small"
)
But on the front-end in Woocommerce admin the attribute text as displayed in the color and size options is "Mint Green" and "Small", as opposed to the option values ("mint-green", "small"), which are returned by get_variation_attributes():
i.e.
<select name="attribute_color[0]">
<option value="">Any Color...</option>
<option selected="selected" value="mint-green">mint green</option>
</select>
<select name="attribute_size[0]">
<option value="">Any Size...</option>
<option selected="selected" value="small">Small</option>
</select>
Can I get product attributes in their original formatting?
Aucun commentaire:
Enregistrer un commentaire