2709906; #--------------------------------------------------------------- my $pMessageList = [ "Please select a country.", "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 country/region combination you selected is invalid. Please check and re-enter your selection.", "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.", ]; my %CountryMap = ( "UK" => "United Kingdom", "US" => "United States", "AR" => "Argentina", "AU" => "Australia", "AT" => "Austria", "BE" => "Belgium", "BM" => "Bermuda", "BR" => "Brazil", "CA" => "Canada", "CL" => "Chile", "CO" => "Colombia", "CY" => "Cyprus", "DK" => "Denmark", "FI" => "Finland", "FR" => "France", "DE" => "Germany", "GI" => "Gibraltar", "GR" => "Greece", "GL" => "Greenland", "HK" => "Hong Kong", "HU" => "Hungary", "IS" => "Iceland", "IE" => "Ireland", "IL" => "Israel", "IT" => "Italy", "JP" => "Japan", "KR" => "Korea (South)", "LB" => "Lebanon", "LI" => "Liechtenstein", "LU" => "Luxembourg", "MY" => "Malaysia", "MT" => "Malta", "MX" => "Mexico", "MC" => "Monaco", "NL" => "Netherlands", "NZ" => "New Zealand (Aotearoa)", "NO" => "Norway", "PH" => "Philippines", "PL" => "Poland", "PT" => "Portugal", "PR" => "Puerto Rico", "RO" => "Romania", "RU" => "Russian Federation", "SA" => "Saudi Arabia", "SG" => "Singapore", "ZA" => "South Africa", "ES" => "Spain", "SE" => "Sweden", "CH" => "Switzerland", "SY" => "Syria", "TR" => "Turkey", "YU" => "Yugoslavia", ); my %ZoneTable = ( "UK" => { "UndefinedRegion" => [1], }, "US" => { "UndefinedRegion" => [17], }, "AR" => { "UndefinedRegion" => [10], }, "AU" => { "UndefinedRegion" => [12], }, "AT" => { "UndefinedRegion" => [15], }, "BE" => { "UndefinedRegion" => [15], }, "BM" => { "UndefinedRegion" => [10], }, "CA" => { "UndefinedRegion" => [19], }, "CL" => { "UndefinedRegion" => [10], }, "CO" => { "UndefinedRegion" => [10], }, "CY" => { "UndefinedRegion" => [15], }, "DK" => { "UndefinedRegion" => [15], }, "FI" => { "UndefinedRegion" => [15], }, "FR" => { "UndefinedRegion" => [15], }, "DE" => { "UndefinedRegion" => [15], }, "GI" => { "UndefinedRegion" => [15], }, "GR" => { "UndefinedRegion" => [15], }, "GL" => { "UndefinedRegion" => [10], }, "HK" => { "UndefinedRegion" => [13], }, "HU" => { "UndefinedRegion" => [14], }, "IL" => { "UndefinedRegion" => [10], }, "IT" => { "UndefinedRegion" => [15], }, "JP" => { "UndefinedRegion" => [13], }, "KR" => { "UndefinedRegion" => [13], }, "LB" => { "UndefinedRegion" => [10], }, "LI" => { "UndefinedRegion" => [15], }, "LU" => { "UndefinedRegion" => [15], }, "MT" => { "UndefinedRegion" => [15], }, "MX" => { "UndefinedRegion" => [10], }, "MC" => { "UndefinedRegion" => [15], }, "NL" => { "UndefinedRegion" => [15], }, "NZ" => { "UndefinedRegion" => [12], }, "NO" => { "UndefinedRegion" => [15], }, "PH" => { "UndefinedRegion" => [13], }, "PL" => { "UndefinedRegion" => [14], }, "PT" => { "UndefinedRegion" => [15], }, "PR" => { "UndefinedRegion" => [10], }, "RO" => { "UndefinedRegion" => [14], }, "RU" => { "UndefinedRegion" => [14], }, "SA" => { "UndefinedRegion" => [10], }, "SG" => { "UndefinedRegion" => [13], }, "ZA" => { "UndefinedRegion" => [11], }, "ES" => { "UndefinedRegion" => [15], }, "SE" => { "UndefinedRegion" => [15], }, "CH" => { "UndefinedRegion" => [15], }, "SY" => { "UndefinedRegion" => [10], }, "TR" => { "UndefinedRegion" => [10], }, "YU" => { "UndefinedRegion" => [14], }, ); my %ShippingTable = ( 1 => { 1 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>1000}, { "wt" =>2.00, "cost" =>1000}, { "wt" =>5.00, "cost" =>1000}, { "wt" =>15.00, "cost" =>1000}, { "wt" =>20.00, "cost" =>1500}, ], }, 13 => { 17 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>2500}, { "wt" =>2.00, "cost" =>4000}, { "wt" =>3.00, "cost" =>4000}, { "wt" =>4.00, "cost" =>4000}, { "wt" =>5.00, "cost" =>4000}, ], }, 14 => { 10 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>0.00, "cost" =>0}, { "wt" =>1.00, "cost" =>6000}, { "wt" =>2.00, "cost" =>6000}, { "wt" =>3.00, "cost" =>6000}, { "wt" =>4.00, "cost" =>6000}, { "wt" =>5.00, "cost" =>6000}, { "wt" =>6.00, "cost" =>6500}, { "wt" =>7.00, "cost" =>7000}, { "wt" =>8.00, "cost" =>7500}, { "wt" =>9.00, "cost" =>8000}, { "wt" =>10.00, "cost" =>8500}, ], 11 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>1.00, "cost" =>5500}, { "wt" =>2.00, "cost" =>5500}, { "wt" =>3.00, "cost" =>5500}, { "wt" =>4.00, "cost" =>5500}, { "wt" =>5.00, "cost" =>5500}, { "wt" =>6.00, "cost" =>6000}, { "wt" =>7.00, "cost" =>6500}, { "wt" =>8.00, "cost" =>7000}, { "wt" =>9.00, "cost" =>7500}, { "wt" =>10.00, "cost" =>8000}, ], 12 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>1.00, "cost" =>5000}, { "wt" =>2.00, "cost" =>5000}, { "wt" =>3.00, "cost" =>5000}, { "wt" =>4.00, "cost" =>5000}, { "wt" =>5.00, "cost" =>5000}, { "wt" =>6.00, "cost" =>5500}, { "wt" =>7.00, "cost" =>5500}, { "wt" =>8.00, "cost" =>6000}, { "wt" =>9.00, "cost" =>6500}, { "wt" =>10.00, "cost" =>6500}, { "wt" =>11.00, "cost" =>7000}, { "wt" =>12.00, "cost" =>7000}, { "wt" =>13.00, "cost" =>7500}, { "wt" =>14.00, "cost" =>7500}, { "wt" =>15.00, "cost" =>8000}, { "wt" =>16.00, "cost" =>8000}, { "wt" =>17.00, "cost" =>8500}, { "wt" =>18.00, "cost" =>8500}, { "wt" =>19.00, "cost" =>9000}, { "wt" =>20.00, "cost" =>9500}, { "wt" =>21.00, "cost" =>10000}, { "wt" =>22.00, "cost" =>10000}, { "wt" =>23.00, "cost" =>10000}, { "wt" =>24.00, "cost" =>10500}, { "wt" =>25.00, "cost" =>10500}, { "wt" =>26.00, "cost" =>11011000}, { "wt" =>27.00, "cost" =>11500}, { "wt" =>28.00, "cost" =>11500}, { "wt" =>29.00, "cost" =>12000}, { "wt" =>30.00, "cost" =>12500}, ], 13 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>1.00, "cost" =>5500}, { "wt" =>2.00, "cost" =>5500}, { "wt" =>3.00, "cost" =>5500}, { "wt" =>4.00, "cost" =>5500}, { "wt" =>5.00, "cost" =>5500}, ], 14 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>5500}, { "wt" =>2.00, "cost" =>5500}, { "wt" =>3.00, "cost" =>5500}, { "wt" =>4.00, "cost" =>5500}, { "wt" =>5.00, "cost" =>5500}, { "wt" =>6.00, "cost" =>6000}, ], 15 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>3500}, { "wt" =>2.00, "cost" =>3500}, { "wt" =>3.00, "cost" =>3500}, { "wt" =>4.00, "cost" =>3500}, { "wt" =>5.00, "cost" =>35000}, ], 17 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>6000}, { "wt" =>2.00, "cost" =>6000}, { "wt" =>3.00, "cost" =>6000}, { "wt" =>4.00, "cost" =>6000}, { "wt" =>5.00, "cost" =>6000}, { "wt" =>6.00, "cost" =>6000}, ], 18 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>2800}, { "wt" =>2.00, "cost" =>2800}, { "wt" =>3.00, "cost" =>2800}, { "wt" =>4.00, "cost" =>2800}, { "wt" =>5.00, "cost" =>2800}, { "wt" =>6.00, "cost" =>3000}, ], 19 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>0.00, "cost" =>0}, { "wt" =>0.00, "cost" =>5500}, { "wt" =>1.00, "cost" =>6000}, { "wt" =>2.00, "cost" =>6000}, { "wt" =>3.00, "cost" =>6000}, { "wt" =>4.00, "cost" =>6000}, { "wt" =>5.00, "cost" =>6000}, { "wt" =>6.00, "cost" =>4300}, { "wt" =>7.00, "cost" =>4600}, { "wt" =>8.00, "cost" =>4900}, { "wt" =>9.00, "cost" =>5200}, { "wt" =>10.00, "cost" =>55000}, { "wt" =>11.00, "cost" =>5800}, { "wt" =>12.00, "cost" =>6000}, { "wt" =>13.00, "cost" =>6000}, { "wt" =>14.00, "cost" =>6000}, { "wt" =>15.00, "cost" =>6200}, { "wt" =>16.00, "cost" =>6400}, { "wt" =>17.00, "cost" =>6600}, { "wt" =>18.00, "cost" =>6800}, { "wt" =>19.00, "cost" =>7000}, ], }, 15 => { 10 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>1.00, "cost" =>2500}, { "wt" =>2.00, "cost" =>3500}, { "wt" =>3.00, "cost" =>4200}, { "wt" =>4.00, "cost" =>5000}, { "wt" =>5.00, "cost" =>5800}, { "wt" =>6.00, "cost" =>6500}, { "wt" =>7.00, "cost" =>7200}, { "wt" =>8.00, "cost" =>8000}, { "wt" =>9.00, "cost" =>8500}, { "wt" =>10.00, "cost" =>9200}, { "wt" =>11.00, "cost" =>10000}, ], 11 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>0.00, "cost" =>10000}, { "wt" =>1.00, "cost" =>2500}, { "wt" =>2.00, "cost" =>3500}, { "wt" =>3.00, "cost" =>4200}, { "wt" =>4.00, "cost" =>5000}, { "wt" =>5.00, "cost" =>5800}, { "wt" =>6.00, "cost" =>6500}, { "wt" =>7.00, "cost" =>7200}, { "wt" =>8.00, "cost" =>8000}, { "wt" =>9.00, "cost" =>8500}, { "wt" =>10.00, "cost" =>9200}, { "wt" =>11.00, "cost" =>10000}, ], 12 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>1.00, "cost" =>2500}, { "wt" =>2.00, "cost" =>3000}, { "wt" =>3.00, "cost" =>3500}, { "wt" =>4.00, "cost" =>4000}, { "wt" =>5.00, "cost" =>4500}, { "wt" =>6.00, "cost" =>5000}, { "wt" =>7.00, "cost" =>5500}, { "wt" =>8.00, "cost" =>6000}, { "wt" =>9.00, "cost" =>6500}, { "wt" =>10.00, "cost" =>7000}, ], 13 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 500}, { "wt" =>1.00, "cost" =>2500}, { "wt" =>2.00, "cost" =>3000}, { "wt" =>3.00, "cost" =>3500}, { "wt" =>4.00, "cost" =>4000}, { "wt" =>5.00, "cost" =>4500}, { "wt" =>6.00, "cost" =>0}, ], 14 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>2000}, { "wt" =>2.00, "cost" =>2500}, { "wt" =>3.00, "cost" =>3000}, { "wt" =>4.00, "cost" =>3000}, { "wt" =>5.00, "cost" =>3500}, { "wt" =>6.00, "cost" =>3500}, { "wt" =>7.00, "cost" =>4000}, { "wt" =>8.00, "cost" =>4000}, { "wt" =>9.00, "cost" =>4500}, { "wt" =>10.00, "cost" =>4500}, ], 15 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 100}, { "wt" =>0.00, "cost" =>3500}, { "wt" =>1.00, "cost" =>2000}, { "wt" =>2.00, "cost" =>2500}, { "wt" =>3.00, "cost" =>2500}, { "wt" =>4.00, "cost" =>2500}, { "wt" =>5.00, "cost" =>2500}, { "wt" =>6.00, "cost" =>3000}, { "wt" =>7.00, "cost" =>3000}, { "wt" =>8.00, "cost" =>3000}, { "wt" =>9.00, "cost" =>3500}, { "wt" =>10.00, "cost" =>3500}, { "wt" =>11.00, "cost" =>3600}, { "wt" =>12.00, "cost" =>3700}, { "wt" =>13.00, "cost" =>3800}, { "wt" =>14.00, "cost" =>3900}, { "wt" =>15.00, "cost" =>4000}, ], 18 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>800}, { "wt" =>2.00, "cost" =>1000}, { "wt" =>3.00, "cost" =>1200}, ], 19 => [ {"ExcessAction" => 'AddFurther', "IncrementalWeight" => 1.000000, "IncrementalCharge" => 200}, { "wt" =>1.00, "cost" =>2500}, { "wt" =>2.00, "cost" =>3000}, { "wt" =>3.00, "cost" =>3500}, { "wt" =>4.00, "cost" =>4000}, { "wt" =>5.00, "cost" =>4500}, { "wt" =>6.00, "cost" =>4800}, { "wt" =>7.00, "cost" =>5100}, { "wt" =>8.00, "cost" =>5400}, { "wt" =>9.00, "cost" =>5700}, { "wt" =>10.00, "cost" =>6000}, ] } ); my %WeightTable = ( "1" => .2, "10" => .2, "100" => .2, "101" => .2, "102" => .2, "103" => .2, "104" => .2, "105" => .2, "106" => .2, "107" => .2, "108" => .2, "109" => .2, "11" => .2, "110" => .2, "111" => .2, "112" => 14, "113" => 1.1, "114" => 1.1, "115" => 1.1, "116" => 1.1, "117" => 1.1, "118" => 1.1, "119" => 1.1, "12" => .2, "120" => 1.1, "121" => 1.1, "122" => 1.1, "123" => 1.1, "124" => 1.1, "125" => .2, "126" => .2, "127" => .2, "128" => .2, "129" => .2, "13" => .2, "130" => .2, "131" => .2, "132" => .2, "133" => 1, "134" => 1, "135" => 1, "136" => 1, "137" => 1, "138" => 1, "139" => 1, "14" => .2, "140" => 1, "141" => 20, "142" => 9, "143" => 8, "144" => 3, "145" => 5, "146" => 4, "147" => 3, "148" => 5, "149" => 4, "15" => 1.1, "150" => 4, "16" => 1.1, "17" => 1.1, "18" => 1.1, "19" => 1.1, "2" => .2, "20" => 1.1, "21" => .2, "22" => .2, "23" => .2, "24" => 6, "25" => 1.1, "26" => 1.1, "27" => 1.1, "28" => 1.1, "29" => 1.1, "3" => .2, "30" => 1.1, "31" => .2, "32" => .2, "33" => .2, "34" => .2, "35" => .2, "36" => .2, "37" => 3, "38" => 1.1, "39" => 1.1, "4" => .2, "40" => 1.1, "41" => 1.1, "42" => 1.1, "43" => 1.1, "44" => 1.1, "45" => .3, "46" => .3, "47" => .3, "48" => .3, "49" => .3, "5" => .2, "50" => .3, "51" => .3, "52" => .3, "53" => 3, "54" => 3, "55" => 3, "56" => 3, "57" => 3, "58" => 3, "59" => 3, "6" => 1.1, "60" => 3, "61" => .2, "62" => .2, "63" => .2, "64" => .2, "65" => .2, "66" => .2, "67" => 1.1, "68" => 1.1, "69" => 1.1, "7" => 1.1, "70" => 1.1, "71" => 1.1, "72" => 1.1, "73" => .2, "74" => .2, "75" => .2, "76" => .2, "77" => .2, "78" => .2, "79" => .2, "8" => .2, "80" => .2, "81" => .2, "82" => .2, "83" => .2, "84" => .2, "85" => 1.1, "86" => 8, "87" => 14, "88" => 1.1, "89" => 8, "9" => .2, "90" => 1.1, "91" => 1.1, "92" => 1.1, "93" => 1.1, "94" => 1.1, "95" => 1.1, "96" => 1.1, "97" => 1.1, "98" => 1.1, "99" => 1.1, ); my ($DefaultWeight, $ShippingBasis, $SimpleCost, $UnknownRegion, $UnknownRegionCost, $WaiveCharges, $WaiveThreshold); $DefaultWeight = 1.00; $ShippingBasis = 'Weight'; $UnknownRegion = 'Error'; $UnknownRegionCost = 300; $WaiveCharges = 'No'; $WaiveThreshold = 25000.000000; my %ClassTable = ( 14 => "Fedex or similar", 15 => "Insured Parcel Post", 1 => "Parcelforce (7 - 10 days)", 13 => "UPS in USA" ); use strict; no strict 'refs'; $::s_Ship_nShippingStatus{ValidatePreliminaryInput} = $::SUCCESS; $::s_Ship_nShippingStatus{ValidateFinalInput} = $::SUCCESS; $::s_Ship_nShippingStatus{RestorePreliminaryUI} = $::SUCCESS; $::s_Ship_nShippingStatus{RestoreFinalUI} = $::SUCCESS; $::s_Ship_nShippingStatus{CalculateShipping} = $::SUCCESS; $::s_Ship_nShippingStatus{IsPrelimPhaseHidden} = $::SUCCESS; $::s_Ship_nShippingStatus{IsFinalPhaseHidden} = $::SUCCESS; $::s_Ship_nShippingStatus{GetShippingDescription} = $::SUCCESS; $::s_Ship_nShippingStatus{GetCountryDescription} = $::SUCCESS; %::s_Ship_sShippingError = (); %::s_Ship_PreliminaryInfoVariables = (); %::s_Ship_ShippingVariables = (); $::s_Ship_bPrelimIsHidden = $::FALSE; $::s_Ship_bShipPhaseIsHidden = $::FALSE; $::s_Ship_sShippingDescription = ''; $::s_Ship_sShippingCountryName = ''; $::s_Ship_nShipCharges = 0; ValidatePreliminaryInput(); ValidateFinalInput(); RestorePreliminaryUI(); RestoreFinalUI(); CalculateShipping(); IsPrelimPhaseHidden(); IsFinalPhaseHidden(); GetShippingDescription(); GetCountryDescription(); return($::SUCCESS); # abort execution (the $::SUCCESS here indicates that the script did not crash) sub ValidatePreliminaryInput { if ($ShippingBasis eq 'Simple') { return; } if (!defined $::g_InputHash{'LocationCountry'} || !defined $::g_InputHash{'LocationRegion'}) { return; } my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { $::s_Ship_nShippingStatus{ValidatePreliminaryInput} = $status; $::s_Ship_sShippingError{ValidatePreliminaryInput} = $sMessage; return; } if ($ShipData{LocationCountry} ne $::g_InputHash{LocationCountry} || $ShipData{LocationRegion} ne $::g_InputHash{LocationRegion}) { undef $::s_Ship_sOpaqueShipData; } $::s_Ship_sOpaqueLocationData = sprintf("LocationCountry;%s;LocationRegion;%s;", $::g_InputHash{'LocationCountry'}, $::g_InputHash{'LocationRegion'}); if (length $::g_InputHash{'LocationCountry'} == 0) { $::s_Ship_nShippingStatus{ValidatePreliminaryInput} = $::FAILURE; $::s_Ship_sShippingError{ValidatePreliminaryInput} = $$pMessageList[0]; return; } my @bands = @{ $ZoneTable{$::g_InputHash{'LocationCountry'}}{$::g_InputHash{'LocationRegion'}} }; if ($#bands < 0 && # invalid country/region combination and $UnknownRegion ne 'Default') # we don't tolerate invalid bands, { $::s_Ship_nShippingStatus{ValidatePreliminaryInput} = $::FAILURE; $::s_Ship_sShippingError{ValidatePreliminaryInput} = $$pMessageList[5]; return; } my ($j, $bFound); $bFound = $::FALSE; OUT: for $j (0 .. $#bands) { my ($Class, $pBandList); while ( ($Class, $pBandList) = each %ShippingTable) { my @costs = @ {${$pBandList}{$bands[$j]}}; if ($#costs > 0) { $bFound = $::TRUE; last OUT; } } } my ($Temp); $Temp = keys %ShippingTable; # reset the iterator for "each" if (!$bFound && # if a matching class was not found, the regions is invalid $UnknownRegion ne 'Default') # we don't tolerate invalid zones { $::s_Ship_nShippingStatus{ValidatePreliminaryInput} = $::FAILURE; $::s_Ship_sShippingError{ValidatePreliminaryInput} = $$pMessageList[5]; return; } return; } sub ValidateFinalInput { if ($ShippingBasis eq 'Simple') { if ($::g_InputHash{SHIPPING}) { $::g_InputHash{SHIPPING} =~ s/^\s*(.*?)\s*$/$1/gs; } if (defined $::g_InputHash{SHIPPING}) # if the shipping is defined, store its value { my $sText = (0 == length $::g_InputHash{SHIPPING}) ? ' ' : $::g_InputHash{SHIPPING}; $::s_Ship_sOpaqueShipData = sprintf("Simple;%s;", $sText); } if (!defined $::g_InputHash{'SHIPPING'} ||# if the shipping is undefined, error out length $::g_InputHash{'SHIPPING'} == 0) { $::s_Ship_nShippingStatus{ValidateFinalInput} = $::FAILURE; $::s_Ship_sShippingError{ValidateFinalInput} = $$pMessageList[9]; return; } my (@Response); @Response = ActinicOrder::ReadPrice($::g_InputHash{SHIPPING}, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS || # if the price is not readable, or $Response[2] != int $Response[2]) { @Response = ActinicOrder::FormatPrice(10000, $::FALSE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { $::s_Ship_nShippingStatus{ValidateFinalInput} = $Response[0]; $::s_Ship_sShippingError{ValidateFinalInput} = $Response[1]; return; } $::s_Ship_nShippingStatus{ValidateFinalInput} = $::FAILURE; $::s_Ship_sShippingError{ValidateFinalInput} = sprintf($$pMessageList[1], $Response[2]); return; } my ($nMaxShipping) = 999999; if ($Response[2] >= $nMaxShipping) # if the shipping is too big, display error { @Response = ActinicOrder::FormatPrice($nMaxShipping, $::TRUE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { $::s_Ship_nShippingStatus{ValidateFinalInput} = $Response[0]; $::s_Ship_sShippingError{ValidateFinalInput} = $Response[1]; return; } $::s_Ship_nShippingStatus{ValidateFinalInput} = $::FAILURE; $::s_Ship_sShippingError{ValidateFinalInput} = sprintf($$pMessageList[2], $Response[2]); return; } my ($nMinShipping) = 0; if ($Response[2] < $nMinShipping) # if the shipping is too small, display error { @Response = ActinicOrder::FormatPrice($nMinShipping, $::TRUE, \%::s_Ship_PriceFormatBlob); if ($Response[0] != $::SUCCESS) { $::s_Ship_nShippingStatus{ValidateFinalInput} = $Response[0]; $::s_Ship_sShippingError{ValidateFinalInput} = $Response[1]; return; } $::s_Ship_nShippingStatus{ValidateFinalInput} = $::FAILURE; $::s_Ship_sShippingError{ValidateFinalInput} = sprintf($$pMessageList[3], $Response[2]); return; } return; } my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { $::s_Ship_nShippingStatus{ValidateFinalInput} = $status; $::s_Ship_sShippingError{ValidateFinalInput} = $sMessage; return; } if (!defined $ShipData{'LocationCountry'} || !defined $ShipData{'LocationRegion'}) { return; } if (!defined $::g_InputHash{'ShippingClass'}) { my ($status, $sMessage, $pOptionTitleList, $pOptionIDList) = FormatShippingOptions(%ShipData); if ($status != $::SUCCESS) { $::s_Ship_nShippingStatus{ValidateFinalInput} = $status; $::s_Ship_sShippingError{ValidateFinalInput} = $sMessage; return; } if ($#{$pOptionIDList} == 0) { $::g_InputHash{'ShippingClass'} = ${$pOptionIDList}[0]; } } if (!defined $::g_InputHash{'ShippingClass'}) { return; } $::s_Ship_sOpaqueShipData = sprintf("ShippingClass;%s;", $::g_InputHash{'ShippingClass'}); if ($WaiveCharges eq 'Value') # We've waive if it's big enough { if (CalculatePrice() > $WaiveThreshold) # See if we've spent enough { return; } } my @bands = @{ $ZoneTable{$ShipData{'LocationCountry'}}{$ShipData{'LocationRegion'}} }; if ($#bands < 0 && # invalid country/region combination and $UnknownRegion ne 'Default') # we don't tolerate invalid bands, { $::s_Ship_nShippingStatus{ValidateFinalInput} = $::FAILURE; $::s_Ship_sShippingError{ValidateFinalInput} = $$pMessageList[5]; return; } my @costs; my $j; for $j (0 .. $#bands) { @costs = @ {$ShippingTable{$::g_InputHash{'ShippingClass'}}{$bands[$j]}}; if ($#costs > 0) { last; # We'll use this one } } if ($#costs <= 0) { if ($UnknownRegion eq 'Default') { return; } $::s_Ship_sShippingError{ValidateFinalInput} = $$pMessageList[4]; $::s_Ship_nShippingStatus{ValidateFinalInput} = $::FAILURE; return; } 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; } } if ($costs[0]{'ExcessAction'} eq 'Highest' || $costs[0]{'ExcessAction'} eq 'AddFurther') { return; } $::s_Ship_nShippingStatus{ValidateFinalInput} = $::FAILURE; $::s_Ship_sShippingError{ValidateFinalInput} = $$pMessageList[8]; return; } sub UnpackData { my (@arglist); @arglist = split (';', $::s_Ship_sOpaqueShipData); push (@arglist, split (';', $::s_Ship_sOpaqueLocationData)); return ($::SUCCESS, "", @arglist); } sub RestorePreliminaryUI { my ($status, $sMessage, %ShipData); ($status, $sMessage, %ShipData) = UnpackData(); if ($status != $::SUCCESS) { $::s_Ship_nShippingStatus{RestorePreliminaryUI} = $status; $::s_Ship_sShippingError{RestorePreliminaryUI} = $sMessage; return; } if ($ShippingBasis eq 'Simple') # we are in simple mode (no processing here) { return; } my ($key, $value); while ( ($key, $value) = each %ShipData) { if (length $value > 0) { $::s_Ship_PreliminaryInfoVariables{"