优惠券不适用于订单

时间:2019-01-26 14:54:23

标签: wordpress woocommerce woocommerce-rest-api

我无法将优惠券代码应用于通过WooCommerce Orders的REST API下达的订单。

下面是我创建的Coupon对象。

    "coupon": {
        "id": 2832,
        "code": "first50",
        "type": "percent",
        "created_at": "2019-01-26T12:13:12Z",
        "updated_at": "2019-01-26T12:16:31Z",
        "amount": "50.00",
        "individual_use": true,
        "product_ids": [
            18,
            128
        ],
        "exclude_product_ids": [],
        "usage_limit": null,
        "usage_limit_per_user": 5,
        "limit_usage_to_x_items": 0,
        "usage_count": 0,
        "expiry_date": null,
        "enable_free_shipping": false,
        "product_category_ids": [],
        "exclude_product_category_ids": [],
        "exclude_sale_items": true,
        "minimum_amount": "50.00",
        "maximum_amount": "0.00",
        "customer_emails": [],
        "description": "50% Discount for new Users"
    }

这是我订单的对象。

             {
         "status": "pending",
         "currency": "INR",
         "customer_id": 1,
         "customer_note": "bring disposables",
         "line_items": [
             {
               "product_id": 18,
               "name": "Tomato/Tamatar",
               "quantity": 2
              },
              {
                "product_id": 128,
            "name": "Park avenue Beer Shampoo - Anti Dandruff",
                "quantity": 1
               }
                 ],
             "coupon_lines": [
                {
                  "code": "FIRST50",
                  "amount":"50"
                 }
                             ] 

                    }

这是答复:

    "order": {
        "id": 2838,
        "order_number": "2838",
        "order_key": "wc_order_CpSt4g4AhSyLF",
        "created_at": "2019-01-26T12:24:10Z",
        "updated_at": "2019-01-26T12:24:10Z",
        "completed_at": "1970-01-01T00:00:00Z",
        "status": "pending",
        "currency": "INR",
        "total": "215.00",
        "subtotal": "215.00",
        "total_line_items_quantity": 3,
        "total_tax": "0.00",
        "total_shipping": "0.00",
        "cart_tax": "0.00",
        "shipping_tax": "0.00",
        "total_discount": "0.00",
        "shipping_methods": "",
        "payment_details": {
            "method_id": "",
            "method_title": "",
            "paid": false
        },
        "billing_address": {
            "first_name": "",
            "last_name": "",
            "company": "",
            "address_1": "",
            "address_2": "",
            "city": "",
            "state": "",
            "postcode": "",
            "country": "",
            "email": "cocnikku@gmail.com",
            "phone": ""
        },
        "shipping_address": {
            "first_name": "",
            "last_name": "",
            "company": "",
            "address_1": "",
            "address_2": "",
            "city": "",
            "state": "",
            "postcode": "",
            "country": ""
        },
        "note": "",
        "customer_ip": "ip-address",
        "customer_user_agent": "WooCommerce API Client-Node.js/1.4.2",
        "customer_id": 1,
        "view_order_url": "some-url",
        "line_items": [
            {
                "id": 19,
                "subtotal": "60.00",
                "subtotal_tax": "0.00",
                "total": "60.00",
                "total_tax": "0.00",
                "price": "30.00",
                "quantity": 2,
                "tax_class": "",
                "name": "Tomato",
                "product_id": 18,
                "sku": "",
                "meta": []
            },
            {
                "id": 20,
                "subtotal": "155.00",
                "subtotal_tax": "0.00",
                "total": "155.00",
                "total_tax": "0.00",
                "price": "155.00",
                "quantity": 1,
                "tax_class": "",
                "name": "Park avenue Beer Shampoo - Anti Dandruff",
                "product_id": 128,
                "sku": "",
                "meta": []
            }
        ],
        "shipping_lines": [],
        "tax_lines": [],
        "fee_lines": [],
        "coupon_lines": [
            {
                "id": 21,
                "code": "FIRST50",
                "amount": "50.00"
            }
        ],
        "customer": {
            "id": 1,
            "created_at": "2019-01-25T11:34:06Z",
            "last_update": "1970-01-01T00:00:00Z",
            "email": "email@gmail",
            "first_name": "",
            "last_name": "",
            "username": "use",
            "role": "administrator",
            "last_order_id": 2838,
            "last_order_date": "2019-01-26T12:24:10Z",
            "orders_count": 7,
            "total_spent": "0.00",
            "avatar_url": "http://2.gravatar.com/avatar/5048e27e52e36b2c2d18d84706104a6c?s=96&d=mm&r=g",
            "billing_address": {
                "first_name": "",
                "last_name": "",
                "company": "",
                "address_1": "",
                "address_2": "",
                "city": "",
                "state": "",
                "postcode": "",
                "country": "",
                "email": "",
                "phone": ""
            },
            "shipping_address": {
                "first_name": "",
                "last_name": "",
                "company": "",
                "address_1": "",
                "address_2": "",
                "city": "",
                "state": "",
                "postcode": "",
                "country": ""
            }
        }
    }

我正在尝试将此发布到API。但是它不会将优惠券应用到总数中。在答复中,我得到了产品的总价,而没有获得优惠券的折扣。

0 个答案:

没有答案