Skip to content

Commit

Permalink
Merged in APITOCART-14258 (pull request #31)
Browse files Browse the repository at this point in the history
fix check new orders

Approved-by: Mykola Zaburko
Approved-by: Serhii Oioiko
  • Loading branch information
abidlovskyi authored and Taras Kubiv committed May 18, 2022
2 parents 7bab75f + 0f22715 commit 26fa7d6
Show file tree
Hide file tree
Showing 4 changed files with 529 additions and 453 deletions.
17 changes: 12 additions & 5 deletions src/app/Http/Controllers/OrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Requests\OrderRequest;
use App\Services\Api2Cart;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

Expand All @@ -26,7 +27,7 @@ public function index()
public function orderList($store_id=null,Request $request)
{
\Debugbar::disable();

// Log::debug($request->all());

/**
* get account carts & extract exact store info
Expand All @@ -36,17 +37,23 @@ public function orderList($store_id=null,Request $request)

$sort_by = ($request->get('sort_by')) ? $request->get('sort_by') : null;
$sort_direct = ($request->get('sort_direct')) ? true : false;
$created_from = ($request->get('created_from')) ? $request->get('created_from') : null;
$created_from = ($request->get('created_from')) ? Carbon::parse($request->get('created_from'))->format("Y-m-d\TH:i:sO") : null;
$limit = ($request->get('limit')) ? $request->get('limit') : null;

$totalOrders = $this->api2cart->getOrderCount( $store_id );

$orders = collect([]);


//Log::debug( $created_from );
if ( $totalOrders ){

$result = $this->api2cart->getOrderList( $store_id, null, null, null, $created_from );
$result = $this->api2cart->getOrderList(
$store_id,
null,
null,
null,
$created_from,
);

$newOrders = (isset($result['result']['orders_count'])) ? collect( $result['result']['order'] ) : collect([]);
// put additional information
Expand Down Expand Up @@ -81,7 +88,7 @@ public function orderList($store_id=null,Request $request)

// $result = $this->api2cart->getOrderList( $store_id , 'create_at.value', null,$limit);
// Log::debug('raw api result');
// Log::debug( print_r($result,1) );
// if ( $store_id == '4730d110180d4b67449f00b44608cb9d' ) Log::debug( print_r($result,1) );

if ( $sort_by ){
switch ($sort_by){
Expand Down
4 changes: 3 additions & 1 deletion src/app/Services/Api2Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\CurlHandler;


use App\Models\User;
use App\Models\Log as Logger;

Expand Down Expand Up @@ -669,6 +668,9 @@ public function getOrderList( $store_id=null , $sort_by=null, $sort_direct=null,
null
);


//if ( $store_id == '4730d110180d4b67449f00b44608cb9d' ) Log::debug(print_r($result,1));

$this->logApiCall( 'order.list.json', $result->getReturnCode(), $this->order->getConfig(), null, null, null, $result->getReturnMessage(), [ 'sort_by' => $sort_by, 'sort_direct' => $sort_direct, 'limit' => $limit, 'created_from' => $created_from] );

if ( $result->getReturnCode() == 0 ){
Expand Down
Loading

0 comments on commit 26fa7d6

Please sign in to comment.