#Programmatically adding / updateing a product to an existing price list.

6 messages · Page 1 of 1 (latest)

heady fog
#

Hello.
I can't figure out how to add or update the price programmatically in the PriceList.
Maybe I'm using the wrong method for this?
const priceList = await priceListServiceTx.addPrices(
"pl_01GSGEEB13KJ70TH0G3A91M2C9",
[
{
amount: 75,
variant_id: "variant_01GQ21A7E91Q3J5PGXF058TTPV", // error here PriceListPriceCreateInput doesn't know anything about variant_id.
currency_code: "USD",
},
]
);

I will be very grateful for help.

heady fog
#

Ok, i can add new product to existing PriceList

#

const pl = await priceListServiceTx.update(
"pl_01GSGEEB13KJ70TH0G3A91M2C9",
{
prices: [
{
variant_id: "variant_01GQ21A7E91Q3J5PGXF058TTPV",
amount: 100,
currency_code: "usd",
},
],
}
);

#

But, if I do this 2 times, will 2 entries appear in the price list, for the same product variant? Is this a bug? logically, it must probably update the existing product with a new price?

And I still don't understand why the addPrice method is needed. It simply creates an empty price, without being tied to a variant.

#

"prices": [
{
"id": "ma_01GSGJNRHQG65H1MTMCD5VQKVW",
"created_at": "2023-02-17T20:57:25.806Z",
"updated_at": "2023-02-17T20:57:25.806Z",
"deleted_at": null,
"currency_code": "usd",
"amount": 75,
"min_quantity": null,
"max_quantity": null,
"price_list_id": "pl_01GSGEEB13KJ70TH0G3A91M2C9",
"variant_id": null,
"region_id": null
},
{
"id": "ma_01GSGJNRJFD9Z35ENG2MF53DWW",
"created_at": "2023-02-17T20:57:25.806Z",
"updated_at": "2023-02-17T20:57:25.806Z",
"deleted_at": null,
"currency_code": "usd",
"amount": 100,
"min_quantity": null,
"max_quantity": null,
"price_list_id": "pl_01GSGEEB13KJ70TH0G3A91M2C9",
"variant_id": "variant_01GQ21A7E91Q3J5PGXF058TTPV",
"region_id": null
},
{
"id": "ma_01GSGJZE6NFAE1ZS7AB326PN8N",
"created_at": "2023-02-17T21:02:42.874Z",
"updated_at": "2023-02-17T21:02:42.874Z",
"deleted_at": null,
"currency_code": "usd",
"amount": 100,
"min_quantity": null,
"max_quantity": null,
"price_list_id": "pl_01GSGEEB13KJ70TH0G3A91M2C9",
"variant_id": "variant_01GQ21A7E91Q3J5PGXF058TTPV",
"region_id": null
}
],

#

It would be cool if someone explained the logic of these methods in the price list. Maybe I found a bug 🙂