Skip to content

Commit 343e047

Browse files
committed
Fixed Order Note issue
1 parent 577c8eb commit 343e047

File tree

3 files changed

+73
-83
lines changed

3 files changed

+73
-83
lines changed

README.md

Lines changed: 61 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -70,69 +70,69 @@ $data = [
7070
7171
// For Variable Product
7272
$data = [
73-
'name' => 'Variable Product', // Product Name pr Title
74-
'type' => 'variable', // Product Type simple|variable
75-
'description' => 'Product Description', // Product Long Description
76-
'short_description' => 'Product Summery', // Product Short Description
77-
// Product Categories
78-
'categories' => [
79-
[
80-
'id' => 9,
81-
],
82-
[
83-
'id' => 14,
84-
],
85-
],
86-
// Product images
87-
'images' => [
88-
[
89-
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
90-
],
91-
[
92-
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg',
93-
],
94-
[
95-
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg',
96-
],
97-
[
98-
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg',
99-
],
100-
],
101-
// Product Attributes
102-
'attributes' => [
103-
[
104-
'id' => 6,
105-
'position' => 0,
106-
'visible' => false,
107-
'variation' => true,
108-
'options' => [
109-
'Black',
110-
'Green',
73+
'name' => 'Variable Product', // Product Name pr Title
74+
'type' => 'variable', // Product Type simple|variable
75+
'description' => 'Product Description', // Product Long Description
76+
'short_description' => 'Product Summery', // Product Short Description
77+
// Product Categories
78+
'categories' => [
79+
[
80+
'id' => 9,
81+
],
82+
[
83+
'id' => 14,
84+
],
11185
],
112-
],
113-
[
114-
'name' => 'Size',
115-
'position' => 0,
116-
'visible' => true,
117-
'variation' => true,
118-
'options' => [
119-
'S',
120-
'M',
86+
// Product images
87+
'images' => [
88+
[
89+
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
90+
],
91+
[
92+
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg',
93+
],
94+
[
95+
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg',
96+
],
97+
[
98+
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg',
99+
],
121100
],
122-
],
123-
],
124-
// Set Default attributes
125-
'default_attributes' => [
126-
[
127-
'id' => 6,
128-
'option' => 'Black',
129-
],
130-
[
131-
'name' => 'Size',
132-
'option' => 'S',
133-
],
134-
],
135-
];
101+
// Product Attributes
102+
'attributes' => [
103+
[
104+
'id' => 6,
105+
'position' => 0,
106+
'visible' => false,
107+
'variation' => true,
108+
'options' => [
109+
'Black',
110+
'Green',
111+
],
112+
],
113+
[
114+
'name' => 'Size',
115+
'position' => 0,
116+
'visible' => true,
117+
'variation' => true,
118+
'options' => [
119+
'S',
120+
'M',
121+
],
122+
],
123+
],
124+
// Set Default attributes
125+
'default_attributes' => [
126+
[
127+
'id' => 6,
128+
'option' => 'Black',
129+
],
130+
[
131+
'name' => 'Size',
132+
'option' => 'S',
133+
],
134+
],
135+
];
136136
137137
// Create a product using create() method
138138
$product = Product::create($data);
@@ -370,11 +370,6 @@ $orders = Order::options(['status' => 'processing', 'orderby' => 'id', 'order' =
370370
371371
// You can set options by passing an array when call `all` method
372372
$orders = Order::all(['status' => 'processing', 'orderby' => 'id', 'order' => 'asc']);
373-
374-
// Data with pagination
375-
$products = Product::paginate(25, 1); // first parameter means how much you want to display per_page, second parameter current page. Default value 1
376-
Or
377-
$products = (new Product)->paginate(25, 5); // first parameter means how much data you want to display per_page, second parameter current page
378373
```
379374
#Product Options: https://woocommerce.github.io/woocommerce-rest-api-docs/#products
380375

src/Models/Order.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ class Order extends BaseModel
1515
* Note
1616
*/
1717

18-
public function notes($order_id, $options = [])
18+
protected function notes($order_id, $options = [])
1919
{
2020
return WooCommerce::all("orders/{$order_id}/notes", $options);
2121
}
2222

23-
public function note($order_id, $note_id)
23+
protected function note($order_id, $note_id)
2424
{
25-
return WooCommerce::create("orders/{$order_id}/notes/{$note_id}");
25+
return WooCommerce::find("orders/{$order_id}/notes/{$note_id}");
2626
}
2727

28-
public function createNote($order_id)
28+
protected function createNote($order_id, $data = [])
2929
{
30-
return WooCommerce::create("orders/{$order_id}/notes");
30+
return WooCommerce::create("orders/{$order_id}/notes", $data);
3131
}
3232

33-
public function deleteNote($order_id, $note_id, $options = [])
33+
protected function deleteNote($order_id, $note_id, $options = [])
3434
{
3535
return WooCommerce::delete("orders/{$order_id}/notes/{$note_id}", $options);
3636
}
@@ -39,22 +39,22 @@ public function deleteNote($order_id, $note_id, $options = [])
3939
* Refund
4040
*/
4141

42-
public function refunds($order_id, $options = [])
42+
protected function refunds($order_id, $options = [])
4343
{
4444
return WooCommerce::all("orders/{$order_id}/refunds", $options);
4545
}
4646

47-
public function refund($order_id, $refund_id)
47+
protected function refund($order_id, $refund_id)
4848
{
49-
return WooCommerce::create("orders/{$order_id}/refunds/{$refund_id}");
49+
return WooCommerce::find("orders/{$order_id}/refunds/{$refund_id}");
5050
}
5151

52-
public function createRefund($order_id)
52+
protected function createRefund($order_id, $data = [])
5353
{
54-
return WooCommerce::create("orders/{$order_id}/refunds");
54+
return WooCommerce::create("orders/{$order_id}/refunds", $data);
5555
}
5656

57-
public function deleteRefund($order_id, $refund_id, $options = [])
57+
protected function deleteRefund($order_id, $refund_id, $options = [])
5858
{
5959
return WooCommerce::delete("orders/{$order_id}/refunds/{$refund_id}", $options);
6060
}

src/Traits/QueryBuilderTrait.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,4 @@ public function save()
246246

247247
return $this->results;
248248
}
249-
250-
public function hello()
251-
{
252-
return "Called";
253-
}
254249
}

0 commit comments

Comments
 (0)