我一直在尝试使用此包将我的 WooCommerce 客户与 Laravel 同步,旨在确保产品、订单和客户数据的无缝集成。
作曲家需要自动/woocommerce
在检索产品或订单时,该包可以顺利运行。
这是示例代码。
此代码从 WooCommerce 返回一个空数组。该问题似乎是客户特有的,因为它没有检索任何数据;仅返回一个空数组。
$since_id = 0;
$url = $this->store['store_url'];
$consumer_key = $this->store['consumer_key'];
$consumer_secret= $this->store['consumer_secret'];
$options = [ 'wp_api' => true, 'version' => 'wc/v3' ];
$woocommerce = new Client($url, $consumer_key, $consumer_secret, $options);
$page = 1;
$per_page = 100; // Set a reasonable limit to avoid overloading
$limit = 10000;
$all_customers = [];
do {
$args = [
'per_page' => $per_page,
'page' => $page,
];
$customers = $woocommerce->get('customers', $args);
$all_customers = array_merge($all_customers, $customers);
// Check if there are more orders:
$page++;
} while (count($customers) >= $per_page);
删除了此检查条件
$has_more = isset($orders['headers']['x-wp-totalpages']) && $page < $orders['headers']['x-wp-totalpages'];