Skip to content

Commit

Permalink
Merge pull request #244 from woocommerce/add/46537_duplicate_product_…
Browse files Browse the repository at this point in the history
…endpoint_docs

Add duplicate product docs
  • Loading branch information
octaedro authored Jun 17, 2024
2 parents 13d6196 + b8345d7 commit 561fb51
Showing 1 changed file with 109 additions and 0 deletions.
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

0 comments on commit 561fb51

Please sign in to comment.