Copied to clipboard

Flag this post as spam?

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


  • Bogdan 250 posts 427 karma points
    Jun 06, 2013 @ 18:41
    Bogdan
    0

    Custom properties issue

    Hello,

    I'm using the Javascript API to add the address and shipping info, but I need some other properties as well. This is what I've tried:

    var properties = {
                        firstName: $("#billingAddressFirstName").val(),
                        lastName: $("#billingAddressLastName").val(),
                        streetAddress: $("#billingAddressStreet").val() + " " + $("#billingAddressNumber").val(),
                        zipCode: $("#billingAddressZip").val(),
                        city: $("#billingAddressCity").val(),
                        email: $("#billingAddressEmail").val(),
                        company: $("#billingAddressCompany").val()
                    };
                    
                    if ($("#additional").is(":checked") == false) {
                        properties["shipping_firstName"] = $("#shippingAddressFirstName").val();
                        properties["shipping_lastName"] = $("#shippingAddressLastName").val();
                        properties["shipping_streetAddress"] = $("#shippingAddressStreet").val() + " " + $("#shippingAddressNumber").val();
                        properties["shipping_zipCode"] = $("#shippingAddressZip").val();
                        properties["shipping_city"] = $("#shippingAddressCity").val();
                        properties["shipping_email"] = $("#shippingAddressEmail").val();
                        properties["shipping_company"] = $("#shippingAddressCompany").val();
                    }
                    properties["twitter"] = "@@twitter";
                    properties["discountCode"] = "code";
                    properties["discountPercentage"] = "x%";
                    TC.addOrUpdateOrderProperties(
                        {
                            properties: properties,
                            storeId: @storeId,
                            successfn: function() { TC.generatePaymentForm( { storeId: @storeId } ); }
                        });

    I can see in the console all the properties being posted, and the order is saved just fine, but I don't see the extra info anywhere. Can you please tell me what I'm doing wrong?

    Thanks!

     

     

  • Anders Burla 2560 posts 8256 karma points
    Jun 07, 2013 @ 09:54
    Anders Burla
    1

    Hi

    I just ran this code - and properties was added just fine - used FF and FireBug

    var properties = {
    firstName: "Anders",
    lastName: "Testing"
    };
    TC.addOrUpdateOrderProperties(
    {
    storeId: 1,
    properties: properties
    });

    Kind regards
    Anders

  • Bogdan 250 posts 427 karma points
    Jun 07, 2013 @ 09:58
    Bogdan
    0

    Hi Anders,

    Yes, firstName and lastName are fine. It's the others, "twitter", "discountCode" that are missing.

    By the way, can you please give me a quick tip on how to implement discount codes?

     

    Thanks a lot!

  • Anders Burla 2560 posts 8256 karma points
    Jun 07, 2013 @ 10:19
    Anders Burla
    0

    If I add the "discountCode" property to my code - then the property is added and has the value of "code". So that one is working as well. Try and cut into it works and then you know which line is making funny business with you :)

    To implement discount code you can add the codes as nodes. Then when the code is added - you use the Tea Commerce event system to get notificed of the properties has changed. Now validate the code and if its valid - add a order property that is server side only with the discount. Now use that discount percent in a custom order calculator to change the pricing.
    http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/40731-Pricing-based-on-quantity?p=0

    Kind regards
    Anders

  • Bogdan 250 posts 427 karma points
    Jun 07, 2013 @ 10:31
    Bogdan
    0

    Thanks, I understand the discount workflow. That's pretty much what I had in mind, just didn't do my homework :) Thanks!

    Where should I be seeing these custom properties in the Tea Commerce section? Maybe I'm just looking at it wrong...

  • Anders Burla 2560 posts 8256 karma points
    Jun 07, 2013 @ 10:35
    Anders Burla
    0

    If you use FireFox and FireBug - then your console will show you all the javascript posts and the response. Then click the JSON tab and you see the JSON returned and can click through the order object. There you have the properties and their values etc.

    Kind regards
    Anders

  • Bogdan 250 posts 427 karma points
    Jun 07, 2013 @ 10:42
    Bogdan
    0

    I do see them in the JSON response (though in Chrome):

    "twitter":{"value":"@twitter","serverSideOnly":false,"isReadOnly":false},
    "discountCode":{"value":"code","serverSideOnly":false,"isReadOnly":false},
    "discountPercentage":{"value":"x%","serverSideOnly":false,"isReadOnly":false}

    But I don't see them saved anywhere in the Tea Commerce section.

  • Anders Burla 2560 posts 8256 karma points
    Jun 07, 2013 @ 11:12
    Anders Burla
    100

    That is because the Razor file that show the order isnt showing custom properties that you add. You can just change the Razor file in the Scripts(razor)/tea-commerce/edit-order.cshtml. Thats simple :)

    Remember to update to the latest Tea Commerce. Think we removed the "serverSideOnly" attribute from teh JSON result :)

  • Bogdan 250 posts 427 karma points
    Jun 07, 2013 @ 11:20
    Bogdan
    0

    Yes! That was it! I've edited edit-order.cshtml and the custom properties are actually working fine.

    The Tea Commerce package I use is from Tea Commerce 2.1.1.zip but I checked the value of the versions of the dlls and it still says 2.0.0. Don't know if that's a problem or not.

    Thanks a lot for helping me, Anders!

  • Anders Burla 2560 posts 8256 karma points
    Jun 07, 2013 @ 11:29
    Anders Burla
    0

    Ahh - that is because its a thing i fixed in 2.1.2 :)

    The dll will always have 2.0.0 in its version because of some copilation stuff in .NET and references to dll files. So the right version is to see in the Umbraco admin and then see install packages.

  • Bogdan 250 posts 427 karma points
    Jun 07, 2013 @ 12:29
    Bogdan
    0

    Is 2.1.2 already available for download? I cannot find it :| Is upgrading only a matter of overwriting the dlls?

    Thanks!

  • Anders Burla 2560 posts 8256 karma points
    Jun 07, 2013 @ 12:50
    Anders Burla
    0

    No it has not been released - so that is why :)

    Upgrading is just installing the package again. We make sure things merge and is overwritten.

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft