xxxxxxxxxx
if( has_term( 4, 'product_cat' ) ) {
// do something if current product in the loop is in product category with ID 4
}
xxxxxxxxxx
function webroom_add_short_description_in_product_categories() {
global $product;
if ( ! $product->get_short_description() ) return;
?>
<div itemprop="description">
<?php echo apply_filters( 'woocommerce_short_description', $product->get_short_description() ) ?>
</div>
<?php
}
add_action('woocommerce_after_shop_loop_item_title', 'webroom_add_short_description_in_product_categories', 5);
xxxxxxxxxx
$categories_html = get_the_term_list($product->ID, 'product_cat', '', ', ');
$categories_text = strip_tags($categories_html);
echo $categories_text;
xxxxxxxxxx
$post_id = wp_insert_post( array(
'post_title' => $title,
'post_type' => 'product',
'post_status' => 'publish',
'post_content' => $body,
));
$product = wc_get_product( $post_id );
$product->set_sku( $sku );
// etc...
$product->save();