#Updating Extended Base Entities Fields in Cart

12 messages · Page 1 of 1 (latest)

verbal scroll
#

We have updated the cart to have store_id. But this store_id is always null even after passing the parameter to the create, update functions.

In cart create method
async create(data: CartCreateProps): Promise<Cart> { console.log(data.store_id); data.store_id = "store_mock_12456677788"; console.log(data); return await super.create(data); }

log 1 is undefined
log 2 is { region_id: 'reg_01HQVXQCZVFQSVX0SMAEEJH1VQ', sales_channel_id: undefined, context: { ip: '::ffff:127.0.0.1', user_agent: 'insomnia/8.6.1' }, store_id: 'store_mock_12456677788' }
and the result is a null store_id in response and in database.

In the update we pass a store_id in POST /store/carts/{id} and in update function we have
`async update(cartOrId: string | Cart, data: CartUpdateProps): Promise<Cart> {
console.log(cartOrId);

console.log(data);

return await super.update(cartOrId, data);

}`

In this,
log 1 is cart_01HR6Z45BSRKMYCXYJES8YM
log 2 is StorePostCartsCartReq { store_id: 'store_01HQVXQ6GNFA9Z8K2M55YV', }

and still in the update response the store_id is null.

We have updated the store_id manually in db and on fetch GET /store/carts/{id} it is working i.e store_id is returned

#
GitHub

Hello everyone, I have been reading the Extend entity docs. It is working amazingly, I can create fields and retrieve them. But, what if we want to implement it using our admin? Example: curl --loc...

late linden
verbal scroll
#

For my case I ended up writing a raw sql query straight to db updating the field. Not the best solution. but the issue has been mentioned a couple times and there's no answer yet

#

So I make two calls 'create cart' and get the cart id, then use it to write the query to db

late linden
#

Did you also mess around with extending the repo or extending the service aswell?

verbal scroll
#

I honestly don't know if the issue lies there but this comment explains it well, https://github.com/medusajs/medusa/discussions/3965#discussioncomment-8671870 one, the extended entity value does not reach the create call and two, the update call has the extended entity but does not write to db. Could be the POST functions, the GET works if you add the value in db

GitHub

Hello everyone, I have been reading the Extend entity docs. It is working amazingly, I can create fields and retrieve them. But, what if we want to implement it using our admin? Example: curl --loc...

late linden
#

Strange. When I extend the create service to console log what I send to the server, the value I input for the custom attributes is shown.

verbal scroll
#

Does it get written to database

late linden
#

Sadly no. I'm trying to mess around with the service to see if I can get it work with no luck

verbal scroll
#

I reckon it's a bug. Will create an issue

late linden
#

It works for me now I somehow solved it. I'm looking into how I fixed it