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.
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.
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.
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
Thank you for your answer :-)
is working on a reply...