Copied to clipboard

Flag this post as spam?

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


  • Mikkel Johannsen 32 posts 185 karma points
    Nov 27, 2017 @ 09:12
    Mikkel Johannsen
    0

    Set variant price programatically?

    Hi!

    Does anyone know of any way to set a variant's price programatically?

    For a "master product", this could be done through ContentService, but I'm not really sure how to deal with this for variants, as the variants aren't created as nodes, but are created through a property on the master product.

  • Rune Grønkjær 1372 posts 3103 karma points
    Nov 27, 2017 @ 13:46
    Rune Grønkjær
    100

    The variants in the variant data type are created by the UI javascript and nothing else. The angular scripts create the json that is saved on the product node.

    You might wan't to take a look at how we parse the json into the object structure: https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco/blob/73385ea228a2895d03254dadbfa7676ef21fba10/Source/TeaCommerce.Umbraco.Configuration/Variants/Services/AVariantPublishedContentService.cs It's the ParseVariantJson method that does the parsing. You might just be able to reverse engineer it, to be able to create the json as instead.

    Tea Commerce for Umbraco is open source, and you can download the code at check it out.

    /Rune

  • Mikkel Johannsen 32 posts 185 karma points
    Nov 28, 2017 @ 13:16
    Mikkel Johannsen
    0

    Thank you for your answer :-)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies