Copied to clipboard

Flag this post as spam?

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


  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Oct 13, 2013 @ 03:07
    Bjarne Fyrstenborg
    0

    Issue with cart after updating to Tea Commerce v. 2.2.0

    I have updated Tea Commerce from v. 2.1.3 to 2.2.0 because of a bug related to PayPal:

    From revision history:
    FIX: PayPal now only supports an interger for quantity instead of decimal

    But in this version also HasCurrentOrder is removed and I should use GetCurrentOrder( storeId, false).

    However I still got an error message:
    Type 'TeaCommerce.Api.Models.Order' can not be implicitly converted to 'bool'

    @using TeaCommerce.Umbraco.Web
    @using TeaCommerce.Api.Models
    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @{
      //Store id
      long storeId = long.Parse( Model._Store );
    
      DynamicNode currentPage = Model;
    
      string totalPrice = "";
      decimal totalQuantity = 0;
      OrderLineCollection orderLines = new OrderLineCollection();
    
      if ( TC.GetCurrentOrder( storeId, false ) ) {
        Order order = TC.GetCurrentOrder( storeId );
        totalPrice = order.SubtotalPrice.ToString();
        totalQuantity = order.OrderLines.Sum( o => o.Quantity );
      }
      var cartPage = currentPage.AncestorOrSelf( "Lang" ).Descendants( "Cart" ).First();
      string cssClass = string.Format( "items{0}", totalQuantity );
    }
    ...

     

    /Bjarne

     

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Oct 13, 2013 @ 03:39
    Bjarne Fyrstenborg
    0

    Okay, I figured out that I just need to check for null as it of course not return a boolean now, but an Order object :)

    and I needed to update the razor files which was using HasCurrentOrder or HasCurrentFinalizedOrder..

    What does the true/false parameter in GetCurrentOrder do?

    And when HasCurrentFinalizedOrder method in v. 2.2.0 is removed, how should I rewrite this in cart/view-order-line-overview.cshtml?

    Order order = TC.GetCurrentOrder( storeId, false );
    decimal totalQuantity = 0;
    
    if ( cartTemplate != 1203 ) {
    if ( order != null ) {
    order = TC.GetCurrentOrder( storeId, false );
    }
    
    } else {
    if ( TC.HasCurrentFinalizedOrder( storeId ) ) {
    order = TC.GetCurrentFinalizedOrder( storeId );
    }
    }

     

    /Bjarne

  • Anders Burla 2560 posts 8256 karma points
    Oct 14, 2013 @ 10:09
    Anders Burla
    100

    The HasCurrentFinalizedOrder just needs to use the GetCurrentFinalizedOrder and then check for null.

    The bool that GetCurrentOrder takes is a bool that indicates if an order should be created if non i present. Mini cart will have false - but the cart flow would axpect an order is already there - so dont send the bool - as its optional.

    Kind regards
    Anders

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Oct 14, 2013 @ 15:25
    Bjarne Fyrstenborg
    0

    Okay, that works.. :)

    So I will just have to use TC.GetCurrentOrder( storeId, false) in minicart and TC.GetCurrentOrder(storeId) in checkout flow?

    /Bjarne

  • Anders Burla 2560 posts 8256 karma points
    Oct 15, 2013 @ 23:03
    Anders Burla
    0

    Exactly

  • Mark 22 posts 73 karma points
    Nov 07, 2013 @ 09:58
    Mark
    0

    I upgraded to 2.2 and I am working through the breaking changes but this does not work for me.

    Order order = TC.GetCurrentOrder( storeId,false);

    This line fails presumably because order is null. I can't seem to check whether it is null before calling this.

    Thanks,
    Mark 

     

     

  • Anders Burla 2560 posts 8256 karma points
    Nov 07, 2013 @ 10:20
    Anders Burla
    0

    Tc.GetCurrentOrder would in 2.2 actually always return an order because of a bug. It will be fixed in 2.2.1. So if this returns null - could you check if your have hit the limit for running in test mode? 20 orders.

    Kind regards
    Anders

  • Mark 22 posts 73 karma points
    Nov 07, 2013 @ 10:30
    Mark
    0

    Hi Anders, I actually had 19 orders but deleted a few and this did not make any difference. Does TC retain an internal count or should deleting orders work?

    Thanks,
    Mark 

  • Anders Burla 2560 posts 8256 karma points
    Nov 07, 2013 @ 11:17
    Anders Burla
    0

    You should reset the "CurrentOrderNumber" in the DB table TC_Store to 0 to get it to work again if you have 20 orders.

Please Sign in or register to post replies

Write your reply to:

Draft