Copied to clipboard

Flag this post as spam?

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


  • MB 273 posts 936 karma points
    Nov 22, 2020 @ 16:44
    MB
    0

    Increase Variant Price by X percentage

    Hey all,

    I would like to increase variant price with a percentage from a property set in Umbraco. I show the price like this:

    TC.GetPrice(1, Model.Content.Id + "_" + variant.VariantIdentifier);
    

    I also made a property on each product category with a Decimal input that increases prices with that amount.

    For a regular price I do the following, where the ThePercentageToIncrease is a decimal property in Umbraco, it works just fine:

    price = (CurrentPage.GetPropertyValue("price") / ThePercentageToIncrease * 100);
    

    But how can I take the variant price and increase it with the decimal property from Umbraco?

    The error I get is:

    Operator '*' cannot be applied to operands of type 'Price' and 'int'
    

    // Mike

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Nov 23, 2020 @ 09:06
    Matt Brailsford
    0

    Hey Mike,

    My guess is because the the price returned from TC is of type Price which is a complex object made up of a pre tax value, a tax value, and a inc-tax value and so a Price can't simply be multiplied. You'll have to multiply the individual parts and construct a new Price value from the results.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft