Created
August 16, 2015 21:11
-
-
Save joewashere/779bb0b12509c86a1795 to your computer and use it in GitHub Desktop.
DHL Global Mail WTB to Miva XML Provisioning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$row = 1; | |
$countries = array('CA','AD','AE','AF','AG','AI','AL','AM','AN','AO','AR','AT','AU','AW','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO','BR','BS','BT','BW','BY','BZ','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','CR','CV','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ','EC','EE','EG','EH','ER','ES','ET','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GH','GI','GL','GM','GN','GP','GQ','GR','GS','GT','GW','GY','HK','HN','HR','HT','HU','ID','IE','IL','IM','IN','IO','IQ','IS','IT','JM','JO','JP','KE','KG','KH','KI','KM','KN','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','ME','MF','MG','MH','MK','ML','MN','MO','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','PA','PE','PF','PG','PH','PK','PL','PM','PN','PS','PT','PW','PY','QA','RE','RO','RS','RU','RW','SA','SB','SC','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','ST','SV','SZ','TC','TD','TF','TG','TH','TJ','TL','TM','TN','TO','TR','TT','TV','TW','TZ','UA','UG','UY','UZ','VA','VC','VE','VG','VN','VU','WF','WS','YE','YT','YU','ZA','ZM','ZW'); | |
$ccounter = 2; | |
//Loop through every country in the array | |
foreach($countries as $country){ | |
//Print opening module block and set method name | |
echo "<Module code='wtbship' feature='shipping'> | |
<Method_Add> | |
<Method>".$country."</Method> | |
<Handling>0.00</Handling>"; | |
//Open CSV file for reading | |
if (($handle = fopen("Miva_DHL_Global.csv", "r")) !== FALSE) { | |
//Loop through each line of CSV | |
while (($data = fgetcsv($handle, ",")) !== FALSE) { | |
//Set initial variables | |
$num = count($data); //Data count | |
$row++; //Increase row number | |
$counter = 0; //Set column counter | |
$wb = $data[0]; //Get weight ceiling | |
//Loop through each cell in the row | |
for ($c=0; $c < $num; $c++) { | |
//Skip the first two columns by checking Country counter against column counter | |
if($counter == $ccounter){ | |
//Skips header row | |
if($wb != 'WEIGHT BREAK (LBS)'){ | |
//Prints celing and rate | |
echo "<Range> | |
<Ceiling>".$wb."</Ceiling> | |
<Rate>".$data[$c]."</Rate> | |
</Range>"; | |
} | |
} | |
$counter++; | |
} | |
} | |
//Close file | |
fclose($handle); | |
} | |
//Print closing XML tags | |
echo "</Method_Add> | |
</Module>"; | |
$ccounter++; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment