webForumDet fria alternativet

frakt problem

1 svar · 177 visningar · startad av Leon

LeonMedlem sedan nov. 200227 inlägg
#1

Har problem med hur jag ska få det att bli fraktfritt över en viss gräns... här är koden som hämtar fram rätt frakt genom hur mycket alla varor väger tillsammans.

<%
Dim ShippingRS__value
ShippingRS__value = "0"
If (CCcart_Weight <> "") Then
  ShippingRS__value = CCcart_Weight
End If
%>
<%
Dim ShippingRS
Dim ShippingRS_numRows

Set ShippingRS = Server.CreateObject("ADODB.Recordset")
ShippingRS.ActiveConnection = MM_CharonCart_STRING
ShippingRS.Source = "SELECT *  FROM Freight  WHERE weightfrom <= " + Replace(ShippingRS__value, "'", "''") + " AND weightto > " + Replace(ShippingRS__value, "'", "''") + ""
ShippingRS.CursorType = 0
ShippingRS.CursorLocation = 2
ShippingRS.LockType = 1
ShippingRS.Open()

ShippingRS_numRows = 0
%>
<%
'
'Add shipping from a value in a recordset
'And If the value exeeds the session freightlimit sets it to 0
'

CCcart_SubTotal = Replace(CCcart_SubTotal, ",", ".")
Session("Freightlimit") = Replace(Session("Freightlimit"), ",", ".")
If (CCcart_SubTotal >= Session("Freightlimit")) Then
	CCcart_Shipping = 0
	Else
	CCcart_Shipping=ShippingRS.Fields.Item("freight").Value
	End If
%>

sen har jag en session med ett nummer säg, 6000

då vill jag att den kollar mot subtotalen av shoppingcarten...

<%
x=CCcart_SubTotal
y=Session("Freightlimit")
If (x >= y) Then
	CCcart_Shipping = 0
	Else
	CCcart_Shipping=ShippingRS.Fields.Item("freight").Value
	End If
%>

problemet är när jag kör den här koden och det råkar vara en decimal så funkar det ju inte... har aldrig fått det att fungera som det borde... har ni några förslag?!

OveRRidEMedlem sedan feb. 200112 078 inlägg
#2

Det är alltså decimalen du har problem med? Detta kan du väl lätt fixa med funktionen round()? Om du inte behöver decimalen, vill säga. ;)

x=round(CCcart_SubTotal,0)
y=round(Session("Freightlimit"),0)
If (x >= y) Then
	CCcart_Shipping = 0
	Else
	CCcart_Shipping=ShippingRS.Fields.Item("freight").Value
	End If
129 ms totalt · 3 externa anrop · v20260731065814-full.fb544a5a
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
127 ms — hämta tråd, inlägg och bilagor (db)