Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Sam Gooch 24 posts 116 karma points
    Sep 19, 2017 @ 14:13
    Sam Gooch

    PrepareInvoice clears basket and loses items


    I am using v2.5.0 along with Umbraco v.7.6.5.

    When I go prepare the invoice using the Checkout Manager (created using the Basket from the MerchelloSurfactController), I am losing all the items against the invoice and the basket clears itself.

    Does anyone have any ideas what I'm doing wrong?

    Thanks in advance, Sam

  • Lee 1130 posts 3088 karma points
    Sep 21, 2017 @ 10:36

    Hard to say without code examples. It's used throughout the code base. Could be that the Basket has changed before you are calling it. i.e. Logging in a user after items have been added to cart

  • Ben McKean 272 posts 549 karma points
    Sep 21, 2017 @ 11:25
    Ben McKean

    Hi Sam,

    I had a similar problem to this and it confused me also. This is intended behaviour in that the basket empties.

    There are a couple of ways around this.

    Firstly in the merchello.config (App_Plugins\Merchello\config\merchello.config) set EmptyBasketOnPaymentSuccess key to false.

        <setting alias="InvoiceNumberPrefix" value="FT" />
        <setting alias="ApplyTaxesToInvoice" value="true" />
        <setting alias="RaiseCustomerEvents" value="false" />
        <setting alias="ResetCustomerManagerDataOnVersionChange" value="false" />
        <setting alias="ResetPaymentManagerDataOnVersionChange" value="true" />
        <setting alias="ResetExtendedManagerDataOnVersionChange" value="true" />
        <setting alias="ResetShippingManagerDataOnVersionChange" value="true" />
        <setting alias="ResetOfferManagerDataOnVersionChange" value="true" />
        <setting alias="EmptyBasketOnPaymentSuccess" value="false" />

    Secondly is to do this when you create an instance of the CheckoutManager. I had a helper method that did this for me and called this whenever I needed it:

    /// <summary>
    /// Gets checkoutmanger instance
    /// </summary>
    /// <param name="customerContext">The context</param>
    /// <returns>ICheckoutManagerBase instance</returns>
    public static ICheckoutManagerBase GetCheckoutManager(CustomerContextBase customerContext)
        var settings = new CheckoutContextSettings()
            ResetCustomerManagerDataOnVersionChange = false,
            ResetExtendedManagerDataOnVersionChange = false,
            ResetShippingManagerDataOnVersionChange = false,
            ResetPaymentManagerDataOnVersionChange = false,
            EmptyBasketOnPaymentSuccess = false
        var basket = customerContext.CurrentCustomer.Basket();
        var checkoutManager = basket.GetCheckoutManager(settings);
        return checkoutManager;

    Hope that helps


  • Sam Gooch 24 posts 116 karma points
    Sep 21, 2017 @ 11:28
    Sam Gooch

    Cheers Ben and Lee. It looks like the Validate() method was being called and the item I was always testing with in my basket (d'oh) had no stock! Annoyingly there was no message bubbling up to let me know of that fact.

    That helper method sounds good, cheers.



  • Ben McKean 272 posts 549 karma points
    Sep 21, 2017 @ 11:31
    Ben McKean

    I found (and as Lee said) that the basket can be pretty temperamental so if you change anything, it creates a new instance of the basket and you lose data.

    In fact, I ran into so many problems that I ended up writing quite a few of my own helper methods which stored things in sessions and reloaded them into the checkout context when I needed them...

    This was a couple of versions back to what you're using so it may have changed.

Please Sign in or register to post replies

Write your reply to: