Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add duplicate product docs #244

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions source/includes/wp-api-v3/_products.md
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,115 @@ woocommerce.get("products").parsed_response
| `max_price` | string | Limit result set to products based on a maximum price. |
| `stock_status` | string | Limit result set to products with specified stock status. Options: `instock`, `outofstock` and `onbackorder`. |

## Duplicate product ##

This API helps you to duplicate a product.

### HTTP request ###

<div class="api-endpoint">
<div class="endpoint-data">
<i class="label label-post">POST</i>
<h6>/wp-json/wc/v3/products/&lt;product_id&gt;/duplicate</h6>
</div>
</div>

```shell
curl https://example.com/wp-json/wc/v3/products/<product_id>/duplicate \
-u consumer_key:consumer_secret
```

```javascript
WooCommerce.post("products/2/duplicate")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
```

```php
<?php print_r($woocommerce->post('products/2/duplicate')); ?>
```

```python
print(wcapi.post("products/2/duplicate").json())
```

```ruby
woocommerce.post("products/2/duplicate").parsed_response
```

> JSON response example:

```json
{
"id": 824,
"name": "Premium Quality (Copy)",
"slug": "",
"date_created": {
"date": "2024-05-30 19:16:39.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"date_modified": {
"date": "2024-03-08 15:03:19.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"status": "draft",
"featured": false,
"catalog_visibility": "visible",
"description": "",
"short_description": "",
"sku": "product-22-1",
"price": "",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_to": null,
"total_sales": 0,
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders": "no",
"low_stock_amount": "",
"sold_individually": false,
"weight": "",
"length": "",
"width": "",
"height": "",
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"reviews_allowed": true,
"purchase_note": "",
"attributes": [],
"default_attributes": [],
"menu_order": 0,
"post_password": "",
"virtual": false,
"downloadable": false,
"category_ids": [
15
],
"tag_ids": [],
"shipping_class_id": 0,
"downloads": [],
"image_id": "",
"gallery_image_ids": [],
"download_limit": -1,
"download_expiry": -1,
"rating_counts": [],
"average_rating": "0",
"review_count": 0,
"meta_data": []
}
```

## Update a product ##

This API lets you make changes to a product.
Expand Down