File: D:/web/hyperflight/! previous changes 2/2025-09-08/new/a/customutils-delivery.asp
<!--#include file="customutils-delivery-charge-class.asp"-->
<%
' ========================
' customutils-delivery.asp
' ========================
' Version 1.00 (24/07/25)
' ============
' HISTORY
' ============
' (SS,24/07/25) First used, included from customutils.asp used for new HyperFlight delivery calculation
' Makes used of new customutils-delivery-charge-class.asp
' (SS,02/09/25) Change to Function CustomGetDeliveryCharge (no longer passing on InGoogleShoppingDataFeed to oDeliveryCharge)
' adjustable delivery cost calculation constants
Const TRACKING_MANDATORY_VALUE = 250 ' i.e. £250 excluding VAT
' (SS,7/4/25)
'Const ROYAL_MAIL_MAX_WEIGHT_UK_MAIN = 100
' (SS,3/6/25) changed from 100 to 250 because we're now including packaging
Const ROYAL_MAIL_MAX_WEIGHT_UK_MAIN = 250
' (SS,21/7/25) £3 excluding VAT for UK, £5 for international, used by GetMarkupTotal
Const ROYAL_MAIL_MIN_CHARGE_UK = 3
Const ROYAL_MAIL_MIN_CHARGE_INTERNATIONAL = 5
Const ROYAL_MAIL_LARGE_LETTER_MAX_WEIGHT = 250 ' (SS,12/6/25)
Const ROYAL_MAIL_MAX_WEIGHT_UK_ISLANDS = 20000
Const ROYAL_MAIL_MAX_WEIGHT_INTERNATIONAL = 2000
'Const ROYAL_MAIL_MAX_BOX_LENGTH = 60
' (SS,7/7/25) maximum order value limit for using Royal Mail
Const ROYAL_MAIL_VALUE_LIMIT = 500
Const RC_MODEL_HEAVY_REF_WEIGHT = 1500
Const RC_MODEL_WEIGHT_ADJUSTMENT_FACTOR = 0.3
'Const POSTAL_TUBE_90_OR_LESS_MIN_WEIGHT = 500
'Const POSTAL_TUBE_90_OR_LESS_ADD_DELIVERY_CHARGE = 1
'Const POSTAL_TUBE_91_OR_MORE_MIN_WEIGHT = 2000
'Const POSTAL_TUBE_91_OR_MORE_ADD_DELIVERY_CHARGE = 2
Const POSTAL_TUBE_90_OR_ADDITIONAL_WEIGHT = 500
'Const POSTAL_TUBE_90_OR_LESS_ADD_DELIVERY_CHARGE = 1
Const POSTAL_TUBE_91_OR_MORE_ADDITIONAL_WEIGHT = 1000
'Const LIPO_UK_MIN_WEIGHT = 100
'Const LIPO_NON_UK_MIN_WEIGHT = 1500
Const ROYAL_MAIL_WEIGHT_ADJUST_RATIO = 1.5
'Const ROYAL_MAIL_COST_ADJUST_RATIO = 1.2
'Const MINIMUM_UK_DELIVERY = 3.00 ' i.e. 3.60 inc VAT
'===============
Const DELIVERY_OPTION_STANDARD = "Standard"
Const DELIVERY_OPTION_TRACKED = "Tracked"
Const DELIVERY_OPTION_EXPEDITED = "Expedited"
Const DELIVERY_AGENT_ROYAL_MAIL = "Royal Mail"
Const DELIVERY_AGENT_WEBSHIP = "WebShip"
Const DELIVERY_COURIER_ROYAL_MAIL = "Royal Mail"
Const DELIVERY_COURIER_DHL = "DHL"
Const DELIVERY_COURIER_FEDEX = "FedEx"
Const DELIVERY_COURIER_UPS = "UPS"
Const DELIVERY_SERVICE_ROYAL_MAIL_UK = "CRL24"
Const DELIVERY_SERVICE_ROYAL_MAIL_NON_UK_STANDARD = "OLA"
Const DELIVERY_SERVICE_ROYAL_MAIL_NON_UK_TRACKED = "OTA"
Const DELIVERY_SERVICE_OTHER_UK_STANDARD = "STD"
Const DELIVERY_SERVICE_OTHER_UK_TRACKED = "STD"
Const DELIVERY_SERVICE_OTHER_UK_EXPEDITED = "EXP"
Const DELIVERY_SERVICE_OTHER_NON_UK_STANDARD = "STD"
Const DELIVERY_SERVICE_OTHER_NON_UK_TRACKED = "STD"
Const DELIVERY_SERVICE_OTHER_NON_UK_EXPEDITED = "EXP"
' ========================
' customutils-delivery.asp
' ========================
' Version 1.00 (28/03/25)
' ========================
' HISTORY
' ========================
' (SS,28/03/25) First created, separated from customutils.asp, CustomGetDelivery in customutils.asp calls CustomGetDeliveryCharge in this unit
' (SS,14/4/25) following place here instead of inside Function CustomGetDeliveryCharge, to allow a callback
Dim oDeliveryCharge
Function CustomGetDeliveryCharge(ATotalValue, AValueOfNonWeightedGoods, ATotalWeight, AVATContent, ATotalItems, ANormalDeliveryCost, AByPriceDeliveryCost, AByWeightDeliveryCost, APostcode, ARegionCode, ADeliveryRegion, ACountry)
' (SS,14/4/25) set default to Standard if nothing selected or set
' (SS,9/5/25) added "if" to ensure delivery-invoice-check.asp overrides the selections
If Not IsRestoreBasketInternal Then
SetDefaultDeliveryMethod
End If
Set oDeliveryCharge = New cDeliveryCharge
oDeliveryCharge.ObjectName = "oDeliveryCharge" ' used for callback purposes via Eval to calculate box lengths in basket
oDeliveryCharge.IsDataFeedMode = False ' (SS,2/9/25) was InGoogleShoppingDataFeed, this is not going to be used in Google Shopping Data Feed mode (caused an issue while testing)
oDeliveryCharge.TotalValue = ATotalValue
oDeliveryCharge.VATContent = AVATContent
oDeliveryCharge.TotalWeight = ATotalWeight
'oDeliveryCharge.LegacyNormalDeliveryCharge = ANormalDeliveryCost
oDeliveryCharge.RegionCode = ARegionCode
oDeliveryCharge.Country = ACountry
oDeliveryCharge.Calculate
' save the total adjusted weight to order if different to original
' (SS,16/5/25) removed following, replaced with SetEstimatedGrossWeight further below, this saves in new EstimatedGrossWeight field instead
'If oDeliveryCharge.WeightAdjusted Then
' SetAdjustedTotalWeight(oDeliveryCharge.TotalAdjustedWeight)
'End If
' alert if error
If oDeliveryCharge.Error Then
SetAlertMessage(oDeliveryCharge.ErrorMessage)
End If
' save the priority (to later save in order record)
SetPriority oDeliveryCharge.Priority
' set additional fields: DeliveryService, PackageSize, DeliveryAgentName, Courier and DeliveryCalculatedCost
SetDeliveryService oDeliveryCharge.Service
SetPackageSize oDeliveryCharge.PackageSize
SetPackageName oDeliveryCharge.PackageName ' (SS,v18/6/25)
SetDeliveryAgentName oDeliveryCharge.Agent
SetCourier oDeliveryCharge.Courier
SetDeliveryCalculatedCost oDeliveryCharge.DeliveryCalculatedCost ' (SS,19/6/25) changed DeliveryCostFromTable to DeliveryCalculatedCost
SetEstimatedGrossWeight oDeliveryCharge.EstimatedGrossWeight ' (SS,16/5/25)
SetEstimatedVolumetricWeight oDeliveryCharge.EstimatedVolumetricWeight ' (SS,25/6/25)
Dim LDeliveryOption
If oDeliveryCharge.IsExpedited Then
LDeliveryOption = "Expedited"
SetExpeditedDeliverySelected True
ElseIf oDeliveryCharge.IsTracked Then
LDeliveryOption = "Tracked"
If oDeliveryCharge.IsTrackedAuto Then
LDeliveryOption = LDeliveryOption + " - auto"
Else
LDeliveryOption = LDeliveryOption + " - selected"
End If
SetTrackedDeliverySelected True
Else ' i.e. Standard (was Untracked)
LDeliveryOption = "Standard"
End If
SetDeliveryOption LDeliveryOption
' set the values for the checkbox allowed, i.e. disable or not
SetStandardDeliverySelectionAllowed Not oDeliveryCharge.IsTrackedAuto
SetTrackedDeliverySelectionAllowed True
SetExpeditedDeliverySelectionAllowed True
If IsBasketPage And CustomIsLocalPC Then
oDeliveryCharge.LogTypeHTML = True
Response.Write oDeliveryCharge.DebugLog
End If
' (SS,9/5/25) if invoice checking mode then save some additional values in session for use by delivery-invoice-check.asp
If IsRestoreBasketInternal Then
Session("NewAgent") = oDeliveryCharge.Agent
Session("NewCourier") = oDeliveryCharge.Courier
Session("NewDeliveryOption") = LDeliveryOption
Session("NewService") = oDeliveryCharge.Service
Session("NewPriority") = oDeliveryCharge.Priority
Session("NewPackageSize") = oDeliveryCharge.PackageSize
Session("NewPackageName") = oDeliveryCharge.PackageName
Session("NewTotalWeight") = oDeliveryCharge.TotalWeight
Session("NewEstimatedGrossWeight") = oDeliveryCharge.EstimatedGrossWeight
Session("NewEstimatedVolumetricWeight") = oDeliveryCharge.EstimatedVolumetricWeight
Session("RegionCode") = oDeliveryCharge.RegionCode
Session("DeliveryCalculatedCost") = oDeliveryCharge.DeliveryCalculatedCost
Session("RCModelCount") = oDeliveryCharge.RCModelCount ' (SS,7/7/25)
End If
CustomGetDeliveryCharge = oDeliveryCharge.DeliveryCharge
Set oDeliveryCharge = Nothing
End Function
%>