Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Kenny Burns 173 posts 305 karma points
    Jan 30, 2012 @ 17:36
    Kenny Burns
    0

    Get a custom property value in .NET

    Hi Guys,

    I have been trying to get this working but I think I am doing something wrong. Basically, i have a custom property on a product called "OVERIDE_VAT" and I am trying to get this value in a function.

    So my function is saying:

    Public Function CalculateTax(ByVal product As UCommerce.EntitiesV2.Product, ByVal priceGroup As UCommerce.EntitiesV2.PriceGroup, ByVal unitPrice As UCommerce.EntitiesV2.PriceGroupPrice) As UCommerce.Money Implements ITaxService.CalculateTax


    Dim taxAmount As Decimal = 0
    Dim taxExempt As String = product("OVERIDE_VAT").Value ??

    ' I want to say if taxExempt return 0 else return something else

    End Function

    Please help!

    Kenny

     

     

  • Kenny Burns 173 posts 305 karma points
    Jan 31, 2012 @ 09:52
    Kenny Burns
    1

    Doh! Sorry don't mind me! It was pretty much what i had - posted below in case anyone else needs it.

    Public Function CalculateTax(ByVal product As UCommerce.EntitiesV2.Product, ByVal priceGroup As UCommerce.EntitiesV2.PriceGroup, ByVal unitPrice As UCommerce.EntitiesV2.PriceGroupPrice) As UCommerce.Money Implements ITaxService.CalculateTax

                Dim taxAmount As Decimal = 0

                Try
                    If product.IsVariant Then

                        If Not product("OVERIDE_VAT").Value Is Nothing Then
                            If product.ParentProduct("OVERIDE_VAT").Value = False Then
                                taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
                            End If
                        Else
                            taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
                        End If


                    Else

                        If Not product("OVERIDE_VAT").Value Is Nothing Then
                            If product("OVERIDE_VAT").Value = False Then
                                taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
                            End If
                        Else
                            taxAmount = product.GetPrice(priceGroup).Price * priceGroup.VATRate
                        End If
                    End If
                Catch

                End Try


                Return New Money(taxAmount, CultureInfo.InvariantCulture, priceGroup.Currency)

            End Function

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jan 31, 2012 @ 10:18
    Søren Spelling Lund
    0

    Thanks for posting your solution. Appreciate it!

    Love the "If Not Is Nothing" double negative of VB by the way. Almost forgot about that :)

Please Sign in or register to post replies

Write your reply to:

Draft