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