1724808; #--------------------------------------------------------------- my $pMessageList = [ 'The shipping price is formatted incorrectly. It should be formatted like %s.', 'The shipping price is too large. The price must be less than %s.', 'The shipping price is too small. The price must be greater than or equal to %s.', 'The class/location combination you selected were invalid. Please check and re-enter your selection.', 'The catalog shipping database does not have any shipping options defined for this location. Please contact us directly with your order.', 'Free Shipping', 'Standard Shipping', 'Your order has exceeded the shipping tables defined by the supplier, therefore it is not possible to calculate the shipping cost. Please contact the supplier with this information as they will be happy to process your order and will then be able to correct the shipping tables.
Thank you.', 'Please enter a shipping cost.', 'Please select a state or province.', ]; my %ZoneTable = ( "UK" => { "UndefinedRegion" => [1], }, "US" => { "UndefinedRegion" => [4], "US.AL" => [4], "US.AK" => [4], "US.AS" => [4], "US.AZ" => [4], "US.AR" => [4], "US.CA" => [4], "US.CO" => [4], "US.CT" => [4], "US.DE" => [4], "US.DC" => [4], "US.FL" => [4], "US.GA" => [4], "US.GU" => [4], "US.HI" => [4], "US.ID" => [4], "US.IL" => [4], "US.IN" => [4], "US.IA" => [4], "US.KS" => [4], "US.KY" => [4], "US.LA" => [4], "US.ME" => [4], "US.MH" => [4], "US.MD" => [4], "US.MA" => [4], "US.MI" => [4], "US.FM" => [4], "US.MN" => [4], "US.MS" => [4], "US.MO" => [4], "US.MT" => [4], "US.MP" => [4], "US.NE" => [4], "US.NV" => [4], "US.NH" => [4], "US.NJ" => [4], "US.NM" => [4], "US.NY" => [4], "US.NC" => [4], "US.ND" => [4], "US.OH" => [4], "US.OK" => [4], "US.OR" => [4], "US.PW" => [4], "US.PA" => [4], "US.PR" => [4], "US.RI" => [4], "US.SC" => [4], "US.SD" => [4], "US.TN" => [4], "US.TX" => [4], "US.TT" => [4], "US.UT" => [4], "US.VT" => [4], "US.VI" => [4], "US.VA" => [4], "US.WA" => [4], "US.WV" => [4], "US.WI" => [4], "US.WY" => [4], }, "CA" => { "UndefinedRegion" => [4], "CA.AB" => [4], "CA.BC" => [4], "CA.MB" => [4], "CA.NB" => [4], "CA.NF" => [4], "CA.NT" => [4], "CA.NS" => [4], "CA.ON" => [4], "CA.PE" => [4], "CA.PQ" => [4], "CA.SK" => [4], "CA.YT" => [4], }, ); my %ShippingTable = ( ); my ($DefaultWeight, $ShippingBasis, $SimpleCost, $UnknownRegion, $UnknownRegionCost, $WaiveCharges, $WaiveThreshold); $DefaultWeight = 0.25; $ShippingBasis = 'Simple'; $SimpleCost = 350; $UnknownRegion = 'Default'; $UnknownRegionCost = 300; $WaiveCharges = 'No'; $WaiveThreshold = 100000.000000; my %ClassTable = ( ); my $nHandlingCharge = 0; my $nHandlingProportion = 0; my %ParentZoneTable = ( "US" => [], "CA" => [], ); use strict; no strict 'refs'; my $UNDEFINED = 'UndefinedRegion'; %::s_Ship_nShippingStatus = (); %::s_Ship_sShippingError = (); %::s_Ship_PreliminaryInfoVariables = (); %::s_Ship_ShippingVariables = (); $::s_Ship_bPrelimIsHidden = $::FALSE; $::s_Ship_bShipPhaseIsHidden = $::FALSE; $::s_Ship_sShippingDescription = ''; $::s_Ship_sHandlingDescription = ''; # not used in this plug-in $::s_Ship_sShippingCountryName = ''; $::s_Ship_nShipCharges = 0; $::s_Ship_nShippingStatus{GetHandlingDescription} = $::SUCCESS; $::s_Ship_sShippingError{GetHandlingDescription} = ''; my @Response = ValidatePreliminaryInput(); $::s_Ship_nShippingStatus{ValidatePreliminaryInput} = $Response[0]; $::s_Ship_sShippingError{ValidatePreliminaryInput} = $Response[1]; @Response = ValidateFinalInput(); $::s_Ship_nShippingStatus{ValidateFinalInput} = $Response[0]; $::s_Ship_sShippingError{ValidateFinalInput} = $Response[1]; @Response = RestoreFinalUI(); $::s_Ship_nShippingStatus{RestoreFinalUI} = $Response[0]; $::s_Ship_sShippingError{RestoreFinalUI} = $Response[1]; @Response = CalculateShipping(); $::s_Ship_nShippingStatus{CalculateShipping} = $Response[0]; $::s_Ship_sShippingError{CalculateShipping} = $Response[1]; @Response = IsFinalPhaseHidden(); $::s_Ship_nShippingStatus{IsFinalPhaseHidden} = $Response[0]; $::s_Ship_sShippingError{IsFinalPhaseHidden} = $Response[1]; @Response = GetShippingDescription(); $::s_Ship_nShippingStatus{GetShippingDescription} = $Response[0]; $::s_Ship_sShippingError{GetShippingDescription} = $Response[1]; @Response = CalculateHandling(); $::s_Ship_nShippingStatus{CalculateHandling} = $Response[0]; $::s_Ship_sShippingError{CalculateHandling} = $Response[1]; return($::SUCCESS); sub ValidatePreliminaryInput { if ($ShippingBasis eq 'Simple') { return($::SUCCESS, undef); } if ($::s_sDeliveryRegionCode eq "" || $::s_sDeliveryRegionCode eq $UNDEFINED) { if (defined $ParentZoneTable{$::s_sDeliveryCountryCode} && $#{$ParentZoneTable{$::s_sDeliveryCountryCode}} == -1) { return ($::FAILURE, $$pMessageList[9]); } } my @bands = GetBands(); if ($#bands < 0 && $UnknownRegion ne 'Default') { return($::FAILURE, $$pMessageList[4]); } my ($j, $bFound); $bFound = $::FALSE; OUT: for $j (0 .. $#bands) { my ($Class, $pBandList); while ( ($Class, $pBandList) = each %ShippingTable) { if( defined ${$pBandList}{$bands[$j]} ) { my @costs = @ { ${$pBandList}{$bands[$j]} }; if ($#costs > 0) { $bFound = $::TRUE; last OUT; } } } } my ($Temp); $Temp = keys %ShippingTable; if (!$bFound && $UnknownRegion ne 'Default') { return($::FAILURE, $$pMessageList[3]); } my ($status, $sMessage, %ShipData, @listTemp); ($status, $sMessage, @listTemp) = UnpackData(); if ($status != $::SUCCESS) { return($status, $sMessage); } if ($#listTemp > -1) { %ShipData = @listTemp; } if (exists $ShipData{ShippingZone}) { my $nZoneID; my $bFoundZone = $::FALSE; foreach $nZoneID (@bands) { if ($ShipData{ShippingZone} == $nZoneID) { $bFoundZone = $::TRUE; last; } } if (!$bFoundZone) { undef $::s_Ship_sOpaqueShipData; } } return($::SUCCESS, undef); } sub ValidateFinalInput { if ($ShippingBasis eq 'Simple') { my (@Response); if ($::g_InputHash{SHIPPING}) { $::g_InputHash{SHIPPING} =~ s/^\s*(.*?)\s*$/$1/gs; } if (defined $::g_InputHash{SHIPPING}) { my $sText = (0 == length $::g_InputHash{SHIPPING}) ? ' ' : $::g_InputHash{SHIPPING}; $::s_Ship_sOpaqueShipData = sprintf("Simple;Error-%s;", $sText); } if (!defined $::g_InputHash{'SHIPPING'} ||# if the shipping is undefined, error out length $::g_InputHash{'SHIPPING'} == 0) { return($::FAILURE, $$pMessageList[8]); } @Response = ActinicOrder::ReadPrice($::g_InputHash{SHIPPING}, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS || $Response[2] != int $Response[2]) { @Response = ActinicOrder::FormatSinglePrice(10000, $::FALSE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { return($Response[0], $Response[1]); } return($::FAILURE, sprintf($$pMessageList[0], $Response[2])); } my ($nMaxShipping) = 99999999; if ($Response[2] >= $nMaxShipping) { @Response = ActinicOrder::FormatPrice($nMaxShipping, $::TRUE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { return($Response[0], $Response[1]); } return($::FAILURE, sprintf($$pMessageList[1], $Response[2])); } my ($nMinShipping) = 0; if ($Response[2] < $nMinShipping) { @Response = ActinicOrder::FormatPrice($nMinShipping, $::TRUE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { return($Response[0], $Response[1]); } return($::FAILURE, sprintf($$pMessageList[2], $Response[2])); } if (defined $::g_InputHash{SHIPPING}) { $::s_Ship_sOpaqueShipData = sprintf("Simple;%s;", $Response[2]); } return($::SUCCESS, undef); } my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { return($status, $sMessage); } if (!defined $::s_sDeliveryCountryCode || !defined $::s_sDeliveryRegionCode) { return($::SUCCESS, undef); } if (!defined $::g_InputHash{'ShippingClass'}) { my ($status, $sMessage, $pOptionTitleList, $pOptionIDList) = FormatShippingOptions(%ShipData); if ($status != $::SUCCESS) { return($status, $sMessage); } if ($#{$pOptionIDList} == 0) { $::g_InputHash{'ShippingClass'} = ${$pOptionIDList}[0]; } } if ($::g_InputHash{'ShippingClass'} eq "") { return($::SUCCESS, undef); } my @bands = GetBands(); if ($#bands < 0 && $UnknownRegion ne 'Default') { return($::FAILURE, $$pMessageList[4]); } my @costs; my $j; my $nZoneID = -1; for $j (0 .. $#bands) { @costs = @ {$ShippingTable{$::g_InputHash{'ShippingClass'}}{$bands[$j]}}; if ($#costs > 0) { $nZoneID = $bands[$j]; last; } } $::s_Ship_sOpaqueShipData = sprintf("ShippingClass;%s;ShippingZone;%d;", $::g_InputHash{'ShippingClass'}, $nZoneID); if ($WaiveCharges eq 'Value') { if (CalculatePrice() > $WaiveThreshold) { return($::SUCCESS, undef); } } if ($#costs <= 0) { if ($UnknownRegion eq 'Default') { return($::SUCCESS, undef); } return($::FAILURE, $$pMessageList[3]); } my ($totalWeight); if ($ShippingBasis eq 'Quantity') { $totalWeight = CalculateQuantity(); } elsif ($ShippingBasis eq 'Price') { $totalWeight = CalculatePrice(); } else { $totalWeight = CalculateWeight(); } for $j (0 .. $#costs) { if ($costs[$j]{wt} >= $totalWeight) { return($::SUCCESS, undef); } } if ($costs[0]{'ExcessAction'} eq 'Highest' || $costs[0]{'ExcessAction'} eq 'AddFurther') { return($::SUCCESS, undef); } return($::FAILURE, $$pMessageList[7]); } sub UnpackData { my (@arglist); @arglist = split (';', $::s_Ship_sOpaqueShipData); return ($::SUCCESS, "", @arglist); } sub IsFinalPhaseHidden { my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { return($status, $sMessage); } if ($ShippingBasis eq 'Simple') { return($::SUCCESS, undef); } my ($pOptionTitleList, $pOptionIDList); ($status, $sMessage, $pOptionTitleList, $pOptionIDList) = FormatShippingOptions(%ShipData); if ($status != $::SUCCESS) { return($status, $sMessage); } if ($#{$pOptionIDList} == 0) { my @bands = GetBands(); if ($#bands < 0 && $UnknownRegion ne 'Default') { return($::FAILURE, $$pMessageList[4]); } my @costs; my $j; my $nZoneID = -1; for $j (0 .. $#bands) { @costs = @ {$ShippingTable{${$pOptionIDList}[0]}{$bands[$j]}}; if ($#costs > 0) { $nZoneID = $bands[$j]; last; } } $::s_Ship_bShipPhaseIsHidden = $::TRUE; $::s_Ship_sOpaqueShipData = sprintf("ShippingClass;%s;ShippingZone;%d;", ${$pOptionIDList}[0], $nZoneID); } return($::SUCCESS, undef); } sub RestoreFinalUI { my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { return($status, $sMessage); } if ($ShippingBasis eq 'Simple') { my (@Response); if (!defined $ShipData{'Simple'}) { @Response = ActinicOrder::FormatSinglePrice($SimpleCost, $::TRUE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { return($Response[0], $Response[1]); } $::s_Ship_ShippingVariables{"NETQUOTEVAR:SHIPPINGVALUE"} = $Response[2]; } elsif($ShipData{'Simple'} =~ /Error-/) { $ShipData{'Simple'} =~ s/^Error-\s*(.*?)\s*$/$1/g; $::s_Ship_ShippingVariables{"NETQUOTEVAR:SHIPPINGVALUE"} = $ShipData{'Simple'}; } else { $ShipData{'Simple'} =~ s/^\s*(.*?)\s*$/$1/g; @Response = ActinicOrder::FormatSinglePrice($ShipData{'Simple'}, $::TRUE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { return($Response[0], $Response[1]); } $::s_Ship_ShippingVariables{"NETQUOTEVAR:SHIPPINGVALUE"} = $Response[2]; } return($::SUCCESS, undef); } my ($pOptionTitleList, $pOptionIDList); ($status, $sMessage, $pOptionTitleList, $pOptionIDList) = FormatShippingOptions(%ShipData); if ($status != $::SUCCESS) { return($status, $sMessage); } my ($sShippingControl); my ($ClassID, $sOptionTitle, $nIndex); $nIndex = 0; if ($#{$pOptionIDList} == 0) { $sOptionTitle = ${$pOptionTitleList}[0]; $sShippingControl .= "$sOptionTitle\n"; } else { $sShippingControl = "\n"; } $::s_Ship_ShippingVariables{$::VARPREFIX . 'SHIPPINGSELECT'} = $sShippingControl; return($::SUCCESS, undef); } sub FormatShippingOptions { my (%ShipData) = @_; if ($ShippingBasis eq 'Simple') { return ($::SUCCESS, "", undef, undef); } if (defined @::s_FormattedShippingOptionList) { return ($::SUCCESS, "", \@::s_FormattedShippingOptionList, \@::s_AssociatedClassIDs); } my %ClassCostMap; my $bConstantCost = $::FALSE; my $nConstantCost = 0; my $nClassCount = 0; if ($WaiveCharges eq 'Value' && CalculatePrice() > $WaiveThreshold) { $bConstantCost = $::TRUE; } else { my @bands = GetBands(); if ($#bands < 0) { if ($UnknownRegion ne 'Default') { return($::FAILURE, $$pMessageList[4], undef, undef); } else { $bConstantCost = $::TRUE; $nConstantCost = $UnknownRegionCost; } } else { my $j; my %ValidClasses; for $j (0 .. $#bands) { my ($Class, $pBandList); while ( ($Class, $pBandList) = each %ShippingTable) { if( defined ${$pBandList}{$bands[$j]} ) { my @costs = @ {${$pBandList}{$bands[$j]}}; if ($#costs > 0) { $ValidClasses{$Class} = $::TRUE; } } } my ($Temp); $Temp = keys %ShippingTable; } $nClassCount = keys %ValidClasses; if ($nClassCount < 1) { if ($UnknownRegion ne 'Default') { return ($::FAILURE, $$pMessageList[3], undef, undef); } else { $bConstantCost = $::TRUE; $nConstantCost = $UnknownRegionCost; } } if (!$bConstantCost) { my ($totalWeight); if ($ShippingBasis eq 'Quantity') { $totalWeight = CalculateQuantity(); } elsif ($ShippingBasis eq 'Price') { $totalWeight = CalculatePrice(); } else { $totalWeight = CalculateWeight(); } my ($Class, $null); while ( ($Class, $null) = each %ValidClasses) { my @costs; my $j; for $j (0 .. $#bands) { @costs = @ {$ShippingTable{$Class}{$bands[$j]}}; if ($#costs > 0) { last; } } my $bFound = $::FALSE; my $nCost = 0; for $j (0 .. $#costs) { if ($costs[$j]{wt} >= $totalWeight && defined $costs[$j]{cost}) { $nCost = $costs[$j]{cost}; $bFound = $::TRUE; last; } } if (!$bFound) { if ($costs[0]{'ExcessAction'} eq 'Highest') { $nCost = $costs[$#costs]{cost}; $bFound = $::TRUE; } elsif ($costs[0]{'ExcessAction'} eq 'AddFurther') { my $extraWeight = $totalWeight - $costs[$#costs]{wt}; my ($dWeightIncrement, $nChargeIncrement) = ($costs[0]{'IncrementalWeight'}, $costs[0]{'IncrementalCharge'}); my ($nExtraUnits) = int ($extraWeight / $dWeightIncrement + 0.999); my $extraCharge = $nExtraUnits * $nChargeIncrement; $nCost = $costs[$#costs]{cost} + $extraCharge;# Take the biggest cost from the band + the extra $bFound = $::TRUE; } else { $nCost = 0; $bFound = $::FALSE; } } if ($bFound) { $ClassCostMap{$Class} = $nCost; } } $nClassCount = keys %ClassCostMap; if ($nClassCount < 1) { return ($::FAILURE, $$pMessageList[7], undef, undef); } } } } if ($bConstantCost) { if ($nConstantCost == 0) { push (@::s_FormattedShippingOptionList, $$pMessageList[5]); push (@::s_AssociatedClassIDs, 1); } else { if ($::s_Ship_bDisplayPrices) { my (@PriceResponse) = ActinicOrder::FormatPrice($nConstantCost, $::TRUE, \%::s_Ship_PriceFormatBlob); push (@::s_FormattedShippingOptionList, $$pMessageList[6] . " (" . $PriceResponse[2] . ")"); } else { push (@::s_FormattedShippingOptionList, $$pMessageList[6]); } push (@::s_AssociatedClassIDs, 1); } } else { my (@ClassIDs) = sort { $ClassCostMap{$a} <=> $ClassCostMap{$b} } keys %ClassCostMap; if ($nClassCount == 1) { my ($sClassName) = $ClassTable{$ClassIDs[0]}; if ($::s_Ship_bDisplayPrices) { my (@PriceResponse) = ActinicOrder::FormatPrice($ClassCostMap{$ClassIDs[0]}, $::TRUE, \%::s_Ship_PriceFormatBlob); push (@::s_FormattedShippingOptionList, "$sClassName (" . $PriceResponse[2] . ")"); } else { push (@::s_FormattedShippingOptionList, "$sClassName"); } push (@::s_AssociatedClassIDs, $ClassIDs[0]); } else { my ($ClassID, $sClassName); foreach $ClassID (@ClassIDs) { $sClassName = $ClassTable{$ClassID}; if ($::s_Ship_bDisplayPrices) { my (@PriceResponse) = ActinicOrder::FormatPrice($ClassCostMap{$ClassID}, $::TRUE, \%::s_Ship_PriceFormatBlob); push (@::s_FormattedShippingOptionList, "$sClassName (" . $PriceResponse[2] . ")"); } else { push (@::s_FormattedShippingOptionList, "$sClassName"); } push (@::s_AssociatedClassIDs, $ClassID); } } } return ($::SUCCESS, "", \@::s_FormattedShippingOptionList, \@::s_AssociatedClassIDs); } sub GetShippingDescription() { my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { return($status, $sMessage); } my ($pOptionTitleList, $pOptionIDList); ($status, $sMessage, $pOptionTitleList, $pOptionIDList) = FormatShippingOptions(%ShipData); if ($status != $::SUCCESS) { return($status, $sMessage); } if ($#{$pOptionTitleList} == 0) { $::s_Ship_sShippingDescription = ${$pOptionTitleList}[0]; $::s_Ship_sShippingDescription =~ s/([^(]*).*/$1/; $::s_Ship_sShippingDescription =~ s/\s*$//; } else { $::s_Ship_sShippingDescription = $ClassTable{$ShipData{'ShippingClass'}}; } return($::SUCCESS, undef); } sub CalculateShipping() { my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { return($status, $sMessage); } if ($ShippingBasis eq 'Simple') { if (!defined $ShipData{'Simple'} || $ShipData{'Simple'} =~ /Error-/) { $::s_Ship_nShipCharges = 0; } else { $::s_Ship_nShipCharges = $ShipData{'Simple'}; } return($::SUCCESS, undef); } if (!defined $::s_Ship_sOpaqueShipData || length $::s_sDeliveryCountryCode == 0 || length $::s_sDeliveryRegionCode == 0 || length $ShipData{'ShippingClass'} == 0) { $::s_Ship_nShipCharges = 0; return($::SUCCESS, undef); } if ($WaiveCharges eq 'Value') { if (CalculatePrice() > $WaiveThreshold) { $::s_Ship_nShipCharges = 0; return ($::SUCCESS, undef); } } my @bands = GetBands(); my @costs; my $j; for $j (0 .. $#bands) { @costs = @ {$ShippingTable{$ShipData{'ShippingClass'}}{$bands[$j]}}; if ($#costs > 0) { last; } } if ($#costs <= 0) { if ($UnknownRegion eq 'Default') { $::s_Ship_nShipCharges = $UnknownRegionCost; return ($::SUCCESS, undef); } return($::SUCCESS, undef); } my ($totalWeight, $extraWeight, $extraCharge); if ($ShippingBasis eq 'Quantity') { $totalWeight = CalculateQuantity(); } elsif ($ShippingBasis eq 'Price') { $totalWeight = CalculatePrice(); } else { $totalWeight = CalculateWeight(); } if (!defined $totalWeight) { $::s_Ship_nShipCharges = 0; return($::SUCCESS, undef); } for $j (0 .. $#costs) { if ($costs[$j]{wt} >= $totalWeight && defined $costs[$j]{cost}) { $::s_Ship_nShipCharges = $costs[$j]{cost}; return($::SUCCESS, undef); } } if ($costs[0]{'ExcessAction'} eq 'Highest') { $::s_Ship_nShipCharges = $costs[$#costs]{cost}; return($::SUCCESS, undef); } if ($costs[0]{'ExcessAction'} eq 'AddFurther') { $extraWeight = $totalWeight - $costs[$#costs]{wt}; my ($dWeightIncrement, $nChargeIncrement) = ($costs[0]{'IncrementalWeight'}, $costs[0]{'IncrementalCharge'}); my ($nExtraUnits) = int ($extraWeight / $dWeightIncrement + 0.999); $extraCharge = $nExtraUnits * $nChargeIncrement; $::s_Ship_nShipCharges = $costs[$#costs]{cost} + $extraCharge;# Take the biggest cost from the band + the extra return($::SUCCESS, undef); } $::s_Ship_nShipCharges = $costs[$#costs]{cost}; return($::FAILURE, $$pMessageList[7]); } sub GetBands { if ($::s_sDeliveryRegionCode eq "" || $::s_sDeliveryRegionCode eq $UNDEFINED) { if ($#{$ParentZoneTable{$::s_sDeliveryCountryCode}} != -1) { return (@{$ParentZoneTable{$::s_sDeliveryCountryCode}}); # return this list (has invalid entries stripped) } } return(@{ $ZoneTable{$::s_sDeliveryCountryCode}{$::s_sDeliveryRegionCode} }); } sub CalculateHandling { $::s_Ship_nHandlingCharges = $nHandlingCharge + int ($::s_Ship_nShipCharges * $nHandlingProportion / $ActinicOrder::PERCENTOFFSET); $::s_Ship_sOpaqueHandleData = sprintf("Handling;%d;", $::s_Ship_nHandlingCharges); return ($::SUCCESS, undef); } sub CalculateWeight { my $j; if (defined $::s_Ship_nTotalWeight) { return ($::s_Ship_nTotalWeight); } $::s_Ship_nTotalWeight = 0; for $j (0 .. $#::s_Ship_sShipProducts) { if ("" ne $::s_Ship_OpaqueDataTables{$::s_Ship_sShipProducts[$j]}) { $::s_Ship_nTotalWeight += $::s_Ship_OpaqueDataTables{$::s_Ship_sShipProducts[$j]} * $::s_Ship_nShipQuantities[$j]; } else { $::s_Ship_nTotalWeight += $DefaultWeight * $::s_Ship_nShipQuantities[$j]; } } return($::s_Ship_nTotalWeight); } sub CalculateQuantity { my $j; if (defined $::s_Ship_nTotalQuantity) { return ($::s_Ship_nTotalQuantity); } $::s_Ship_nTotalQuantity = 0; for $j (0 .. $#::s_Ship_nShipQuantities) { $::s_Ship_nTotalQuantity += $::s_Ship_nShipQuantities[$j]; } return($::s_Ship_nTotalQuantity); } sub CalculatePrice { my $j; if (defined $::s_Ship_nTotalPrice) { return ($::s_Ship_nTotalPrice); } if (defined $::s_Ship_nSubTotal) { return ($::s_Ship_nSubTotal); } $::s_Ship_nTotalPrice = 0; for $j (0 .. $#::s_Ship_sShipProducts) { $::s_Ship_nTotalPrice += ($::s_Ship_nShipPrices[$j] * $::s_Ship_nShipQuantities[$j]); } return($::s_Ship_nTotalPrice); } return ($::SUCCESS);