Copied to clipboard

Flag this post as spam?

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


  • Carlos Tarazona 24 posts 43 karma points
    Jun 19, 2012 @ 02:55
    Carlos Tarazona
    0

    Price update destroys orderline properties?

    Hi,

    I am extending Tea Commerce using the .NET API.  Specifically, I am updating the price (UnitPrice) of the orderline to give discounts.  As soon as I do this the product names of the products that had their price updated are blank.  I see this both from XSLT and the order object in the javascript API.  Any ideas why is this happening?  Or what am I doing wrong?  Thank you!

     

    Carlos

  • Rune Grønkjær 1371 posts 3102 karma points
    Jun 19, 2012 @ 08:18
    Rune Grønkjær
    0

    Hi Carlos,

    Welcome to the Umbraco forum.

    From your description I cannot say what is wrong. I'm doing exactly that in a few of my own e-commerce solutions and never ran into that.

    You should try and run it on your local IIS and attach a debugger. Then you can step through it and see if anything weird happens.

    /Rune

  • Carlos Tarazona 24 posts 43 karma points
    Jun 19, 2012 @ 11:42
    Carlos Tarazona
    0

    Hi Rune,

    I am banging my head against the wall with this.  Also, note, I am implementing pessimistic stock management (this works well) too.  In WebshopEvents_OrderLineAdded (and "removed"), I am looping over all order lines and making a decision on what the discount should be and then setting the UnitPrice. I am doing something along the lines of:

                for (int i = 0; i < order.OrderLines.Count(); i++)

                {

    tempLine = order.OrderLines.ElementAt(i);

    if (tempLine.NodeId is a product category that gets a discount) //this is pseudo-code for simplicity

    discountPrice = 49.95M;

    tempLine.UnitPrice = discountPrice;

    }

    I have tried calling order.Save() when directly after I have applied the discount and at the end of this event (i.e. one update).  As I said, I am managing stock values too.  I do an order.Save() immediately after calling SetStock.

    Playing with when and how many times I call order.Save() hasn't made a difference but to be clear.  How should I use order.Save()?  Does it matter if I call it multiple times?  Or could it be that I am using a temp variable to hold the order line?

    Thanks.

    Carlos

  • Rune Grønkjær 1371 posts 3102 karma points
    Jun 19, 2012 @ 11:51
    Rune Grønkjær
    0

    Hi Carlos,

    The order.Save() method is saving the order and everything in it to the database. BUT it will only save the things, that have been changed on the order. So if you change the UnitPrice on an order line only the order line will be saved. If you change a property on the order line only that property will be saved.

    A few questions
    By product names, you mean an order line property?
    Is all order line properties left blank after your code has been run?

    Maybe replace your for loop with a foreach like this:

    foreach(var orderline in order.OrderLines){
      //Do the magic
    }

    /Rune

  • Carlos Tarazona 24 posts 43 karma points
    Jun 19, 2012 @ 12:01
    Carlos Tarazona
    0

    Hi Rune,

    Yes, I mean an order line property by product names.  Only those order lines for which the price has been updated is the product name blank.  Also, just saw that if I add/remove products the issue appears to correct itself though not reliably.  It worked once when I added a product but then I tried to reproduce it and it took a couple add/removes before it fixed itself.  But it did fix itself eventually.

    I will try your foreach suggestion.  Thanks.

    Carlos

  • Rune Grønkjær 1371 posts 3102 karma points
    Jun 19, 2012 @ 12:04
    Rune Grønkjær
    0

    This is some enigma you have there :)

    Best thing would be if you could debug it locally. If not, maybe try to debug it on the server by writing to the umbraco log.

    umbraco.BusinessLogic.Log.Add(..)

    Afterwards you can check the log in the database and se what is going on.

    /Rune

  • Carlos Tarazona 24 posts 43 karma points
    Jun 19, 2012 @ 15:14
    Carlos Tarazona
    0

    Hi Rune,

    FYI, foreach didn't help.  I will try local debugging.  Any other suggestions?  Thanks.

    Carlos

  • Rune Grønkjær 1371 posts 3102 karma points
    Jun 19, 2012 @ 15:35
    Rune Grønkjær
    0

    No, not before you have some more info. Just walk throught your steps in debug mode and check the values.

    Also, you might want to check the properties in the Tea Commerce tables if you need to go all in on the debugging.

    /Rune

  • Carlos Tarazona 24 posts 43 karma points
    Jun 21, 2012 @ 06:30
    Carlos Tarazona
    0

    Hi Rune,

    I tried to use VS2010 to attach to a locally running IIS but the site was funky.  Something about data page invalid.  Not sure what the issue is with that so I added some additional logging and ToJson'd the order at different points.  Look at nodeid 1362.  Anything funny there?  That is the discounted product and it doesn't have any of the "standard" properties.  Only a custom one that I added which I only started doing today and the issue existed previously so it's not related.

    Without further adieu here is the the JSON:

    {

        "Id": 596,

        "Country": {

            "Id": 2,

            "Name": "United States"

        },

        "CreatedDate": "\/Date(1340251738283-0500)\/",

        "Currency": {

            "CultureName": "en-US",

            "ISOCode": "USD",

            "Id": 3

        },

        "IsOrder": false,

        "MemberId": null,

        "ModifiedDate": "\/Date(1340251764196-0500)\/",

        "Name": "AMTA-596",

        "OrderDate": null,

        "OrderLines": [{

            "Id": 2140,

            "IsUnique": false,

            "NodeId": 1445,

            "Properties": [{

                "Id": 6497,

                "Alias": "nodeName",

                "Value": "Month to month agreement"

            }, {

                "Id": 6498,

                "Alias": "productName",

                "Value": "Month to month agreement"

            }, {

                "Id": 6499,

                "Alias": "productNumber",

                "Value": "Monthly"

            }, {

                "Id": 6500,

                "Alias": "mainProductLine",

                "Value": "aBusinessPhone"

            }],

            "Quantity": 1,

            "TotalPrice": 0.0000,

            "TotalPriceFormatted": "$0.00",

            "TotalPriceFormattedNoSymbol": "0.00",

            "TotalPriceWithoutVAT": 0,

            "TotalPriceWithoutVATFormatted": "$0.00",

            "TotalPriceWithoutVATFormattedNoSymbol": "0.00",

            "TotalVAT": 0.0000,

            "TotalVATFormatted": "$0.00",

            "TotalVATFormattedNoSymbol": "0.00",

            "UnitPrice": 0.0000,

            "UnitPriceFormatted": "$0.00",

            "UnitPriceFormattedNoSymbol": "0.00",

            "UnitPriceWithoutVAT": 0,

            "UnitPriceWithoutVATFormatted": "$0.00",

            "UnitPriceWithoutVATFormattedNoSymbol": "0.00",

            "UnitVAT": 0.0000,

            "UnitVATFormatted": "$0.00",

            "UnitVATFormattedNoSymbol": "0.00",

            "VAT": 0.0000,

            "VATPercent": "0"

        }, {

            "Id": 2141,

            "IsUnique": false,

            "NodeId": 1939,

            "Properties": [{

                "Id": 6501,

                "Alias": "nodeName",

                "Value": "312-216-5110"

            }, {

                "Id": 6502,

                "Alias": "productName",

                "Value": "aBusinessPhone"

            }, {

                "Id": 6503,

                "Alias": "productNumber",

                "Value": "312-216-5110"

            }, {

                "Id": 6504,

                "Alias": "mainProductLine",

                "Value": "aBusinessPhone"

            }],

            "Quantity": 1,

            "TotalPrice": 49.950000,

            "TotalPriceFormatted": "$49.95",

            "TotalPriceFormattedNoSymbol": "49.95",

            "TotalPriceWithoutVAT": 49.95,

            "TotalPriceWithoutVATFormatted": "$49.95",

            "TotalPriceWithoutVATFormattedNoSymbol": "49.95",

            "TotalVAT": 0.000000,

            "TotalVATFormatted": "$0.00",

            "TotalVATFormattedNoSymbol": "0.00",

            "UnitPrice": 49.950000,

            "UnitPriceFormatted": "$49.95",

            "UnitPriceFormattedNoSymbol": "49.95",

            "UnitPriceWithoutVAT": 49.95,

            "UnitPriceWithoutVATFormatted": "$49.95",

            "UnitPriceWithoutVATFormattedNoSymbol": "49.95",

            "UnitVAT": 0.000000,

            "UnitVATFormatted": "$0.00",

            "UnitVATFormattedNoSymbol": "0.00",

            "VAT": 0.0000,

            "VATPercent": "0"

        }, {

            "Id": 2142,

            "IsUnique": false,

            "NodeId": 1362,

            "Properties": [{

                "Id": 6508,

                "Alias": "mainProductLine",

                "Value": "aBusinessPhone"

            }],

            "Quantity": 1,

            "TotalPrice": 79.950000,

            "TotalPriceFormatted": "$79.95",

            "TotalPriceFormattedNoSymbol": "79.95",

            "TotalPriceWithoutVAT": 79.95,

            "TotalPriceWithoutVATFormatted": "$79.95",

            "TotalPriceWithoutVATFormattedNoSymbol": "79.95",

            "TotalVAT": 0.000000,

            "TotalVATFormatted": "$0.00",

            "TotalVATFormattedNoSymbol": "0.00",

            "UnitPrice": 79.950000,

            "UnitPriceFormatted": "$79.95",

            "UnitPriceFormattedNoSymbol": "79.95",

            "UnitPriceWithoutVAT": 79.95,

            "UnitPriceWithoutVATFormatted": "$79.95",

            "UnitPriceWithoutVATFormattedNoSymbol": "79.95",

            "UnitVAT": 0.000000,

            "UnitVATFormatted": "$0.00",

            "UnitVATFormattedNoSymbol": "0.00",

            "VAT": 0.0000,

            "VATPercent": "0"

        }, {

            "Id": 2143,

            "IsUnique": false,

            "NodeId": 1446,

            "Properties": [{

                "Id": 6509,

                "Alias": "nodeName",

                "Value": "12 month agreement"

            }, {

                "Id": 6510,

                "Alias": "productName",

                "Value": "12 month agreement"

            }, {

                "Id": 6511,

                "Alias": "productNumber",

                "Value": "Annual"

            }, {

                "Id": 6512,

                "Alias": "mainProductLine",

                "Value": "aBusinessPhone"

            }],

            "Quantity": 1,

            "TotalPrice": 0.0000,

            "TotalPriceFormatted": "$0.00",

            "TotalPriceFormattedNoSymbol": "0.00",

            "TotalPriceWithoutVAT": 0,

            "TotalPriceWithoutVATFormatted": "$0.00",

            "TotalPriceWithoutVATFormattedNoSymbol": "0.00",

            "TotalVAT": 0.0000,

            "TotalVATFormatted": "$0.00",

            "TotalVATFormattedNoSymbol": "0.00",

            "UnitPrice": 0.0000,

            "UnitPriceFormatted": "$0.00",

            "UnitPriceFormattedNoSymbol": "0.00",

            "UnitPriceWithoutVAT": 0,

            "UnitPriceWithoutVATFormatted": "$0.00",

            "UnitPriceWithoutVATFormattedNoSymbol": "0.00",

            "UnitVAT": 0.0000,

            "UnitVATFormatted": "$0.00",

            "UnitVATFormattedNoSymbol": "0.00",

            "VAT": 0.0000,

            "VATPercent": "0"

        }],

        "OrderStatus": {

            "DictionaryItemName": "",

            "Id": 1,

            "Name": "New"

        },

        "Payment": {

            "DictionaryItemName": "creditCard",

            "Fee": 0.00000000,

            "FeeFormatted": "$0.00",

            "FeeFormattedNoSymbol": "0.00",

            "FeeVAT": 0.00000000,

            "FeeVATFormatted": "$0.00",

            "FeeVATFormattedNoSymbol": "0.00",

            "FeeWithoutVAT": 0.0000,

            "FeeWithoutVATFormatted": "$0.00",

            "FeeWithoutVATFormattedNoSymbol": "0.00",

            "Id": 1,

            "MediaId": 1218,

            "Name": "Credit card"

        },

        "PaymentStatus": null,

        "Properties": [],

        "Shipping": {

            "DictionaryItemName": "",

            "Fee": 0.0000,

            "FeeFormatted": "$0.00",

            "FeeFormattedNoSymbol": "0.00",

            "FeeVAT": 0.0000,

            "FeeVATFormatted": "$0.00",

            "FeeVATFormattedNoSymbol": "0.00",

            "FeeWithoutVAT": 0,

            "FeeWithoutVATFormatted": "$0.00",

            "FeeWithoutVATFormattedNoSymbol": "0.00",

            "Id": null,

            "MediaId": null,

            "Name": ""

        },

        "TotalPrice": 129.90000000,

        "TotalPriceFormatted": "$129.90",

        "TotalPriceFormattedNoSymbol": "129.90",

        "TotalPriceWithoutFees": 129.900000,

        "TotalPriceWithoutFeesFormatted": "$129.90",

        "TotalPriceWithoutFeesFormattedNoSymbol": "129.90",

        "TotalPriceWithoutFeesWithoutVAT": 129.90,

        "TotalPriceWithoutFeesWithoutVATFormatted": "$129.90",

        "TotalPriceWithoutFeesWithoutVATFormattedNoSymbol": "129.90",

        "TotalPriceWithoutVAT": 129.9000,

        "TotalPriceWithoutVATFormatted": "$129.90",

        "TotalPriceWithoutVATFormattedNoSymbol": "129.90",

        "TotalQuantity": 4,

        "TotalVAT": 0.00000000,

        "TotalVATFormatted": "$0.00",

        "TotalVATFormattedNoSymbol": "0.00",

        "TotalVATWithoutFees": 0.000000,

        "TotalVATWithoutFeesFormatted": "$0.00",

        "TotalVATWithoutFeesFormattedNoSymbol": "0.00",

        "Transaction": {

            "PaymentAmount": null,

            "PaymentAmountFormatted": "$0.00",

            "PaymentAmountFormattedNoSymbol": "0.00",

            "PaymentCardNumber": null,

            "PaymentCardType": null,

            "PaymentTransactionId": null

        },

        "UmbracoLanguageId": 0,

        "VAT": 0.0000,

        "VATGroupId": 1,

        "VATPercent": "0"

    }

    Carlos

  • Carlos Tarazona 24 posts 43 karma points
    Jun 21, 2012 @ 06:31
    Carlos Tarazona
    0

    Also, the "standard" properties were there 4 seconds before in a previous entry.

  • Rune Grønkjær 1371 posts 3102 karma points
    Jun 21, 2012 @ 08:25
    Rune Grønkjær
    0

    Hi Carlos,

    Looks to me like all your orderlines have 4 properties. Here's from one of the orderlines:

    "Properties": [{

                "Id": 6497,

                "Alias": "nodeName",

                "Value": "Month to month agreement"

            }, {

                "Id": 6498,

                "Alias": "productName",

                "Value": "Month to month agreement"

            }, {

                "Id": 6499,

                "Alias": "productNumber",

                "Value": "Monthly"

            }, {

                "Id": 6500,

                "Alias": "mainProductLine",

                "Value": "aBusinessPhone"

            }]

     

    ---

    Or am I misunderstanding you?

    /Rune

  • Anders Burla 2560 posts 8256 karma points
    Jun 21, 2012 @ 08:38
    Anders Burla
    0

    Hi Carlos

    It looks like the order your posted has order lines with properties. Isn't that correct? Which events are you hooked into with the Tea Commerce .NET API?

    Kind regards
    Anders

  • Carlos Tarazona 24 posts 43 karma points
    Jun 21, 2012 @ 11:17
    Carlos Tarazona
    0

    Hi Rune,

    Those are the properties for nodeid 1445.  Only products which have had their price changed (see earlier in this thread) have the issue.  Here nodeid 1362 had it's price changed.  These are the properties for nodeid 1362 (only 1 as opposed to 4):

     

         "Id": 2142,

            "IsUnique": false,

            "NodeId": 1362,

            "Properties": [{

                "Id": 6508,

                "Alias": "mainProductLine",

                "Value": "aBusinessPhone"

            }],

  • Carlos Tarazona 24 posts 43 karma points
    Jun 21, 2012 @ 11:20
    Carlos Tarazona
    0

    Hi Anders,

    I am hooked into:

    WebshopEvents_AfterOrderFinalized

    WebshopEvents_OrderLineAdded

    WebshopEvents_OrderLineRemoved

     

    I am doing the discounting in "added" and "removed".  Those 2 events do the same thing as far as discounting goes.  Also, I am managing stock levels in these 2 methods as well.  That works great.

    Carlos

  • Carlos Tarazona 24 posts 43 karma points
    Jun 21, 2012 @ 11:22
    Carlos Tarazona
    0

    Also, the discount is being applied based on that they have another product in their cart.  Namely, nodeid 1446.

    Carlos

  • Rune Grønkjær 1371 posts 3102 karma points
    Jun 21, 2012 @ 11:25
    Rune Grønkjær
    0

    Hi Carlos,

    Do you have a page where we can see the problem in action? If you don't want to post it publicly you can e-mail it to us at [email protected]

    Please tell us how to reproduce it as well

    /Rune

  • Carlos Tarazona 24 posts 43 karma points
    Jun 21, 2012 @ 14:12
    Carlos Tarazona
    0

    Hi Rune,

    I sent over the information you requested.  Please confirm you received it.  Thank you.

    Carlos

  • Carlos Tarazona 24 posts 43 karma points
    Jun 27, 2012 @ 12:19
    Carlos Tarazona
    0

    Hi Rune/Anders,

    Tea Commerce 1.4.3.0 BETA 6 appears to have corrected this issue for me.  Thanks!

    Carlos

     

  • Anders Burla 2560 posts 8256 karma points
    Jun 27, 2012 @ 21:52
    Anders Burla
    0

    Could you please mark your own answer as the solution for this question - thanks :)

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft