woocommerce icon indicating copy to clipboard operation
woocommerce copied to clipboard

Able to Create New Contents

Open karamusluk opened this issue 5 years ago • 3 comments

Is it possible to create new contents (Post, Products, Upload Images) with this extension of corcel?

karamusluk avatar Dec 05 '19 08:12 karamusluk

It is possible even without this package, but it's not easy thing. You need to know product meta keys and you can create it in this way:

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

I will think about making this process at least a bit easier.

Dartui avatar Oct 03 '20 14:10 Dartui

is it possible to create order with the same method?

xuark avatar Jul 07 '21 09:07 xuark

is it possible to create order with the same method?

Came here for the same reason, even though technically it's possible cause order is just a custom post type but order items are stored in a different table, and there are several other tables for the orders so if not already built in, which is not. It's not as easy as just create the order and update the metas.

You should change all the other tables (first have to know how all that works)

For these I usually use a webhook from php (laravel, lumeon,... pointing to a wp rest custom endpoint) and let the job be done on side of WordPress.

That way everything would work even if you use wpml which I do.

Stevemoretz avatar Aug 04 '21 09:08 Stevemoretz