I have got to where I need to update my shipping modules. I had some coded by a certified developer who I now cannot contact so I am trying to update them myself.
I have copied, altered, and created new shipping module files using the table rate module. That all works but my old modules had a place where I had to enter the minimum and maximum shipping weighs and costs. I can get the four new boxes to show in the modules admin page. That was the easy bit.
The problem comes when I try to add the code required to enable these inputted figures in the shipping modules. The old website has a file called 'abstract_banded_shipping_module.php' in the classes folder. I have found the equivalent folder in 1.0.8.20 in system/versioned/1.0.7.8/abstract_shipping_module.php. These fields allow us to restrict the weight and order value depending on the shipping method.
What I am having trouble with is adding the code from the old website into the new websites file. I need to add
Into the new file. I cannot seem to get it to work, so am probably putting it in the wrong place. In the old file it comes into the public function update_status() { section, but when I add it in there I get errors and the shipping modules do not work. I have added the code as// Only ship if packet value exceeds method minimum value
if ( ($order_total / $this->shipping_num_boxes) < $this->base_constant('MIN_VALUE')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MIN_BOX_VALUE, ($order_total / $this->shipping_num_boxes), $this->base_constant('MIN_VALUE')));
}
// Only ship if packet value does not exceed method maximum value
if ($this->base_constant('MAX_VALUE') > 0 && ($order_total / $this->shipping_num_boxes) > $this->base_constant('MAX_VALUE')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MAX_BOX_VALUE, ($order_total / $this->shipping_num_boxes), $this->base_constant('MAX_VALUE')));
}
// Only ship if packet weight exceeds method minimum weight
if ( $this->shipping_weight < $this->base_constant('MIN_WEIGHT')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MIN_BOX_WEIGHT, $this->shipping_weight, $this->base_constant('MIN_WEIGHT')));
}
// Only ship if packet weight does not exceed method maximum weight
if ($this->base_constant('MAX_WEIGHT') > 0 && $this->shipping_weight > $this->base_constant('MAX_WEIGHT')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MAX_BOX_WEIGHT, $this->shipping_weight, $this->base_constant('MAX_WEIGHT')));
}
Code: Select all
public function update_status() {
if ($this->enabled && isset($GLOBALS['order']->delivery['country']['id'])) {
$this->update_status_by($GLOBALS['order']->delivery);
}
// Only ship if packet value exceeds method minimum value
if ( ($order_total / $this->shipping_num_boxes) < $this->base_constant('MIN_VALUE')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MIN_BOX_VALUE, ($order_total / $this->shipping_num_boxes), $this->base_constant('MIN_VALUE')));
}
// Only ship if packet value does not exceed method maximum value
if ($this->base_constant('MAX_VALUE') > 0 && ($order_total / $this->shipping_num_boxes) > $this->base_constant('MAX_VALUE')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MAX_BOX_VALUE, ($order_total / $this->shipping_num_boxes), $this->base_constant('MAX_VALUE')));
}
// Only ship if packet weight exceeds method minimum weight
if ( $this->shipping_weight < $this->base_constant('MIN_WEIGHT')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MIN_BOX_WEIGHT, $this->shipping_weight, $this->base_constant('MIN_WEIGHT')));
}
// Only ship if packet weight does not exceed method maximum weight
if ($this->base_constant('MAX_WEIGHT') > 0 && $this->shipping_weight > $this->base_constant('MAX_WEIGHT')) {
$this->disable(sprintf(COUNTRY_BANDED_SHIPPING_MAX_BOX_WEIGHT, $this->shipping_weight, $this->base_constant('MAX_WEIGHT')));
}
}