我正在尝试从 Shopify 的特定日期范围内获取所有订单。问题是我只能得到 250 个订单。我正在使用以下代码。
<div id="main-content1">
<div class="container-fluid">
<?php
function nextorders($lastorderno,$orderfm,$orderto,$orders) {
$orders_obj_url = 'XXXXXXXXXXXXXXXXXXX.myshopify.com/admin/api/2019-10/orders.json&since_id='.$lastorderno.'&status=any&created_at_min='.$orderfm.'T00:00:00&created_at_max='.$orderto.'T23:59:59&fields=created_at,id,order_status_url,total_price_set,number,note,note_attributes';
$orders_content = @file_get_contents( $orders_obj_url );
$orders_json = json_decode( $orders_content, true );
$orders_new = $orders_json['orders'];
$orders = $orders_json['orders'];
if ($remaningprder > 0) {
$lastorderno = $orders['0']["number"];
nextorders($lastorderno,$orderfm,$orderto,$orders_new);
}
return $orders_new;
}
if ($_POST) {
$orderfm = date("Y-m-d", strtotime($_POST['start']));
$orderto = date("Y-m-d", strtotime($_POST['end']));
$orders_obj_url = 'XXXXXXXXXXXXXXXXXXX.myshopify.com/admin/api/2019-10/orders.json?limit=250&fields=created_at,id,order_status_url,total_price_set,number,note,note_attributes&status=any&created_at_min='.$orderfm.'T00:00:00&created_at_max='.$orderto.'T23:59:59';
$orders_content = @file_get_contents( $orders_obj_url );
$orders_json = json_decode( $orders_content, true );
$orders = $orders_json['orders'];
if (count($orders) > 249) {
$remaningprder = $total_order - count($orders);
$lastorderno = $orders['0']["number"];
$orders = nextorders($lastorderno,$orderfm,$orderto,$orders);
}
}
?>
<div class="row clearfix" style="margin-top:20px;margin-bottom:20px;">
<div class="offset-lg-3 offset-md-3 col-lg-6 col-md-6">
</div>
<div class="offset-lg-3 offset-md-3 col-lg-6 col-md-6">
<div>
<form method="POST" action="">
<label>Date Range</label>
<div class="input-daterange input-group" data-provide="datepicker">
<input type="text" class="input-sm form-control" value="<?=$startset;?>" name="start" autocomplete="off">
<span class="input-group-addon range-to">to</span>
<input type="text" class="input-sm form-control" value="<?=$endset; ?>" name="end" autocomplete="off">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="submit">Search</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-lg-12">
<div class="card">
<div class="header">
<h2>Last order</h2>
<ul class="header-dropdown dropdown">
<li><a href="javascript:void(0);" class="full-screen"><i class="icon-frame"></i></a></li>
</ul>
</div>
<div class="body">
<div class="table-responsive hide-table">
<?php if (count($orders) > 0) { ?>
<table class="table table-striped table-hover dataTable js-exportable">
<thead>
<tr>
<th>#</th>
<th>Order No</th>
<th>Amount</th>
<th>Token</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
foreach ($orders as $order) {
?>
<tr>
<th scope="row" data-title="Date"><?=$i++;?></th>
<td data-title="Order No"><a href="<?=$order["order_status_url"];?>" target="_blank"><?=$order["number"];?></a></td>
<td data-title="Amount"><?=$order["total_price_set"]["shop_money"]["amount"];?></td>
<td data-title="Token"></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
然后使用 $orders 变量创建输出表。即使我增加订单限制,它也只是播下250个订单。
谁能帮我这个
谢谢