I'm trying to make a schema with variation product to output for every variation, price, availability, SKU and itemcondition.
File is place at theme-child/woocommerce/single-product/price.php Is this the right call to make?
Assuming the get_child
output is an array?
Thank you!
<?php
if ($product->is_type('variable'))
{
// do stuff for everything else
$ids = $product->get_children();
foreach ($ids as $value)
{
$product = wc_get_product($value);
?>
<p class="price"><?php echo $product->get_price_html(); ?></p>
<meta itemprop="price" content="<?php echo $product->get_price(); ?>" />
<meta itemprop="priceCurrency" content="<?php echo get_woocommerce_currency(); ?>" />
<link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />
<meta itemprop="sku" content="<?php echo $product->get_sku(); ?>" />
<meta itemprop="itemCondition" content="http://schema.org/NewCondition" /><?php
}
}
?>
global $product; if ($product->is_type('variable')){ $ids = $product->get_children(); $prodID = $ids[0]; $producT = wc_get_product($prodID); } ?> get_price_html(); ?> is_type('variable')){ echo $producT->get_price(); } else { echo $product->get_price(); } ?>" /> " /> is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />