royal_mail.php (29598B)
1 <?php 2 /* 3 List of Royal Mail support Countries 4 5 http://www.royalmail.com/sites/default/files/RoyalMail_International_TrackedCoverage_Jan2014.pdf 6 7 Afghanistan = AF 8 Aland Islands = NA 9 Albania = AL 10 Algeria = DZ 11 Andorra = AD 12 Angola = AO 13 Anguilla = AI 14 Antigua / Barbuda = AG 15 Argentina = AR 16 Armenia = AM 17 Aruba = AW 18 Ascension Island = XA 19 Australia = AU 20 Austria = AT 21 Azerbaijan = AZ 22 Bahamas = BS 23 Bahrain = BH 24 Bangladesh = BD 25 Barbados = BB 26 Belarus = BY 27 Belgium = BE 28 Belize = BZ 29 Benin = BJ 30 Bermuda = BM 31 Bhutan = BT 32 Bolivia = BO 33 Bonaire = BX 34 Bosnia Hertzegovina = BA 35 Botswana = BW 36 Brazil = BR 37 British Indian Ocean Territory = IO 38 British Virgin Islands = VG 39 Brunei = BN 40 Bulgaria = BG 41 Burkina Faso = BF 42 Burundi = BI 43 Cambodia = KH 44 Cameroon = CM 45 Canada = CA 46 Canary Islands = XC 47 Cape Verde = CV 48 Cayman Islands = KY 49 Central African Republic = CF 50 Ceuta = CE 51 Chad = TD 52 Chile = CL 53 China (People's Republic of) = CN 54 Christmas Island (Indian Ocean) = CX 55 Christmas Island (Pacific Ocean) = CX 56 Colombia = CO 57 Comoros Islands = KM 58 Congo ( Dem. Rep of) = CD 59 Congo ( Rep of) = CG 60 Cook Islands = CK 61 Costa Rica = CR 62 Croatia = HR 63 Cuba = CU 64 Curacao = CB 65 Cyprus = CY 66 Czech Republic = CZ 67 Denmark = DK 68 Djibouti = DJ 69 Dominica = DM 70 Dominican Republic = DO 71 Ecuador = EC 72 Egypt = EG 73 El Salvador = SV 74 Equatorial Guinea = GQ 75 Eritrea = ER 76 Estonia = EE 77 Ethiopia = ET 78 Falkland Islands = FK 79 Faroe Islands = FO 80 Fiji = FJ 81 Finland = FI 82 France = FR 83 French Guiana = GF 84 French Polynesia = PF 85 French South Antarctic Territory = TF 86 Gabon = GA 87 Gambia = GM 88 Georgia = GE 89 Germany = DE 90 Ghana = GH 91 Gibraltar = GI 92 Greece = GR 93 Greenland = GL 94 Grenada = GD 95 Guadeloupe = GP 96 Guatemala = GT 97 Guinea = GN 98 Guinea-Bissau = GW 99 Guyana = GY 100 Haiti = HT 101 Honduras = HN 102 Hong Kong = HK 103 Hungary = HU 104 Iceland = IS 105 India = IN 106 Indonesia = ID 107 Iran (Islamic Republic of) = IR 108 Iraq = IQ 109 Ireland (Republic of) = IE 110 Israel = IL 111 Italy = IT 112 Ivory Coast (Cote D'Ivoire) = CI 113 Jamaica = JM 114 Japan = JP 115 Jordan = JO 116 Kazakhstan = KZ 117 Kenya = KE 118 Kiribati = KI 119 Kosovo = KV 120 Kuwait = KW 121 Kyrgyzstan = KG 122 Laos (People's Democratic Republic of) = LA 123 Latvia = LV 124 Lebanon = LB 125 Lesotho = LS 126 Liberia = LR 127 Libya = LY 128 Liechtenstein = LI 129 Lithuania = LT 130 Luxembourg = LU 131 Macau = MO 132 Macedonia = MK 133 Madagascar = MG 134 Mahore (also known as Mayotte) = YT 135 Malawi = MW 136 Malaysia = MY 137 Maldives = MV 138 Mali = ML 139 Malta = MT 140 Martinique = MQ 141 Mauritania = MR 142 Mauritius = MU 143 Melilla = XL 144 Mexico = MX 145 Moldova = MD 146 Mongolia = MN 147 Montenegro = CS 148 Montserrat = MS 149 Morocco = MA 150 Mozambique = MZ 151 Myanmar = MM 152 Namibia = NA 153 Nauru Island = NR 154 Nepal = NP 155 Netherlands = NL 156 New Caledonia = NC 157 New Zealand = NZ 158 Nicaragua = NI 159 Niger Republic = NE 160 Nigeria = NG 161 Niue Island = NU 162 North Korea (People's Democratic Republic of ) = KP 163 Norway = NO 164 Oman = OM 165 Pakistan = PK 166 Palau (known also as Belau) = PW 167 Panama = PA 168 Papua New Guinea = PG 169 Paraguay = PY 170 Peru = PE 171 Philippines = PH 172 Pitcairn Island = PN 173 Poland = PL 174 Portugal = PT 175 Puerto Rico = PR 176 Qatar = QA 177 Reunion Island = RE 178 Romania = RO 179 Russian Federation = RU 180 Rwanda = RW 181 San Marino = SM 182 Sao Tome & Principe = ST 183 Saudi Arabia = SA 184 Senegal = SN 185 Serbia = CS 186 Seychelles = SC 187 Sierra Leone = SL 188 Singapore = SG 189 Slovak Republic = SK 190 Slovenia = SI 191 Solomon Islands = SB 192 Somalia = SO 193 South Africa ( Republic of) = ZA 194 South Korea (Republic of) = KR 195 South Sudan = SD 196 Spain = ES 197 Sri Lanka = LK 198 St Eustatius = SX 199 St Helena = SH 200 St Kitts & Nevis = KN 201 St Lucia = LC 202 St Maarten = SF 203 St Vincent & The Grenadines = VC 204 Sudan = SD 205 Suriname = SR 206 Swaziland = SZ 207 Sweden = SE 208 Switzerland = CH 209 Syria = SY 210 Taiwan = TW 211 Tajikistan = TJ 212 Tanzania = TZ 213 Thailand = TH 214 Timor-Leste = TP 215 Togo = TG 216 Tokelau Islands = TK 217 Tonga = TO 218 Trinidad & Tobago = TT 219 Tristan de Cunha = XT 220 Tunisia = TN 221 Turkey = TR 222 Turkish (Republic of Northern Cyprus) = CP 223 Turkmenistan = TM 224 Turks & Caicos Islands = TC 225 Tuvalu = TV 226 Uganda = UG 227 Ukraine = UA 228 United Arab Emirates = AE 229 Uruguay = UY 230 USA = US 231 Uzbekistan = UZ 232 Vanuatu = VU 233 Vatican City State = VA 234 Venezuela = VE 235 Vietnam = VN 236 Wallis & Futuna Islands = WF 237 Western Sahara = EH 238 Western Samoa = WS 239 Yemen, Republic of = YE 240 Zambia = ZM 241 Zimbabwe = ZW 242 */ 243 class ModelExtensionShippingRoyalMail extends Model { 244 function getQuote($address) { 245 $this->load->language('extension/shipping/royal_mail'); 246 247 $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('shipping_royal_mail_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); 248 249 if (!$this->config->get('shipping_royal_mail_geo_zone_id')) { 250 $status = true; 251 } elseif ($query->num_rows) { 252 $status = true; 253 } else { 254 $status = false; 255 } 256 257 $quote_data = array(); 258 259 if ($status) { 260 $weight = $this->cart->getWeight(); 261 $sub_total = $this->cart->getSubTotal(); 262 263 // Special Delivery > 500 264 if ($this->config->get('shipping_royal_mail_special_delivery_500_status') && $address['iso_code_2'] == 'GB') { 265 $cost = 0; 266 $insurance = 0; 267 268 $rates = explode(',', $this->config->get('shipping_royal_mail_special_delivery_500_rate')); 269 270 foreach ($rates as $rate) { 271 $data = explode(':', $rate); 272 273 if ($data[0] >= $weight) { 274 if (isset($data[1])) { 275 $cost = $data[1]; 276 } 277 278 break; 279 } 280 } 281 282 if ((float)$cost) { 283 $title = $this->language->get('text_special_delivery'); 284 285 if ($this->config->get('shipping_royal_mail_display_weight')) { 286 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 287 } 288 289 if ($this->config->get('shipping_royal_mail_display_insurance')) { 290 $title .= ' (' . $this->language->get('text_insurance') . ' ' . $this->currency->format(500, $this->session->data['currency']) . ')'; 291 } 292 293 $quote_data['special_delivery_500'] = array( 294 'code' => 'royal_mail.special_delivery_500', 295 'title' => $title, 296 'cost' => $cost, 297 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 298 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 299 ); 300 } 301 } 302 303 // Special Delivery > 1000 304 if ($this->config->get('shipping_royal_mail_special_delivery_1000_status') && $address['iso_code_2'] == 'GB') { 305 $cost = 0; 306 $insurance = 0; 307 308 $rates = explode(',', $this->config->get('shipping_royal_mail_special_delivery_1000_rate')); 309 310 foreach ($rates as $rate) { 311 $data = explode(':', $rate); 312 313 if ($data[0] >= $weight) { 314 if (isset($data[1])) { 315 $cost = $data[1]; 316 } 317 318 break; 319 } 320 } 321 322 if ((float)$cost) { 323 $title = $this->language->get('text_special_delivery'); 324 325 if ($this->config->get('shipping_royal_mail_display_weight')) { 326 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 327 } 328 329 if ($this->config->get('shipping_royal_mail_display_insurance')) { 330 $title .= ' (' . $this->language->get('text_insurance') . ' ' . $this->currency->format(1000, $this->session->data['currency']) . ')'; 331 332 } 333 334 $quote_data['special_delivery_1000'] = array( 335 'code' => 'royal_mail.special_delivery_1000', 336 'title' => $title, 337 'cost' => $cost, 338 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 339 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 340 ); 341 } 342 } 343 344 // Special Delivery > 2500 345 if ($this->config->get('shipping_royal_mail_special_delivery_2500_status') && $address['iso_code_2'] == 'GB') { 346 $cost = 0; 347 $insurance = 0; 348 349 $rates = explode(',', $this->config->get('shipping_royal_mail_special_delivery_2500_rate')); 350 351 foreach ($rates as $rate) { 352 $data = explode(':', $rate); 353 354 if ($data[0] >= $weight) { 355 if (isset($data[1])) { 356 $cost = $data[1]; 357 } 358 359 break; 360 } 361 } 362 363 if ((float)$cost) { 364 $title = $this->language->get('text_special_delivery'); 365 366 if ($this->config->get('shipping_royal_mail_display_weight')) { 367 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 368 } 369 370 if ($this->config->get('shipping_royal_mail_display_insurance')) { 371 $title .= ' (' . $this->language->get('text_insurance') . ' ' . $this->currency->format(2500, $this->session->data['currency']) . ')'; 372 } 373 374 $quote_data['special_delivery_2500'] = array( 375 'code' => 'royal_mail.special_delivery_2500', 376 'title' => $title, 377 'cost' => $cost, 378 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 379 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 380 ); 381 } 382 } 383 384 // 1st Class Signed 385 if ($this->config->get('shipping_royal_mail_1st_class_signed_status') && $address['iso_code_2'] == 'GB') { 386 $cost = 0; 387 388 $rates = explode(',', $this->config->get('shipping_royal_mail_1st_class_signed_rate')); 389 390 foreach ($rates as $rate) { 391 $data = explode(':', $rate); 392 393 if ($data[0] >= $weight) { 394 if (isset($data[1])) { 395 $cost = $data[1]; 396 } 397 398 break; 399 } 400 } 401 402 if ((float)$cost) { 403 $title = $this->language->get('text_1st_class_signed'); 404 405 if ($this->config->get('shipping_royal_mail_display_weight')) { 406 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 407 } 408 409 $quote_data['1st_class_signed'] = array( 410 'code' => 'royal_mail.1st_class_signed', 411 'title' => $title, 412 'cost' => $cost, 413 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 414 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 415 ); 416 } 417 } 418 419 // 2nd Class Signed 420 if ($this->config->get('shipping_royal_mail_2nd_class_signed_status') && $address['iso_code_2'] == 'GB') { 421 $cost = 0; 422 423 $rates = explode(',', $this->config->get('shipping_royal_mail_2nd_class_signed_rate')); 424 425 foreach ($rates as $rate) { 426 $data = explode(':', $rate); 427 428 if ($data[0] >= $weight) { 429 if (isset($data[1])) { 430 $cost = $data[1]; 431 } 432 433 break; 434 } 435 } 436 437 if ((float)$cost) { 438 $title = $this->language->get('text_2nd_class_signed'); 439 440 if ($this->config->get('shipping_royal_mail_display_weight')) { 441 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 442 } 443 444 $quote_data['2nd_class_signed'] = array( 445 'code' => 'royal_mail.2nd_class_signed', 446 'title' => $title, 447 'cost' => $cost, 448 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 449 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 450 ); 451 } 452 } 453 454 // 1st Class Standard 455 if ($this->config->get('shipping_royal_mail_1st_class_standard_status') && $address['iso_code_2'] == 'GB') { 456 $cost = 0; 457 458 $rates = explode(',', $this->config->get('shipping_royal_mail_1st_class_standard_rate')); 459 460 foreach ($rates as $rate) { 461 $data = explode(':', $rate); 462 463 if ($data[0] >= $weight) { 464 if (isset($data[1])) { 465 $cost = $data[1]; 466 } 467 468 break; 469 } 470 } 471 472 if ((float)$cost) { 473 $title = $this->language->get('text_1st_class_standard'); 474 475 if ($this->config->get('shipping_royal_mail_display_weight')) { 476 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 477 } 478 479 $quote_data['1st_class_standard'] = array( 480 'code' => 'royal_mail.1st_class_standard', 481 'title' => $title, 482 'cost' => $cost, 483 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 484 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 485 ); 486 } 487 } 488 489 // 2nd Class Standard 490 if ($this->config->get('shipping_royal_mail_2nd_class_standard_status') && $address['iso_code_2'] == 'GB') { 491 $cost = 0; 492 493 $rates = explode(',', $this->config->get('shipping_royal_mail_2nd_class_standard_rate')); 494 495 foreach ($rates as $rate) { 496 $data = explode(':', $rate); 497 498 if ($data[0] >= $weight) { 499 if (isset($data[1])) { 500 $cost = $data[1]; 501 } 502 503 break; 504 } 505 } 506 507 if ((float)$cost) { 508 $title = $this->language->get('text_2nd_class_standard'); 509 510 if ($this->config->get('shipping_royal_mail_display_weight')) { 511 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 512 } 513 514 $quote_data['2nd_class_standard'] = array( 515 'code' => 'royal_mail.2nd_class_standard', 516 'title' => $title, 517 'cost' => $cost, 518 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 519 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 520 ); 521 } 522 } 523 524 $europe = array( 525 'AL', 526 'AD', 527 'AM', 528 'AT', 529 'AZ', 530 'BY', 531 'BE', 532 'BG', 533 'XC', 534 'HR', 535 'CY', 536 'CZ', 537 'DK', 538 'EE', 539 'FO', 540 'FI', 541 'FR', 542 'GE', 543 'DE', 544 'GI', 545 'GR', 546 'GL', 547 'HU', 548 'IS', 549 'IE', 550 'IT', 551 'KZ', 552 'KV', 553 'KG', 554 'LV', 555 'LI', 556 'LT', 557 'LU', 558 'MK', 559 'MT', 560 'MD', 561 'CS', 562 'NL', 563 'NO', 564 'PL', 565 'PT', 566 'RO', 567 'RU', 568 'SM', 569 'CS', 570 'SK', 571 'SI', 572 'ES', 573 'SE', 574 'CH', 575 'TJ', 576 'TR', 577 'TM', 578 'UA', 579 'UZ', 580 'VA' 581 ); 582 583 $non_eu = array( 584 'AL', 585 'AD', 586 'AM', 587 'AZ', 588 'BY', 589 'XC', 590 'FO', 591 'GE', 592 'GL', 593 'IS', 594 'KZ', 595 'KV', 596 'KG', 597 'LI', 598 'MK', 599 'MD', 600 'CS', 601 'NO', 602 'RU', 603 'SM', 604 'CS', 605 'CH', 606 'TJ', 607 'TR', 608 'TM', 609 'UA', 610 'UZ', 611 'VA' 612 ); 613 614 $zone_1 = array( 615 'AF', 616 'NA', 617 'DZ', 618 'AO', 619 'AI', 620 'AG', 621 'AR', 622 'AW', 623 'XA', 624 'BS', 625 'BH', 626 'BD', 627 'BB', 628 'BZ', 629 'BJ', 630 'BM', 631 'BT', 632 'BO', 633 'BX', 634 'BW', 635 'BR', 636 'VG', 637 'BN', 638 'BF', 639 'BI', 640 'KH', 641 'CM', 642 'CA', 643 'CV', 644 'KY', 645 'CF', 646 'CE', 647 'TD', 648 'CL', 649 'CN', 650 'CO', 651 'KM', 652 'CD', 653 'CG', 654 'CR', 655 'CU', 656 'CB', 657 'DJ', 658 'DM', 659 'DO', 660 'EC', 661 'EG', 662 'SV', 663 'GQ', 664 'ER', 665 'ET', 666 'FK', 667 'GF', 668 'GA', 669 'GM', 670 'GH', 671 'GD', 672 'GP', 673 'GT', 674 'GN', 675 'GW', 676 'GY', 677 'HT', 678 'HN', 679 'HK', 680 'IN', 681 'ID', 682 'IR', 683 'IQ', 684 'IL', 685 'CI', 686 'JM', 687 'JP', 688 'JO', 689 'KE', 690 'KW', 691 'LB', 692 'LS', 693 'LR', 694 'LY', 695 'MG', 696 'YT', 697 'MW', 698 'MY', 699 'MV', 700 'ML', 701 'MQ', 702 'MR', 703 'MU', 704 'XL', 705 'MX', 706 'MN', 707 'MS', 708 'MA', 709 'MZ', 710 'MM', 711 'NA', 712 'NP', 713 'NI', 714 'NE', 715 'NG', 716 'KP', 717 'OM', 718 'PK', 719 'PA', 720 'PY', 721 'PE', 722 'PH', 723 'PR', 724 'QA', 725 'RE', 726 'RW', 727 'ST', 728 'SA', 729 'SN', 730 'SC', 731 'SL', 732 'SO', 733 'ZA', 734 'KR', 735 'SD', 736 'LK', 737 'SX', 738 'SH', 739 'KN', 740 'LC', 741 'SF', 742 'VC', 743 'SD', 744 'SR', 745 'SZ', 746 'SY', 747 'TW', 748 'TZ', 749 'TH', 750 'TP', 751 'TG', 752 'TT', 753 'XT', 754 'TN', 755 'CP', 756 'TC', 757 'UG', 758 'AE', 759 'UY', 760 'US', 761 'VU', 762 'VE', 763 'VN', 764 'WF', 765 'EH', 766 'YE', 767 'ZM', 768 'ZW' 769 ); 770 771 $zone_2 = array( 772 'AU', 773 'IO', 774 'CX', 775 'CK', 776 'FJ', 777 'PF', 778 'TF', 779 'KI', 780 'LA', 781 'MO', 782 'NR', 783 'NC', 784 'NZ', 785 'NU', 786 'PW', 787 'PG', 788 'PN', 789 'SG', 790 'SB', 791 'TK', 792 'TO', 793 'TV', 794 'WS' 795 ); 796 797 // International Standard 798 if ($this->config->get('shipping_royal_mail_international_standard_status') && $address['iso_code_2'] != 'GB') { 799 $cost = 0; 800 801 $rates = array(); 802 803 // EU 804 if (in_array($address['iso_code_2'], $europe)) { 805 $rates = explode(',', $this->config->get('shipping_royal_mail_international_standard_eu_rate')); 806 } 807 808 // World Zones 1 809 if (in_array($address['iso_code_2'], $zone_1)) { 810 $rates = explode(',', $this->config->get('shipping_royal_mail_international_standard_zone_1_rate')); 811 } 812 813 // World Zones 2 814 if (in_array($address['iso_code_2'], $zone_2)) { 815 $rates = explode(',', $this->config->get('shipping_royal_mail_international_standard_zone_2_rate')); 816 } 817 818 foreach ($rates as $rate) { 819 $data = explode(':', $rate); 820 821 if ($data[0] >= $weight) { 822 if (isset($data[1])) { 823 $cost = $data[1]; 824 } 825 826 break; 827 } 828 } 829 830 if ((float)$cost) { 831 $title = $this->language->get('text_international_standard'); 832 833 if ($this->config->get('shipping_royal_mail_display_weight')) { 834 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 835 } 836 837 $quote_data['international_standard'] = array( 838 'code' => 'royal_mail.international_standard', 839 'title' => $title, 840 'cost' => $cost, 841 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 842 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 843 ); 844 } 845 } 846 847 // International Tracked & Signed 848 $tracked_signed = array( 849 'AD', 850 'AR', 851 'AT', 852 'BY', 853 'BE', 854 'BG', 855 'CA', 856 'KY', 857 'HR', 858 'CZ', 859 'DK', 860 'EC', 861 'FI', 862 'FR', 863 'DE', 864 'GI', 865 'GR', 866 'HK', 867 'HU', 868 'IS', 869 'IT', 870 'JP', 871 'LI', 872 'LT', 873 'LU', 874 'MT', 875 'NL', 876 'NZ', 877 'PL', 878 'PT', 879 'RO', 880 'SM', 881 'SG', 882 'SK', 883 'SI', 884 'KR', 885 'SE', 886 'CH', 887 'TH', 888 'TT', 889 'US', 890 'VA' 891 ); 892 893 if ($this->config->get('shipping_royal_mail_international_tracked_signed_status') && in_array($address['iso_code_2'], $tracked_signed)) { 894 $cost = 0; 895 896 $rates = array(); 897 898 // EU 899 if (in_array($address['iso_code_2'], $europe)) { 900 $rates = explode(',', $this->config->get('shipping_royal_mail_international_tracked_signed_eu_rate')); 901 } 902 903 // World Zones 1 904 if (in_array($address['iso_code_2'], $zone_1)) { 905 $rates = explode(',', $this->config->get('shipping_royal_mail_international_tracked_signed_zone_1_rate')); 906 } 907 908 // World Zones 2 909 if (in_array($address['iso_code_2'], $zone_2)) { 910 $rates = explode(',', $this->config->get('shipping_royal_mail_international_tracked_signed_zone_2_rate')); 911 } 912 913 foreach ($rates as $rate) { 914 $data = explode(':', $rate); 915 916 if ($data[0] >= $weight) { 917 if (isset($data[1])) { 918 $cost = $data[1]; 919 } 920 921 break; 922 } 923 } 924 925 if ((float)$cost) { 926 $title = $this->language->get('text_international_tracked_signed'); 927 928 if ($this->config->get('shipping_royal_mail_display_weight')) { 929 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 930 } 931 932 $quote_data['international_tracked_signed'] = array( 933 'code' => 'royal_mail.international_tracked_signed', 934 'title' => $title, 935 'cost' => $cost, 936 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 937 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 938 ); 939 } 940 } 941 942 // International Tracked 943 $tracked = array( 944 'AD', 945 'AU', 946 'AT', 947 'BE', 948 'BR', 949 'CA', 950 'XC', 951 'HR', 952 'DK', 953 'EE', 954 'FI', 955 'FR', 956 'DE', 957 'HK', 958 'HU', 959 'IS', 960 'IN', 961 'IE', 962 'LV', 963 'LI', 964 'LT', 965 'LU', 966 'MY', 967 'MT', 968 'NL', 969 'NZ', 970 'PL', 971 'PT', 972 'SG', 973 'ES', 974 'SE', 975 'CH', 976 'US' 977 ); 978 979 if ($this->config->get('shipping_royal_mail_international_tracked_status') && in_array($address['iso_code_2'], $tracked)) { 980 $cost = 0; 981 982 $rates = array(); 983 984 // EU 985 if (in_array($address['iso_code_2'], $europe) && !in_array($address['iso_code_2'], $non_eu)) { 986 $rates = explode(',', $this->config->get('shipping_royal_mail_international_tracked_eu_rate')); 987 } 988 989 // Non EU 990 if (in_array($address['iso_code_2'], $non_eu)) { 991 $rates = explode(',', $this->config->get('shipping_royal_mail_international_tracked_non_eu_rate')); 992 } 993 994 // World Zones 1 995 if (in_array($address['iso_code_2'], $zone_1)) { 996 $rates = explode(',', $this->config->get('shipping_royal_mail_international_tracked_zone_1_rate')); 997 } 998 999 // World Zones 2 1000 if (in_array($address['iso_code_2'], $zone_2)) { 1001 $rates = explode(',', $this->config->get('shipping_royal_mail_international_tracked_zone_2_rate')); 1002 } 1003 1004 foreach ($rates as $rate) { 1005 $data = explode(':', $rate); 1006 1007 if ($data[0] >= $weight) { 1008 if (isset($data[1])) { 1009 $cost = $data[1]; 1010 } 1011 1012 break; 1013 } 1014 } 1015 1016 if ((float)$cost) { 1017 $title = $this->language->get('text_international_tracked'); 1018 1019 if ($this->config->get('shipping_royal_mail_display_weight')) { 1020 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 1021 } 1022 1023 $quote_data['international_tracked'] = array( 1024 'code' => 'royal_mail.international_tracked', 1025 'title' => $title, 1026 'cost' => $cost, 1027 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 1028 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 1029 ); 1030 } 1031 } 1032 1033 // International Signed 1034 $signed = array( 1035 'AF', 1036 'NA', 1037 'AL', 1038 'DZ', 1039 'AO', 1040 'AI', 1041 'AG', 1042 'AM', 1043 'AW', 1044 'XA', 1045 'AU', 1046 'AZ', 1047 'BS', 1048 'BH', 1049 'BD', 1050 'BB', 1051 'BZ', 1052 'BJ', 1053 'BM', 1054 'BT', 1055 'BO', 1056 'BX', 1057 'BA', 1058 'BW', 1059 'BR', 1060 'IO', 1061 'VG', 1062 'BN', 1063 'BF', 1064 'BI', 1065 'KH', 1066 'CM', 1067 'XC', 1068 'CV', 1069 'CF', 1070 'CE', 1071 'TD', 1072 'CL', 1073 'CN', 1074 'CX', 1075 'CX', 1076 'CO', 1077 'KM', 1078 'CD', 1079 'CG', 1080 'CK', 1081 'CR', 1082 'CU', 1083 'CB', 1084 'CY', 1085 'DJ', 1086 'DM', 1087 'DO', 1088 'EG', 1089 'SV', 1090 'GQ', 1091 'ER', 1092 'EE', 1093 'ET', 1094 'FK', 1095 'FO', 1096 'FJ', 1097 'GF', 1098 'PF', 1099 'TF', 1100 'GA', 1101 'GM', 1102 'GE', 1103 'GH', 1104 'GL', 1105 'GD', 1106 'GP', 1107 'GT', 1108 'GN', 1109 'GW', 1110 'GY', 1111 'HT', 1112 'HN', 1113 'IN', 1114 'ID', 1115 'IR', 1116 'IQ', 1117 'IL', 1118 'CI', 1119 'JM', 1120 'JO', 1121 'KZ', 1122 'KE', 1123 'KI', 1124 'KV', 1125 'KW', 1126 'KG', 1127 'LA', 1128 'LV', 1129 'LB', 1130 'LS', 1131 'LR', 1132 'LY', 1133 'MO', 1134 'MK', 1135 'MG', 1136 'YT', 1137 'MW', 1138 'MY', 1139 'MV', 1140 'ML', 1141 'MQ', 1142 'MR', 1143 'MU', 1144 'XL', 1145 'MX', 1146 'MD', 1147 'MN', 1148 'CS', 1149 'MS', 1150 'MA', 1151 'MZ', 1152 'MM', 1153 'NA', 1154 'NR', 1155 'NP', 1156 'NC', 1157 'NI', 1158 'NE', 1159 'NG', 1160 'NU', 1161 'KP', 1162 'NO', 1163 'OM', 1164 'PK', 1165 'PW', 1166 'PA', 1167 'PG', 1168 'PY', 1169 'PE', 1170 'PH', 1171 'PN', 1172 'PR', 1173 'QA', 1174 'RE', 1175 'RU', 1176 'RW', 1177 'ST', 1178 'SA', 1179 'SN', 1180 'CS', 1181 'SC', 1182 'SL', 1183 'SB', 1184 'SO', 1185 'ZA', 1186 'SD', 1187 'ES', 1188 'LK', 1189 'SX', 1190 'SH', 1191 'KN', 1192 'LC', 1193 'SF', 1194 'VC', 1195 'SD', 1196 'SR', 1197 'SZ', 1198 'SY', 1199 'TW', 1200 'TJ', 1201 'TZ', 1202 'TP', 1203 'TG', 1204 'TK', 1205 'TO', 1206 'XT', 1207 'TN', 1208 'TR', 1209 'CP', 1210 'TM', 1211 'TC', 1212 'TV', 1213 'UG', 1214 'UA', 1215 'AE', 1216 'UY', 1217 'UZ', 1218 'VU', 1219 'VE', 1220 'VN', 1221 'WF', 1222 'EH', 1223 'WS', 1224 'YE', 1225 'ZM', 1226 'ZW' 1227 ); 1228 1229 if ($this->config->get('shipping_royal_mail_international_signed_status') && in_array($address['iso_code_2'], $signed)) { 1230 $cost = 0; 1231 1232 $rates = array(); 1233 1234 // EU 1235 if (in_array($address['iso_code_2'], $europe)) { 1236 $rates = explode(',', $this->config->get('shipping_royal_mail_international_signed_eu_rate')); 1237 } 1238 1239 // World Zones 1 1240 if (in_array($address['iso_code_2'], $zone_1)) { 1241 $rates = explode(',', $this->config->get('shipping_royal_mail_international_signed_zones_1_rate')); 1242 } 1243 1244 // World Zones 2 1245 if (in_array($address['iso_code_2'], $zone_2)) { 1246 $rates = explode(',', $this->config->get('shipping_royal_mail_international_signed_zones_2_rate')); 1247 } 1248 1249 foreach ($rates as $rate) { 1250 $data = explode(':', $rate); 1251 1252 if ($data[0] >= $weight) { 1253 if (isset($data[1])) { 1254 $cost = $data[1]; 1255 } 1256 1257 break; 1258 } 1259 } 1260 1261 if ((float)$cost) { 1262 $title = $this->language->get('text_international_signed'); 1263 1264 if ($this->config->get('shipping_royal_mail_display_weight')) { 1265 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 1266 } 1267 1268 $quote_data['international_signed'] = array( 1269 'code' => 'royal_mail.international_signed', 1270 'title' => $title, 1271 'cost' => $cost, 1272 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 1273 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 1274 ); 1275 } 1276 } 1277 1278 // Economy 1279 if ($this->config->get('shipping_royal_mail_international_economy_status') && $address['iso_code_2'] != 'GB') { 1280 $cost = 0; 1281 1282 $rates = explode(',', $this->config->get('shipping_royal_mail_international_economy_rate')); 1283 1284 foreach ($rates as $rate) { 1285 $data = explode(':', $rate); 1286 1287 if ($data[0] >= $weight) { 1288 if (isset($data[1])) { 1289 $cost = $data[1]; 1290 } 1291 1292 break; 1293 } 1294 } 1295 1296 if ((float)$cost) { 1297 $title = $this->language->get('text_international_economy'); 1298 1299 if ($this->config->get('shipping_royal_mail_display_weight')) { 1300 $title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')'; 1301 } 1302 1303 $quote_data['international_economy'] = array( 1304 'code' => 'royal_mail.international_economy', 1305 'title' => $title, 1306 'cost' => $cost, 1307 'tax_class_id' => $this->config->get('shipping_royal_mail_tax_class_id'), 1308 'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_royal_mail_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency']) 1309 ); 1310 } 1311 } 1312 } 1313 1314 $method_data = array(); 1315 1316 if ($quote_data) { 1317 $method_data = array( 1318 'code' => 'royal_mail', 1319 'title' => $this->language->get('text_title'), 1320 'quote' => $quote_data, 1321 'sort_order' => $this->config->get('shipping_royal_mail_sort_order'), 1322 'error' => false 1323 ); 1324 } 1325 1326 return $method_data; 1327 } 1328 }