如何为WC WP制作此自定义功能



我正在尝试为WooCommerce创建一个自定义函数,该函数将数组作为参数并打印一些产品。该数组将包含WooCommerce产品标签。

<form id="form3" method="POST" action="">
<h4>Concerns</h4>
<div class="container-form">
<input type="checkbox" name="concern1" checked="checked"
<?php if (isset($concern1) && $concern1=="dryness") echo "checked";?>
value="dryness"><div class="checkmark">Dryness</div>

</div>
<div class="container-form">
<input type="checkbox" name="concern2"
<?php if (isset($concern2) && $concern2=="dullness") echo "checked";?>
value="male"><div class="checkmark">Male</div>
<br>
</div>
<div class="container-form">
<input type="checkbox" name="concern3"
<?php if (isset($concern3) && $concern3=="other") echo "checked";?>
value="other"><div class="checkmark">Other</div>
<br>
</div>
<input type="submit" name="submit" class="submit" value="Submit"/>
<?php
function pre_r($array){
echo '<pre>';
print_r($array);
echo '</pre>';
}
?>

如何制作函数,将数组作为参数,并根据这些标记显示产品?

// Get products with the "Excellent" or "Modern" tags.
$args = array(
'tag' => array( 'excellent', 'modern' ),
);
$products = wc_get_products( $args );

接受数组:将结果限制为由段塞分配给特定标签的产品

更多详细信息可在WooCommerce官方文档中找到

最新更新