What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi, I got a question on a best practice: I am in my PayCommand. I need to get access to the itemTran

ULL0N440J
ULL0N440J Posts: 184 🧑🏻‍🚀 - Cadet

Hi, I got a question on a best practice:
I am in my PayCommand. I need to get access to the itemTransfer inside/ instead of the SalesOrderItemTransfer.
Why? The ItemTransfer provides a field "originalNetPrice", which I need (prices without margin).

My thought so far: I could receive this by resolving the productId and get the ItemTransfer this way. Is there a better idea?

Comments

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer

    You shouldn’t fetch it from the current product price.
    The reason here is that while the order item you process might be created a few seconds ago in the meantime the product price could have changed.

    My suggestion is to copy the originalNetPrice into the order item during the creation of it and work on this copied data.
    It’s the same reason why addresses for an order are copied to the order instead of referencing the original address.

  • I agree, order data should not be changed after order was placed. All those information was accepted by customer (including prices and so on) during checkout process.

  • ULL0N440J
    ULL0N440J Posts: 184 🧑🏻‍🚀 - Cadet

    Alright 🙂 Thank you both, will extend the SpySalesOrderItemEntityTransfer then.

    Can you tell me, at which point items are "changed" to OrderItems? My first guess was to add the new field (originNetPrice) during Calculation process.

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer

    There should be a placeOrder method in the sales bundle. This is were the quote gets converted into an order.
    Implementing this in the calculation process is not a good idea as most parts of the calculation process are reused in the cart.

  • ULL0N440J
    ULL0N440J Posts: 184 🧑🏻‍🚀 - Cadet
    edited January 2020

    Yep, I added an own step to checkout already (margin calculation).
    OriginNetPrice of a product shouldn't change at all during process (well.. maybe if the price is changed in this time as you mentioned 😅 )

    Thanks! 🙂

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer