Skip to content

Commit 3d00f8d

Browse files
committed
Add duplicate product docs
1 parent 13d6196 commit 3d00f8d

File tree

2 files changed

+218
-0
lines changed

2 files changed

+218
-0
lines changed

Diff for: source/includes/v3/_products.md

+109
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,115 @@ woocommerce.get("products").parsed_response
16291629
<code>tag</code>, <code>shipping_class</code> and <code>pa_*</code> filters are available starting from WooCommerce 2.5.
16301630
</aside>
16311631

1632+
## Duplicate product ##
1633+
1634+
This API helps you to duplicate a product.
1635+
1636+
### HTTP request ###
1637+
1638+
<div class="api-endpoint">
1639+
<div class="endpoint-data">
1640+
<i class="label label-post">POST</i>
1641+
<h6>/wp-json/wc/v3/products/<product_id>/duplicate</h6>
1642+
</div>
1643+
</div>
1644+
1645+
```shell
1646+
curl https://example.com/wp-json/wc/v3/products/<product_id>/duplicate \
1647+
-u consumer_key:consumer_secret
1648+
```
1649+
1650+
```javascript
1651+
WooCommerce.post("products/2/duplicate")
1652+
.then((response) => {
1653+
console.log(response.data);
1654+
})
1655+
.catch((error) => {
1656+
console.log(error.response.data);
1657+
});
1658+
```
1659+
1660+
```php
1661+
<?php print_r($woocommerce->post('products/2/duplicate')); ?>
1662+
```
1663+
1664+
```python
1665+
print(wcapi.post("products/2/duplicate").json())
1666+
```
1667+
1668+
```ruby
1669+
woocommerce.post("products/2/duplicate").parsed_response
1670+
```
1671+
1672+
> JSON response example:
1673+
1674+
```json
1675+
{
1676+
"id": 824,
1677+
"name": "Premium Quality (Copy)",
1678+
"slug": "",
1679+
"date_created": {
1680+
"date": "2024-05-30 19:16:39.000000",
1681+
"timezone_type": 1,
1682+
"timezone": "+00:00"
1683+
},
1684+
"date_modified": {
1685+
"date": "2024-03-08 15:03:19.000000",
1686+
"timezone_type": 1,
1687+
"timezone": "+00:00"
1688+
},
1689+
"status": "draft",
1690+
"featured": false,
1691+
"catalog_visibility": "visible",
1692+
"description": "",
1693+
"short_description": "",
1694+
"sku": "product-22-1",
1695+
"price": "",
1696+
"regular_price": "",
1697+
"sale_price": "",
1698+
"date_on_sale_from": null,
1699+
"date_on_sale_to": null,
1700+
"total_sales": 0,
1701+
"tax_status": "taxable",
1702+
"tax_class": "",
1703+
"manage_stock": false,
1704+
"stock_quantity": null,
1705+
"stock_status": "instock",
1706+
"backorders": "no",
1707+
"low_stock_amount": "",
1708+
"sold_individually": false,
1709+
"weight": "",
1710+
"length": "",
1711+
"width": "",
1712+
"height": "",
1713+
"upsell_ids": [],
1714+
"cross_sell_ids": [],
1715+
"parent_id": 0,
1716+
"reviews_allowed": true,
1717+
"purchase_note": "",
1718+
"attributes": [],
1719+
"default_attributes": [],
1720+
"menu_order": 0,
1721+
"post_password": "",
1722+
"virtual": false,
1723+
"downloadable": false,
1724+
"category_ids": [
1725+
15
1726+
],
1727+
"tag_ids": [],
1728+
"shipping_class_id": 0,
1729+
"downloads": [],
1730+
"image_id": "",
1731+
"gallery_image_ids": [],
1732+
"download_limit": -1,
1733+
"download_expiry": -1,
1734+
"rating_counts": [],
1735+
"average_rating": "0",
1736+
"review_count": 0,
1737+
"meta_data": []
1738+
}
1739+
```
1740+
16321741
## Update a Product ##
16331742

