Our products have recently gained interest from members of the British Forces serving overseas, and we'd like to start selling to them.
We sell loose leaf tea using our online store, and send them in our own packaging. The shipping extension serves us well for UK addresses, so that's all fine.
For those of you who aren't aware The British Armed Forces have their own Post service, called the British Forces Post Office (known locally as BFPO), which delivers mail to soldiers serving overseas. It's cheaper than regular mail, as it is subsidized by the British Government. For the purpose of this post, the details can be found here: https://www.gov.uk/british-forces-post-office-services.
Now, instead of creating/paying for a brand new shipping option extension that is separate to the Royal Mail option, I want to include BFPO as an option within the Royal Mail extension, in the same way that First Class Standard, Second Class Recorded etc. are options. I've gone and replaced the 'Surface' option (what even is that?!) in both the Admin front-end, and in the controller/model/view/language files. All I have done is copy/paste the First Class Standard Post code, and adjusted the prefixes to 'bfpo' across the files all.
The BFPO tab shows up in the Admin section all fine, and I can enable/disable and enter weight-based rates as normal. However, when I do a test order in the checkout, the BFPO option does now show up in the Shipping Method section. The only option is the Royal Mail First Class, which is the only other option that I have enabled.
The Code:
catalog/model/shipping/royal_mail.php
Code: Select all
// 1st Class Standard
if ($this->config->get('royal_mail_1st_class_standard_status') && $address['iso_code_2'] == 'GB') {
$cost = 0;
$insurance = 0;
$rates = explode(',', $this->config->get('royal_mail_1st_class_standard_rate'));
foreach ($rates as $rate) {
$data = explode(':', $rate);
if ($data[0] >= $weight) {
if (isset($data[1])) {
$cost = $data[1];
}
break;
}
}
$rates = explode(',', $this->config->get('royal_mail_1st_class_standard_insurance'));
foreach ($rates as $rate) {
$data = explode(':', $rate);
if ($data[0] >= $sub_total) {
if (isset($data[1])) {
$insurance = $data[1];
}
break;
}
}
if ((float)$cost) {
$title = $this->language->get('text_1st_class_standard');
if ($this->config->get('royal_mail_display_weight')) {
$title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')';
}
if ($this->config->get('royal_mail_display_insurance') && (float)$insurance) {
$title .= ' (' . $this->language->get('text_insurance') . ' ' . $this->currency->format($insurance) . ')';
}
$quote_data['1st_class_standard'] = array(
'code' => 'royal_mail.1st_class_standard',
'title' => $title,
'cost' => $cost,
'tax_class_id' => $this->config->get('royal_mail_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('royal_mail_tax_class_id'), $this->config->get('config_tax')))
);
}
}
// BFPO
if ($this->config->get('bfpo_status') && $address['iso_code_2'] == 'GB') {
$cost = 0;
$insurance = 0;
$rates = explode(',', $this->config->get('bfpo_rate'));
foreach ($rates as $rate) {
$data = explode(':', $rate);
if ($data[0] >= $weight) {
if (isset($data[1])) {
$cost = $data[1];
}
break;
}
}
$rates = explode(',', $this->config->get('bfpo_insurance'));
foreach ($rates as $rate) {
$data = explode(':', $rate);
if ($data[0] >= $sub_total) {
if (isset($data[1])) {
$insurance = $data[1];
}
break;
}
}
if ((float)$cost) {
$title = $this->language->get('text_bfpo');
if ($this->config->get('royal_mail_display_weight')) {
$title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')';
}
$quote_data['bfpo'] = array(
'code' => 'bfpo',
'title' => $title,
'cost' => $cost,
'tax_class_id' => $this->config->get('royal_mail_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('royal_mail_tax_class_id'), $this->config->get('config_tax')))
);
}
}
Any ideas as to what's going wrong?
Thanks