woocommerce icon indicating copy to clipboard operation
woocommerce copied to clipboard

Variable product

Open fillobotto opened this issue 2 years ago • 1 comments

I wasn't able to create a Product with type variable (like you do with REST API) and its corresponding product variations based on one or more Attributes/Taxonomies. Is there an example for that?

fillobotto avatar Nov 12 '22 17:11 fillobotto

$term_slug = 'variable';

$taxonomy = ProductType::whereHas('term', function($q) use ($term_slug) {
   $q->where('slug', $term_slug);
})->first();

$youProductModel->productTypes()->syncWithoutDetaching($taxonomy->term_taxonomy_id);

alagaccia avatar Feb 21 '23 09:02 alagaccia