Skip to content

Commit 483ce28

Browse files
committed
Added results count functionality to quueryBuilderTrait and fix getRequest() and getResponse() in WooCommerceTrait
1 parent b058769 commit 483ce28

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/Traits/QueryBuilderTrait.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ protected function where(...$parameters)
191191
}
192192

193193
/**
194+
* Set order direction.
195+
*
194196
* @param string $name
195197
* @param string $direction
196198
*
@@ -205,6 +207,8 @@ protected function orderBy($name, $direction = 'desc')
205207
}
206208

207209
/**
210+
* Paginate results.
211+
*
208212
* @param int $per_page
209213
* @param int $current_page
210214
*
@@ -241,6 +245,21 @@ protected function paginate($per_page, $current_page = 1)
241245
}
242246

243247
/**
248+
* Count all results.
249+
*
250+
* @return int
251+
*/
252+
protected function count()
253+
{
254+
$results = WooCommerce::all($this->endpoint, $this->options);
255+
$totalResults = WooCommerce::countResults();
256+
257+
return $totalResults;
258+
}
259+
260+
/**
261+
* Store data.
262+
*
244263
* @return array
245264
*/
246265
public function save()

src/Traits/WooCommerceTrait.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ public function delete($endpoint, $options = [])
9191
*/
9292
public function getRequest()
9393
{
94-
self::__construct();
95-
9694
return $this->client->http->getRequest();
9795
}
9896

@@ -103,8 +101,6 @@ public function getRequest()
103101
*/
104102
public function getResponse()
105103
{
106-
self::__construct();
107-
108104
return $this->client->http->getResponse();
109105
}
110106

0 commit comments

Comments
 (0)