QuadComm e-commerce solutions
Home
Paypal

Shipping charge applied in some cases when ordering just a gift certificate

SYMPTOMS

When placing an order with just a gift certificate in the cart, in some circumstances like when using a flat fee shipping charge this may also be applied to the gift certificate.

VERSIONS AFFECTED

Q-Shop Pro and Lite v3.5.0 and 3.5.1.

CAUSE

Shipping charges are applied using the order cost and this doesn't distinguish whether the order is "virtual" i.e. there are no shippable products.

RESOLUTION

Follow these 2 simple steps:

1. Edit inc/catfunc.asp and add the code:

'=========================================================================
' Function: IsVirtualCart
' Check whether the cart only contains virtual elements (just gift certs
etc)
' Returns True if the cart is "virtual"
'=========================================================================
Function IsVirtualCart
	Dim rsCart, sql
	Dim nItems
	Dim bGiftCert_IsInCart

	IsVirtualCart = False
	
	If IsProVersion Then	'Check only on Pro version since it can only
be the case in Pro

		'Check whether there is a gift certificate in the cart
		bGiftCert_IsInCart = GiftCert_IsInCart
		
		'If there is a gift cert in cart
		If bGiftCert_IsInCart Then
		
			'Since there is a gift cert then check for shippable
products:
			Set rsCart = Server.CreateObject("ADODB.Recordset")
			sql = "SELECT COUNT(*) FROM Carts WHERE CartID = '"
& ParseInj(CartID) & "'"
			rsCart.Open sql,Conn, adOpenStatic, adLockOptimistic

			
			'Check if the cart is empty and update IsCartEmpty accordingly
			If rsCart.EOF AND rsCart.BOF Then 
				nItems = 0
			Else
				nItems = rsCart(0)
				'Close cart
				rsCart.Close
			End If
			set rsCart = nothing
		
			'If there are no shippable items in the cart but there is a soft good then return true
			If nItems = 0 Then IsVirtualCart = True
		
		End If
		
	End If

End Function

2. Edit inc/shipping and at the end add:

'If the order only contains virtual products set shipping charge to 0 If IsVirtualCart Then ShipCost = 0 

Boost your sales with Web Marketing Today Premium Edition