admin管理员组

文章数量:1336563

I am migrating a Shopify store to the Woocommerce store and using the REST API for migration of the data. I imported the customer and order data. But now facing issues with importing the order specifically with the date on which this order was placed. I am trying to pass the same date on which the order was placed. So this was my payload:

order_data = {
    "customer_id": customer_id,
    "status": order_status,
    "date_created": order_date,
    "billing": billing_data,
    "shipping": shipping_data,
    "line_items": line_items,
    "shipping_total": str(shipping_total),
    "payment_method": payment_method,
    "shipping_lines": [
        {
            "method_title": shipping_method,
            "method_id": shipping_method
        }
    ] if shipping_method else [],
    "meta_data": [
        {"key": "_order_number", "value": str(order_id)},
        {"key": "tracking_number", "value": tracking_number}
    ]
}

I looked at the Woocommerce rest API doc and it's mentioned that the created date and modified date are read-only so I tried to pass the date as meta_data:

# Payload
order_data = {
    "customer_id": customer_id,
    "status": order_status,
    "billing": billing_data,
    "shipping": shipping_data,
    "line_items": line_items,
    "shipping_total": str(shipping_total),
    "payment_method": payment_method,
    "payment_method_title": payment_method,
    "shipping_lines": [
        {
            "method_title": shipping_method,
            "method_id": shipping_method
        }
    ] if shipping_method else [],
    "meta_data": [
        {"key": "_order_number", "value": str(order_id)},
        {"key": "tracking_number", "value": tracking_number},
        {"key": "_original_order_date", "value": order_date.strftime("%Y-%m-%d %H:%M:%S")}
    ]
}

but was still not able to get the back date in order when importing the order created date as it still shows the present in order. Is there any way to pass the back date for the order? If not rest API is there any other way to import orders in bulk?

本文标签: wordpressCreating a back date order in woocommerce using REST APIStack Overflow