最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wordpress - Creating a back date order in woocommerce using REST API - Stack Overflow

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论