Skip to content

Commit 0a9eb0c

Browse files
Added some php examples
1 parent 77f8358 commit 0a9eb0c

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

source/includes/v2/_coupons.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,35 @@ data = {
126126
print(wcapi.post("coupons", data).text)
127127
```
128128

129+
```php
130+
<?php
131+
$data = array(
132+
'coupon' => array(
133+
'code' => 'new-coupon3',
134+
'type' => 'percent',
135+
'amount' => '10',
136+
'individual_use' => true,
137+
'product_ids' => array(),
138+
'exclude_product_ids' => array(),
139+
'usage_limit' => '',
140+
'usage_limit_per_user' => '',
141+
'limit_usage_to_x_items' => '',
142+
'expiry_date' => '',
143+
'enable_free_shipping' => false,
144+
'product_category_ids' => array(),
145+
'exclude_product_category_ids' => array(),
146+
'exclude_sale_items' => true,
147+
'minimum_amount' => '100.00',
148+
'maximum_amount' => '0.00',
149+
'customer_emails' => array(),
150+
'description' => ''
151+
)
152+
);
153+
154+
print_r($woocommerce->coupons->create($data));
155+
?>
156+
```
157+
129158
> Response:
130159
131160
```json
@@ -192,6 +221,10 @@ WooCommerce.get('coupons/529', function(err, data, res) {
192221
print(wcapi.get("coupons/529").text)
193222
```
194223

224+
```php
225+
<?php print_r($woocommerce->coupons->get(529)); ?>
226+
```
227+
195228
> Response:
196229
197230
```json
@@ -251,6 +284,10 @@ WooCommerce.get('coupons', function(err, data, res) {
251284
print(wcapi.get("coupons").text)
252285
```
253286

287+
```php
288+
<?php print_r($woocommerce->coupons->get()); ?>
289+
```
290+
254291
> Response:
255292
256293
```json
@@ -378,6 +415,18 @@ data = {
378415
print(wcapi.put("coupons/529", data).text)
379416
```
380417

418+
```php
419+
<?php
420+
$data = array(
421+
'coupon' => array(
422+
'amount' => '5'
423+
)
424+
);
425+
426+
print_r($woocommerce->coupons->update(529, $data));
427+
?>
428+
```
429+
381430
> Response:
382431
383432
```json
@@ -434,7 +483,11 @@ WooCommerce.delete('coupons/529/?force=true', function(err, data, res) {
434483
```
435484

436485
```python
437-
print(wcapi.delete("coupons/529").text)
486+
print(wcapi.delete("coupons/529?force=true").text)
487+
```
488+
489+
```php
490+
<?php print_r($woocommerce->coupons->delete(529, true)); ?>
438491
```
439492

440493
> Response:
@@ -479,6 +532,10 @@ WooCommerce.get('coupons/count', function(err, data, res) {
479532
print(wcapi.get("coupons/count").text)
480533
```
481534

535+
```php
536+
<?php print_r($woocommerce->coupons->get_count()); ?>
537+
```
538+
482539
> Response:
483540
484541
```json

source/includes/v2/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ WooCommerce.get('', function(err, data, res) {
7070
print(wcapi.get("").text)
7171
```
7272

73+
```php
74+
<?php print_r($woocommerce->index->get()); ?>
75+
```
76+
7377
> Response:
7478
7579
```json

source/includes/v2/_introduction.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ See the webhook resource section.
402402

403403
- [Node.js](https://www.npmjs.com/package/woocommerce-api)
404404
- [Python](https://pypi.python.org/pypi/WooCommerce)
405-
405+
- [PHP](https://packagist.org/packages/woothemes/woocommerce-api)
406406

407407
```javascript
408408
// Install:
@@ -434,10 +434,24 @@ wcapi = API(
434434
)
435435
```
436436

437+
```php
438+
<?php
439+
// Install:
440+
// composer require "woothemes/woocommerce-api:2.*"
441+
442+
// Setup:
443+
include_once('vendor/autoload.php');
444+
445+
$woocommerce = new WC_API_Client(
446+
'http://example.com/',
447+
'consumer_key',
448+
'consumer_secret'
449+
);
450+
?>
451+
```
452+
437453
## Tools ##
438454

439-
* [WooCommerce REST API Client Library](https://github.com/kloon/WooCommerce-REST-API-Client-Library) - A simple PHP client library by Gerhard Potgieter.
440-
* [WooCommerce API Client](https://github.com/mac2000/woo-commerce-api-client) - Guzzle wrapper around WooCommerce v2 API plus missign api helpers.
441455
* [CocoaRestClient](http://mmattozzi.github.io/cocoa-rest-client/) - A free, easy to use Mac OS X GUI client for interacting with the API, most useful when your test store has SSL enabled.
442456
* [Paw HTTP Client](https://itunes.apple.com/us/app/paw-http-client/id584653203?mt=12) - Another excellent HTTP client for Mac OS X.
443457
* [RESTClient, a debugger for RESTful web services](https://addons.mozilla.org/en-US/firefox/addon/restclient/) - Free Firefox add-on.

source/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ language_tabs:
55
- shell: cURL
66
- javascript: Node.js
77
- python: Python
8+
- php: PHP
89

910
toc_footers:
1011
- <a href="https://github.com/woothemes/woocommerce-rest-api-docs">Contributing to WC REST API Docs</a>

0 commit comments

Comments
 (0)