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..

Hello again 🙂 when using the step engine in yves, there is a last “successStep

UPWG9AYH2
UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

Hello again 🙂
when using the step engine in yves, there is a last “successStep” which will display a “thank you for your order” phrase. We want also to display the order number of the current finished order. Unfortunately, the success execute step clears the quote before the getTemplateVariables() method gets called. So we have no order reference anymore. Question: Is there some elegant way to get the last order reference anyway without extensive changes? Any “getLastOrder” functionality or something like this?
Best regards

«1

Comments

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    One idea is to bypass the step engine on the “successAction” in the CheckoutController and pass an extra variable to the render call … but this would be extremely ugly in my opinion

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Another idea: outsource the clearQuote logic to an additional step called “clearQuoteStep” and append it as the very last step (after success page). The problem is, i cannot be ensured that the “clearquote” step is really executed. 😕

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    U can to do this in controller successAction.
    U can clone the quote transfer and then execute the process (standard).
    And provide the cloned quote transfer to view..

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    As far as i see, the quote is $response in that case

    $response = $this->createStepProcess()->process($request);

    This will implicit execute all steps (including clear quote) … how to clone this here?

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Okay, the response is not the quote but it is included in it …

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    U have the DataContainer in CheckoutPage Bundle.. Just get data from DataContainer and u have the quote transfer used in step engine

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    okay, means, get the datacontainer and pass an extra variable to the template?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    yes.. this is the fast way..

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Would be some solution that i already evaluated, but also very ugly in my opinion^^

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    No.. why?

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Because the response is already rendered and should include all the info that is required for rendering the output

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Feels like hacking the whole process to me in some way

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    SuccessStep ist the last step.. successStep execute will be run before getTemplateVariables etc... u have no other options..
    Another options is to make this logic in successStep execute.. there maybe clone and then this cloned var used in getTemplateVariables.. but is the same.. maybe clean

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Okay, might be the only workaround for this 😕 Thanks a lot 🙂

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    as said clean would be to implement this in successStep on pyz level..

    Let me know if u found another "better" solution 🙂

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    p.s.: take a look in placeOrderAction in CheckoutController.. Spryker self make some checks or other things before run process... it is just similar..

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    ah i see …

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    $quoteTransfer = $this->getFactory()
    ->getQuoteClient()
    ->getQuote();

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    as said clean would be to implement this in successStep on pyz level..

    How would you do this? I would suggest editing the execute method, but unfortunately, the return value of the execute gets saved to the session … so adding the order reference here leads to unwanted effects for the next order/quote

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    even with clone quoteTransfer saved as class variable i.e. and then used in getTemplateVariables.

    Ok.. In our project we have a secondary data container where we save in session the quote placed as order.. in our case then is just to read this one.. but this happened in our project already in place order action to avoid double orders problem where Spryker just working on it (great problem in spryker place order)

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    but we have a completely re-structured checkout.. we have an OnePageCheckout.. otherwise i could post the source code for u..

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Thanks for your offer 🙂 i think i will go for least resistance way and bypass some variable to the template^^might be appropriate for the current siutation

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    $orderReference = $this->getFactory()->getQuoteClient()->getQuote()->getOrderReference();
    return $this->view(
    array_merge($response, [‘orderReference’ => $orderReference]), …

    is the way i’ll go

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    Ok.. where u placed

    $orderReference = $this->getFactory()->getQuoteClient()->getQuote()->getOrderReference();
    

    ?

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    successAction, first execution line

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    right before

    $response = $this->createStepProcess()->process($request);

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    since it will change the quote

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    Ok in controller.. then u go with first option as my first suggestion..

    Yes it is ok!

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    Thanks a lot 🙂

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

    u are welcome.

    p.s.: of course there is still a better or elegant solution, but this ist the fast and also "not ugly" solution!