Originally Posted by
2mymall
Ran into a problem with "perweightunit.php"
It does not have a //class constructor.
Where do I add the code in "perweightunit.php"?
The comment (line that begins with //) may be missing, but comments are generally ignored by code. For this module the constructor identifier in ZC 1.5.1 was placed within a different comment structure (/* comment that can span many lines */).
You are looking for a section that begins or includes the word function with at least one space before and after followed by either the name of the class (perweightunit) or for code that works in old ZC versions but will work in PHP 7.0+ you would be looking for __construct.
The first type of constructor is included in ZC 1.5.1 shipping module perweightunit.php:
Code:
/**
* Constructor
*
* @return perweightunit
*/
function perweightunit() {
global $order, $db;
$this->code = 'perweightunit';
$this->title = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE;
$this->description = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_PERWEIGHTUNIT_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_BASIS;
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_PERWEIGHTUNIT_STATUS == 'True') ? true : false);
}
if ($this->enabled) {
// check MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING_METHOD is in
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING_METHOD'");
if ($check_query->EOF) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING_METHOD', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_PERWEIGHTUNIT_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . "
where geo_zone_id = '" . MODULE_SHIPPING_PERWEIGHTUNIT_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;
}
}
}
Bookmarks