Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: hooks of LineItem are missing #10086

Closed
dupuisbenjamin opened this issue Nov 13, 2024 · 5 comments
Closed

[Bug]: hooks of LineItem are missing #10086

dupuisbenjamin opened this issue Nov 13, 2024 · 5 comments
Labels

Comments

@dupuisbenjamin
Copy link

Package.json file

{
    [...]
    "scripts": { [...] },
    "dependencies": {
        "@medusajs/admin-sdk": "latest",
        "@medusajs/framework": "latest",
        "@medusajs/medusa": "latest",
        "@medusajs/cli": "latest",
        "@mikro-orm/core": "5.9.7",
        "@mikro-orm/knex": "5.9.7",
        "@mikro-orm/migrations": "5.9.7",
        "@mikro-orm/postgresql": "5.9.7",
        "awilix": "^8.0.1",
        "pg": "^8.13.0",
        [...]
    },
    "devDependencies": {
        "@mikro-orm/cli": "5.9.7",
        "@medusajs/test-utils": "latest",
        [...]
    }
}

Node.js version

v20.17.0

Database and its version

PostgreSQL v10.4

Operating system name and version

Windows 11

Browser name

No response

What happended?

I'm trying to extend the LineItem on an order. While there is no documentation for extending the Order module, I've found a similar one for the Cart. Here is the link
I'd like to consume the lineItemCreated workflow hook, similarly to step 4. I've checked the https://docs.medusajs.com/learn/advanced-development/workflows/workflow-hooks and the reference https://docs.medusajs.com/resources/medusa-workflows-reference, and couldn't find any hooks that allows you to add additional_data to a line_item.

Expected behavior

According to the reference guide and to the github

I am expecting to be able to do the following

addOrderLineItemsWorkflow.hooks.LineItemCreated(
      async ({ lineItem, }, { container }) => {
            // TODO
      })
)

Actual behavior

Error that there is no hook on addOrderLineItemsWorkflow

Link to reproduction repo

@sradevski
Copy link
Member

Hi there, we are adding hooks as necessary, so we might not have gotten to it just yet.

I cannot say when we'll be able to look into it though, so we'd be more than happy if you can just open a PR adding the hooks.

Thanks!

@dupuisbenjamin
Copy link
Author

Hi @sradevski,

I have been working on the workflow createOrderLineItemsWorkflow and implementing it in the createOrdersWorkflow.

However, after several hours working on it, I noticed that achieving my goal won't be possible at the moment due to the impossibility of supplying the workflow with additional_data like in createOrdersWorkflow.
The validator doesn't allow the addition of customAdditionalData Validation to the additional_data of an item inside an order, aka LineItem.
I was expecting to be able to do it in Medusa v2 because it was possible to do so in Medusa v1. With the current additional_data structure, this seems impossible. Extending LineItem to add additional_data is crucial for my team, I am quite disappointed in the lack of extendability of important entities.

Looking forward for future fixes about it.

@sradevski
Copy link
Member

@dupuisbenjamin the way you extend models is different in V2, please check https://docs.medusajs.com/learn/customization/custom-features.

Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@github-actions github-actions bot added the Stale label Dec 17, 2024
Copy link
Contributor

This issue was closed because it has been stalled for 3 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants