At first, everything works just fine. Shipping estimates come up as expected, with my flat rate module showing if the order is over the total specified. I notice that if I click on a Delivery Method the Shopping Cart page reloads. That is OK, unless I click on my new Flat Rate module. When that happens, the Shopping Cart page no longer works (blank screen) and I get an error in the server log as follows:
PHP Fatal error: Cannot redeclare get_shippable_total() (previously declared in /shop/includes/modules/shipping/siriusflat.php:42) in /shop/includes/modules/shipping/siriusflat.php on line 41
It does not make sense to me (I'm not good at code) that the declaration can happen one line after the line that throws the error.
Here is the code where the error happens, lines 41-44:
Code: Select all
41 function get_shippable_total() {
42 global $order, $currencies;
43
44 $order_total = (('physical' === $order->content_type) ? $_SESSION['cart']->show_total() : 0);
Code: Select all
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
class siriusflat extends abstract_shipping_module {
const CONFIG_KEY_BASE = 'MODULE_SHIPPING_SIRIUSFLAT_';
// class methods
public function quote($method = '') {
global $order;
$this->quotes = [
'id' => $this->code,
'module' => MODULE_SHIPPING_SIRIUSFLAT_TEXT_TITLE,
'methods' => [[
'id' => $this->code,
'title' => MODULE_SHIPPING_SIRIUSFLAT_TEXT_WAY,
'cost' => (float)$this->base_constant('COST') + $this->calculate_handling(),
]],
];
$this->quote_common();
function get_shippable_total() {
global $order, $currencies;
$order_total = (('physical' === $order->content_type) ? $_SESSION['cart']->show_total() : 0);
if ('mixed' === $order->content_type) {
foreach ($order->products as $product) {
foreach (($product['attributes'] ?? []) as $option => $value) {
$virtual_check = $GLOBALS['db']->query(sprintf(<<<'EOSQL'
SELECT COUNT(*) AS total
FROM products_attributes pa
INNER JOIN products_attributes_download pad
ON pa.products_attributes_id = pad.products_attributes_id
WHERE pa.products_id = %d AND pa.options_values_id = %d
EOSQL
, (int)$product['id'], (int)$value['value_id']))->fetch_assoc();
if ($virtual_check['total'] > 0) {
// if any attribute is downloadable, the product is virtual
// and doesn't count; so skip to the next product
// without adding the line total
continue 2;
}
}
$order_total += $currencies->calculate_price($product['final_price'], $product['tax'], $product['qty']);
}
}
return $order_total;
}
if ((get_shippable_total()) > $this->base_constant('ORDERSOVER')) {
return $this->quotes;
}
}
protected function get_parameters() {
return [
$this->config_key_base . 'STATUS' => [
'title' => 'Enable Flat Shipping',
'value' => 'True',
'desc' => 'Do you want to offer flat rate shipping?',
'set_func' => "Config::select_one(['True', 'False'], ",
],
$this->config_key_base . 'ORDERSOVER' => [
'title' => 'Orders over ',
'value' => '0',
'desc' => 'Use flat rate for order totals over this amount.',
],
$this->config_key_base . 'COST' => [
'title' => 'Shipping Cost',
'value' => '5.00',
'desc' => 'The shipping cost for all orders using this shipping method.',
],
$this->config_key_base . 'TAX_CLASS' => [
'title' => 'Tax Class',
'value' => '0',
'desc' => 'Use the following tax class on the shipping fee.',
'use_func' => 'Tax::get_class_title',
'set_func' => 'Config::select_tax_class(',
],
$this->config_key_base . 'ZONE' => [
'title' => 'Shipping Zone',
'value' => '0',
'desc' => 'If a zone is selected, only enable this shipping method for that zone.',
'use_func' => 'geo_zone::fetch_name',
'set_func' => 'Config::select_geo_zone(',
],
$this->config_key_base . 'SORT_ORDER' => [
'title' => 'Sort Order',
'value' => '0',
'desc' => 'Sort order of display.',
],
];
}
}
[code}
$order_total = (('physical' === $order->content_type) ? $_SESSION['cart']->show_total() : 0);
[/code]
Any idea of what is going on here? Maybe the action of clicking on Shipping Options be eliminated some way?
CE Phoenix v1.0.9.1
PHP Version 7.4.33
Thanks for any help offered!