corcel / corcel/woocommerce

Creating a Product Category

Open
#21 6 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
PHP
Stars
110
Forks
32
PR merge metrics
No merged PRs in 30d

Description

Hello,

I am trying to create a product with a product category and thumbnail (not worked on this yet).

I am hoping you can help. How would you recommend doing this please?

```
$product = Product::create([
'post_title' => 'Product name',
'post_content' => 'Post description',
'post_status' => 'publish',
'post_type' => 'product'
]
);
$product->createMeta([
'_sku' => $row['skucode'],
'_regular_price' => '10.00',
'_sale_price' => '5.00',
'_thumbnail_id' => 10
// other wp_postmeta product meta values...
]);

$category = ProductCategory::create([
'cat_name' => 'Test'
]);

$product->categories()->save($category);
```

How can I create a product and attach a category to it, please?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.