You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Wix Velo的listCurrentMemberOrders添加ACTIVE状态过滤?

筛选当前会员的ACTIVE状态订单解决方案

根据Wix Pricing Plans API的listCurrentMemberOrders方法,你可以通过传入filter参数来仅获取状态为ACTIVE的订单,无需返回所有状态的订单。

修正后的代码实现

export function button_click(event) {
    const urlId = getUrlId();

    if (wixUsers.currentUser.loggedIn) {
        // 仅获取ACTIVE状态的订单
        orders.listCurrentMemberOrders({
            filter: {
                status: "ACTIVE" // 筛选条件:订单状态为ACTIVE
            }
        })
        .then((activeOrdersList) => {
            if (activeOrdersList.length > 0) {
                // 会员存在有效订单
                wixLocation.to(`/profil/kontakt/${urlId}`);
            } else {
                // 会员无有效订单
                wixLocation.to(`/abonnementer`);
            }
        })
        .catch((error) => {
            console.error(error);
        });
    } else { 
        // 你的其他代码
    }
}

关键说明

  • 调用listCurrentMemberOrders时传入配置对象,其中filter属性指定筛选规则,status: "ACTIVE"会仅返回状态为活跃的订单
  • 返回的activeOrdersList已经是经过筛选的结果,无需再额外判断单个订单状态
  • 若activeOrdersList长度大于0,说明用户存在有效的活跃订单

内容的提问来源于stack exchange,提问作者JohnOle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 22:40:03