I'm attempting to get a custom attribute in Woocommerce. In this case the custom attribute is called 'Brand'.
The following line of code attempts to get the 'Brand' attribute.
$brand = array_shift( wc_get_product_terms( $_product->id, 'pa_brand', array( 'fields' => 'names' ) ) );
I'm attempting to add each individual 'Brand' item to a for each loop which is picked up later in a drop down menu. I have the following code which attempts to add each instance of the $brand array to the associative $brands array. My question is how can I add these as associative values?
foreach($brand as $brands){
$values = array(
'Label' => 'value'
}
So for example, if the brad Ford existed in the $brand array, I'd like to add 'Ford' with the associative value 'ford' in the for each statement.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire