woocommerce
woocommerce copied to clipboard
Variable product
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?
$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);