似乎无法让分页在我的 WooCommerce REST API 应用程序上运行?

发布于 2025-01-20 14:13:18 字数 474 浏览 4 评论 0原文

到目前为止我得到了什么:

        [
            'wp_api' => true,
            'version' => 'wc/v3',
            'query_string_auth' => true //Force Basic Authentication as query string true and using under HTTPS
            
        ]
    );
        

try {
    $results = $woocommerce->get('orders?per_page=30');
    $result = count($results);

我尝试删除 query_string_auth 但没有显示任何数据。 仅供参考,它可以在 page=30 的情况下工作,但只显示前 10 项。

任何建议都会有很大帮助:

What I got so far:

        [
            'wp_api' => true,
            'version' => 'wc/v3',
            'query_string_auth' => true //Force Basic Authentication as query string true and using under HTTPS
            
        ]
    );
        

try {
    $results = $woocommerce->get('orders?per_page=30');
    $result = count($results);

I tried to remove the query_string_auth but I dont get any data displayed.
FYI it works without the page=30 but then only displayed the first 10 items.

Any advice would help alot:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画骨成沙 2025-01-27 14:13:18

获取方法接受额外的参数。

$woocommerce->get($endpoint, $parameters = []);

尝试这样的

$woocommerce->get('orders', array('per_page' => 30));

更多详细信息可以看到在这里

Get method accepts extra parameters.

$woocommerce->get($endpoint, $parameters = []);

Try like this

$woocommerce->get('orders', array('per_page' => 30));

More details can be seen here

慢慢从新开始 2025-01-27 14:13:18

如果您使用 Nginx,请检查您的 Nginx 配置。缺少 Nginx 设置将忽略 GET 方法查询参数。因此,问题可能在于您的 page 或 per_page 参数被忽略。

If you are using Nginx, check your Nginx configurations. Missing Nginx settings will ignore the GET method query parameters. So it might be the issue that your page or per_page parameter are simply being ignored.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文