Negative options displayed incorrectly


https://forum.kartris.com/Topic3246.aspx
Print Topic | Close Window

By Tiggywiggler - Tue 12 Aug 2014
If you have set a negative offset option (e.g. having an option that has a value adjustment below zero such as -10.00) the options drop down on the product page will show the option in a strange way. It will show a positive change (increased cost) as:

+ £10.00

But it would show a negative change (discounted cost) as:

+ £-10.00

The code below fixes this and is found in [Options.ascx] within the [NewItem()] routine found on line 131.


Public Sub NewItem(ByVal pItemText As String, ByVal pItemValue As String, _
Optional ByVal pItemPriceChange As Single = 0, Optional ByVal pIsSelected As Boolean = False, _
Optional ByVal pChangePriceOnSelection As Boolean = True)

Dim itemListOptions As New ListItem(pItemText, pItemValue)
Dim itemListOptionsPrice As New ListItem(pItemText & "-" & CStr(pItemPriceChange), pItemPriceChange)
Dim strPriceFormatted As String = ""
Dim strPriceToFormat As String = ""

_ChangePricesOnSelection = pChangePriceOnSelection

'' The next -IF Statement- will change the price amount regarding the current Currency.
If pItemPriceChange <> 0 Then

'' Convert the Price Amount to the current Currency,
'' and then Rounding to 2 digits after the decimal point.
itemListOptionsPrice.Value = CurrenciesBLL.ConvertCurrency(Session("CUR_ID"), pItemPriceChange)

strPriceToFormat = itemListOptionsPrice.Value

If _ChangePricesOnSelection Then
' If the price changes on selection we will be adding a prefix to the displayed text and so we do not want
' the sign in the number that will be passed into CurrenciesBLL.FormatCurrencyPrice() so remove it here.
strPriceToFormat = CurrenciesBLL.ConvertCurrency(Session("CUR_ID"), Math.Abs(pItemPriceChange))
End If

strPriceFormatted = CurrenciesBLL.FormatCurrencyPrice( _
Session("CUR_ID"), strPriceToFormat, , _OptionType <> "DropDown")

'' Changing the display text to the user with the amount increased if this option is selected.
If _ChangePricesOnSelection Then itemListOptions.Text += Space(3) & "(" & IIf(pItemPriceChange < 0, "-", "+") & " " & strPriceFormatted & ")"
End If
If pIsSelected Then
_Control.ClearSelection()
itemListOptions.Selected = pIsSelected
End If

'itemListOptions.Selected = pIsSelected

_Control.Items.Add(itemListOptions)

'If only one option, then we will see a checkbox. In v1.3
'and earlier, this would effectively make the 'optional'
'setting for this option irrelevant, as a checkbox input
'can be left unchecked to indicate a selection of 'no'.
'From 1.4 onwards, we interpret a single option which is
'not optional (i.e. required) as the option being selected.
'This way, you can set up a product as an options product
'even if this is only one option to begin with (e.g. size)
'but make this single size selection required. Or you can
'use it to emphasize something that is included with a
'product and cannot be removed.
If _Mandatory And _OptionType = "Check" Then
_Control.Items(0).Selected = True
_Control.Items(0).Enabled = False
End If

_ControlPrice.Items.Add(itemListOptionsPrice)

If pIsSelected Then indxChanged(Me, New EventArgs)

End Sub
By Tiggywiggler - Fri 15 Aug 2014
Main post is its own answer. this post is to mark as complete
By Paul - Sat 16 Aug 2014
Thanks, we should have this in the next release too.