MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
947 stars 278 forks source link

only able to create single order #645

Open peteroleeman opened 8 months ago

peteroleeman commented 8 months ago

need help, trying to create order with code below. However i'm only able to create a single order. I have tried to call the function many times and for past 3 days, but it always return back the same order i created few days ago.

shopify.order.create( { //"user_id" : "gkash user id", "order_id": 51, //"api_version" : "2024-01", // "id": 550789470, "created_at": "2024-01-11T12:40:09+08:00", "name": "A0051", "number": 51, "order_number": 51, "kind": "sale", "status": "success", // "amount": 238.47, "reference" : "gkash", "source_name" : "gkash_source", "processing_method" : "gkash_method", //"device_id" : "gkash_terminal_id", //"gateway" : "gkash_gateway", "note" : "this is a detail note from gkash", "tags": "Léon, Noël", //"name" : "A001", "note_attributes": [ { "name": "custom engraving", "value": "Happy Birthday" }, { "name": "colour", "value": "green" } ],

    "line_items" : [
        {
        "title" : "Big Brown Bear Boots",
        "price" : 74.99,
        //"grams" : "1300",
        "quantity": 1,
        // "tax_lines": [
        // {
        //     "price": 13.5,
        //     "rate": 0.06,
        //     "title": "State tax"
        // }
        // ]
    }
    ]
}

) .then((order) => {

res.send(order)

}) .catch((err) => { res.send(err) });

Kakha01 commented 5 months ago

@peteroleeman As mentioned in the shopify order resource, parameters such as "created_at", "name", "order_number", etc. are read-only, which means that you cannot pass them as params, instead only shopify can modify those values.

shopify.order.create({
        "number": 51,
        "transactions": [{
            "kind": "sale",
            "status": "success",
            "amount": 238.47
        }],
        "source_name": "gkash_source",
        "note": "this is a detail note from gkash",
        "tags": "Léon,Noël",
        "note_attributes": [{
                "name": "custom engraving",
                "value": "Happy Birthday"
            },
            {
                "name": "colour",
                "value": "green"
            }
        ],
        "line_items": [{
            "title": "Big Brown Bear Boots",
            "price": 74.99,
            "quantity": 1,
        }]
    })
    .then((order) => {
        res.send(order)
    })
    .catch((err) => {
        res.send(err)
    });

your code should look something like this.