Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jul 15, 2013 @ 11:29
    Dan
    0

    Get custom property of Tea Commerce order in razor

    Hi,

    I've used AJAX to save a custom property on an order, like this:

    TC.addOrUpdateOrderProperties({properties:{'upsShippingOptionPlainText' : upsShippingOptionPlainText}});

    Now I'd like to output the saved value of that property in the cart so the customer can see which shipping option they've chosen, but I don't think I have the syntax right and can't actually see a method in the documentation that looks like it would do this (I'm just assuming/hoping it's possible!).  I've tried this:

    @Dictionary[ "Shipping" ] (@Dictionary[ currentShippingMethod.Alias ] - @order.upsShippingOptionPlainText)

    And this:

    @Dictionary[ "Shipping" ] (@Dictionary[ currentShippingMethod.Alias ] - @order.Properties.upsShippingOptionPlainText)

    But it's erroring on saving the .cshtml file.

    Can anyone advise on how to retreive this custom property in the Razor script?

    Thanks

  • Dan 1288 posts 3921 karma points c-trib
    Jul 15, 2013 @ 12:05
    Dan
    100

    Got it!  The correct syntax for getting a property is

    @order.Properties["customProperty"])

    So my code above ended up like this:

    @Dictionary[ "Shipping" ] (@Dictionary[ currentShippingMethod.Alias ] - @order.Properties["upsShippingOptionPlainText"])

    Works nicely.  The more I find out about the API the more I like it - it's just difficult with the incomplete documentation at the moment.

  • Rune Grønkjær 1372 posts 3103 karma points
    Jul 15, 2013 @ 12:19
    Rune Grønkjær
    0

    Good thing you figured it out. The starter kit is all the documentation you will ever need ;)

    Nah, we know we need more documentation and it will come in august when we are over the summer holidays.

    /Rune

  • Dan 1288 posts 3921 karma points c-trib
    Jul 15, 2013 @ 12:29
    Dan
    0

    That's cool, thanks Rune.  It does feel a bit frustrating sometimes as this stuff is usually really simple but can take way too long to uncover.  If I could put in a feature request (for after the documentation!) it would be to offer a stripped-back starter kit that is ultra-basic in terms of functionality.  This was really useful with TC1, where you offered two starter kits - a bare-bones one and a fully-fledged one, but I've found that the starter kit in TC2 is way overkill for a simple starter project and actually quite confusing.  It has lots of package dependencies and uses pretty much the full gamut of TC functionality, which is obviously a good thing if it's a show-case of the product, but I've found it quite laborious to strip all of this stuff out and just get back to a simple 'add this product to cart' type of functionality.  Personally, I'd prefer to start light and add functionality than start heavy and strip back.

    I love Tea Commerce, and the beauty of it is that it's SIMPLE, but I've found that with TC2 the simplicity is very hidden and things seem more complicated than (a) they are, and (b) they used to be with TC1, when actually it's probably simpler than TC1.

    Just my two cents anyhow.  I know you guys are busy and this will all fall into place eventually. :)

  • Rune Grønkjær 1372 posts 3103 karma points
    Jul 15, 2013 @ 14:09
    Rune Grønkjær
    0

    Cool. Thanks for the great feedback. We really appreciate it bad and/or good.

    The plan is more documentation as part of the Tea Commerce training courses we are preparing. They will go hand in hand.

    /Rune

  • Anders Burla 2560 posts 8256 karma points
    Aug 05, 2013 @ 14:04
    Anders Burla
    0

    Hi Dan

    What do you think the functionality should be of such a simpler package?

    And would you maybe create it? :)
    If its a much simpler solution maybe it would be quick for you to create it.

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft