Can you post the first bit mof your code? What do you have $this->code = set to at around line 30. Also, what is your file and class called?
Absolute
Can you post the first bit mof your code? What do you have $this->code = set to at around line 30. Also, what is your file and class called?
Absolute
Thanks,
all constants declared in:
\shop\includes\languages\english\modules\shipping\mycourier.php
created mycourier.php in:
\shop\includes\modules\shipping
changed the class name to mycourier
I created a function:
function do_calc($shipping_num_boxes, $total_weight){
//my code here
return 123; //for now just return a shipping cost of $123.00
}
I changed function quote to be:
function quote($method = '') {
global $order,$cart, $shipping_weight, $shipping_num_boxes, $total_weight;
//DO CALCULATION HERE
$mycalc = $this->do_calc($shipping_num_boxes, $total_weight);
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_MYCOURIER_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_MYCOURIER_TEXT_WAY,
'cost' => $mycalc)));
....rest of store pickup
The code in do_calc() is working okay as the correct amount gets put in the order, but I cant get to the payment in my module, only in built in store pickup module.
Thanks for the help
That all looks fine.
The only other thing is, you should havbe something like
Can you post his bit of code? this->code should equal the name of your shipping module, exactly as the filename appears. Is this included in your code?Code:class mycourier extends base { function mycourier() { this->code = ...........
Absolute
Thanks Again:
This is copied straight from the StorePickup shipping module except I have changed the constants, and the part in red, is that what you are refering to and where you think it is going wrong. I dont understand it, I thought it was just a description.
function mycourier() {
global $order, $db;
$this->code = 'MYCOURIER';
$this->title = MODULE_SHIPPING_MYCOURIER_TEXT_TITLE;
$this->description = MODULE_SHIPPING_MYCOURIER_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_MYCOURIER_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_MYCOURIER_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_ITEM_MYCOURIER_BASIS;
$this->enabled = ((MODULE_SHIPPING_MYCOURIER_STATUS == 'True') ? true : false);
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_MYCOURIER_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . "
where geo_zone_id = '" . MODULE_SHIPPING_MYCOURIER_ZONE . "'
and zone_country_id = '" . $order->delivery['country']['id'] . "'
order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
}
Thanks
this->code is used to name the choosen shipping module. So if you have a shipping module, and the file is called "mycourier.php", and $this->code equals "MYCOURIER", then the class won't be found. You need to change this->code to lower case, to match the class name. So the line should read:
This should fix your little bug. If not, let me know.Code:$this->code = 'mycourier';
Absolute
Woohoo,
thanks heaps,
working now.
what a big problem, for such a small thing.
Thanks