I need help to add custom attribute in woocommerce. I’m designing a single product page by adding code form “single-product” one by one code like product title and price.
<?php the_title(); ?>
<?php echo get_woocommerce_currency(); ?> <?php echo $price = get_post_meta( get_the_ID(), '_regular_price', true); ?>
i also get products images there but i need to get attribute product please help me. My Html Code is
<div class="col-md-6 col-sm-6">
<label class="block" for="product_color">Color</label>
<select class="form-control pointer" name="product_color" id="product_color">
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="cherry">Cherry</option>
</select>
</div>
<!-- /product color -->
<!-- product size -->
<div class="col-md-6 col-sm-6">
<label class="block" for="product_size">Size</label>
<select class="form-control pointer" name="product_size" id="product_size">
<option value="l">L</option>
<option value="m">M</option>
<option value="xxl">XXL</option>
</select>
</div>
so I need attribute according to it.
Based on the information provided here: Woocommerce getting custom attributes
What you’re looking for is
$product->get_attribute( 'your_attr' );