如何使用woocommerce api为客户创建账单记录

2024-03-28 14:37:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法将我的django应用程序中有关特定客户的信息发布到我的woocommerce网站

我所遵循的过程是从表单中获取有关账单的信息,然后调用一个函数,通过api向我的站点发送帖子

我注意到账单信息根本没有存储

您知道这种行为是否与api的语法有关吗? 您知道我是否必须在posting命令中定义客户的id吗

我的代码:

def create_woocommerce_client_billing_individually(wcapi,wholesale_client_id,first_name,last_name,company,address_1,address_2,city,state,postcode,country,email,phone):
        print(wholesale_client_id)
        fetched_billing=Woo_Customer_Billing.objects.get(client_id=wholesale_client_id,email=email)

        data = {
            "first_name": fetched_billing.first_name,    
            "last_name": fetched_billing.last_name,
            "company": fetched_billing.company,
            "address_1": fetched_billing.address_1,
            "address_2": fetched_billing.address_2,
            "city": fetched_billing.city,
            "state": fetched_billing.state,
            "postcode": fetched_billing.postcode,
            "country": fetched_billing.country,
            "email": fetched_billing.email,
            "phone": fetched_billing.phone,


            }
        wcapi.post("customers", data).json()


Tags: nameclient信息idcityaddressemailcompany