16341743
This API lets you make changes to a product.

Diff for: source/includes/wp-api-v3/_products.md

+109
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,115 @@ woocommerce.get("products").parsed_response
14951495
| `max_price` | string | Limit result set to products based on a maximum price. |
14961496
| `stock_status` | string | Limit result set to products with specified stock status. Options: `instock`, `outofstock` and `onbackorder`. |
14971497

1498+
## Duplicate product ##
1499+
1500+
This API helps you to duplicate a product.
1501+
1502+
### HTTP request ###
1503+
1504+
<div class="api-endpoint">
1505+
<div class="endpoint-data">
1506+
<i class="label label-post">POST</i>
1507+
<h6>/wp-json/wc/v3/products/<product_id>/duplicate</h6>
1508+
</div>
1509+
</div>
1510+
1511+
```shell
1512+
curl https://example.com/wp-json/wc/v3/products/<product_id>/duplicate \
1513+
-u consumer_key:consumer_secret
1514+
```
1515+
1516+
```javascript
1517+
WooCommerce.post("products/2/duplicate")
1518+
.then((response) => {
1519+
console.log(response.data);
1520+
})
1521+
.catch((error) => {
1522+
console.log(error.response.data);
1523+
});
1524+
```
1525+
1526+
```php
1527+
<?php print_r($woocommerce->post('products/2/duplicate')); ?>
1528+
```
1529+
1530+
```python
1531+
print(wcapi.post("products/2/duplicate").json())
1532+
```
1533+
1534+
```ruby
1535+
woocommerce.post("products/2/duplicate").parsed_response
1536+
```
1537+
1538+
> JSON response example:
1539+
1540+
```json
1541+
{
1542+
"id": 824,
1543+
"name": "Premium Quality (Copy)",
1544+
"slug": "",
1545+
"date_created": {
1546+
"date": "2024-05-30 19:16:39.000000",
1547+
"timezone_type": 1,
1548+
"timezone": "+00:00"
1549+
},
1550+
"date_modified": {
1551+
"date": "2024-03-08 15:03:19.000000",
1552+
"timezone_type": 1,
1553+
"timezone": "+00:00"
1554+
},
1555+
"status": "draft",
1556+
"featured": false,
1557+
"catalog_visibility": "visible",
1558+
"description": "",
1559+
"short_description": "",
1560+
"sku": "product-22-1",
1561+
"price": "",
1562+
"regular_price": "",
1563+
"sale_price": "",
1564+
"date_on_sale_from": null,
1565+
"date_on_sale_to": null,
1566+
"total_sales": 0,
1567+
"tax_status": "taxable",
1568+
"tax_class": "",
1569+
"manage_stock": false,
1570+
"stock_quantity": null,
1571+
"stock_status": "instock",
1572+
"backorders": "no",
1573+
"low_stock_amount": "",
1574+
"sold_individually": false,
1575+
"weight": "",
1576+
"length": "",
1577+
"width": "",
1578+
"height": "",
1579+
"upsell_ids": [],
1580+
"cross_sell_ids": [],
1581+
"parent_id": 0,
1582+
"reviews_allowed": true,
1583+
"purchase_note": "",
1584+
"attributes": [],
1585+
"default_attributes": [],
1586+
"menu_order": 0,
1587+
"post_password": "",
1588+
"virtual": false,
1589+
"downloadable": false,
1590+
"category_ids": [
1591+
15
1592+
],
1593+
"tag_ids": [],
1594+
"shipping_class_id": 0,
1595+
"downloads": [],
1596+
"image_id": "",
1597+
"gallery_image_ids": [],
1598+
"download_limit": -1,
1599+
"download_expiry": -1,
1600+
"rating_counts": [],
1601+
"average_rating": "0",
1602+
"review_count": 0,
1603+
"meta_data": []
1604+
}
1605+
```
1606+
14981607
## Update a product ##
14991608

15001609
This API lets you make changes to a product.

0 commit comments

Comments
 (0)