Forums / Addon Shipping Modules / Shipping Surcharge [Support Thread]

Shipping Surcharge [Support Thread]

Results 1 to 20 of 23
03 Apr 2021, 10:20
#1
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Posts:
10,620
Plugin Contributions:
212

Shipping Surcharge [Support Thread]

The Shipping Surcharge plugin allows you to impose an additional shipping charge for a specific zone.

https://www.zen-cart.com/downloads.php?do=file&id=2308
03 Jun 2021, 17:35
#2
welshop_com avatar

welshop_com

Zen Follower

Join Date:
Aug 2004
Posts:
262
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

Brilliant little Mod - I didn't want to restructure my whole shipping module for Northern Ireland and Isle of Man so this was a beautiful workaround.

Nice1 SWGuy :thumbsup:
01 Jul 2021, 18:28
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Posts:
10,620
Plugin Contributions:
212

Re: Shipping Surcharge [Support Thread]

Updated version 1.1 has weight and value thresholds in case you want to check those before imposing the surcharge.
13 Mar 2022, 23:39
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,907
Plugin Contributions:
1

Re: Shipping Surcharge [Support Thread]

swguy:

Updated version 1.1 has weight and value thresholds in case you want to check those before imposing the surcharge.

Looks like this version may have introduced an issue for stores performing a new install. Discussion is had at the following forum thread: https://www.zen-cart.com/showthread.php?228689-Error-when-installing-the-shipping-surcharge-module
14 Mar 2022, 11:15
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Posts:
10,620
Plugin Contributions:
212

Re: Shipping Surcharge [Support Thread]

This issue has been fixed in version 1.2, which is now available.
18 Mar 2022, 14:05
#6
semi_crazy avatar

semi_crazy

New Zenner

Join Date:
Mar 2022
Posts:
8
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

swguy:

This issue has been fixed in version 1.2, which is now available.


Thank You Very Much! It works now. (In reference to thread "Error when installing the shipping surcharge module")
21 Mar 2022, 01:13
#7
semi_crazy avatar

semi_crazy

New Zenner

Join Date:
Mar 2022
Posts:
8
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

I like the ability to add a surcharge using a weight threshold in the shipping surcharge module and I was wondering if it would be possible to add dimension thresholds for oversized items that UPS, FedEx, USPS or others charge more to ship. Thanks.
21 Mar 2022, 10:36
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Posts:
10,620
Plugin Contributions:
212

Re: Shipping Surcharge [Support Thread]

This could certainly be done but it would not be the kind of thing I would release as an open source module. You are welcome to work with me or any other developer if you'd like to make this change on your cart.
12 Aug 2022, 12:40
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Posts:
10,620
Plugin Contributions:
212

Re: Shipping Surcharge [Support Thread]

There was a bug in specifying the zone for this module that has been fixed in the new version.
16 Apr 2025, 16:33
#10
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
346
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

I'm looking for a module for "tariff surcharge" and this module looks good.

I tested it under zc158 and it shows some warning.

1.
[PHP][16-Apr-2025 12:05:52 America/New_York] Request URI: /index.php?main_page=checkout_one, IP address: xxxx, Language id 1
#0 /includes/modules/order_total/ot_shippingsurcharge.php(78): zen_debug_error_handler()
#1 /includes/classes/order_total.php(99): ot_shippingsurcharge->process()
#2 /includes/modules/pages/checkout_one/header_php.php(347): order_total->process()
#3 /index.php(35): require('/home4/...')
--> PHP Warning: A non-numeric value encountered in /includes/modules/order_total/ot_shippingsurcharge.php on line 78.[/PHP]

Line 78 is the following.

[PHP]$shipping_surcharge = ($order->info['subtotal'] * (MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT/100));[/PHP]

My fix. Change this line to

[PHP]$shipping_surcharge = ($order->info['subtotal'] * ((float)MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT/100));[/PHP]

2.
[PHP][16-Apr-2025 12:16:48 America/New_York] Request URI: /index.php?main_page=checkout_one, IP address: xxx, Language id 1
#0 /includes/modules/order_total/ot_shippingsurcharge.php(89): zen_debug_error_handler()
#1 /includes/classes/order_total.php(99): ot_shippingsurcharge->process()
#2 /includes/modules/pages/checkout_one/header_php.php(347): order_total->process()
#3 /index.php(35): require('/home4/...')
--> PHP Warning: Undefined array key "Sales Tax" in /includes/modules/order_total/ot_shippingsurcharge.php on line 89.[/PHP]

Line 89 is the following.
[PHP]$order->info['tax_groups']["$tax_description"] += zen_calculate_tax($shipping_surcharge, $tax);[/PHP]

Not sure how to fix it. My fix is to comment the this line out. It seems no affect on my checkout page.

Also this surcharge doesn't apply on my sales tax (local sales tax), which seems normal anyway, since it is a surcharge.
16 Apr 2025, 19:49
#11
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Posts:
332
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

Your second problem is due to the fact there is no tax applied but module try to calculate it anyway. Suppressing this line won't work if you want to apply some tax on the surcharge, which is probably the case if you already applied some tax everywhere else.
You can modify code as follow:
[PHP] if ($charge_it) {
$tax_address = zen_get_tax_locations();
$tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);

// calculate from flat fee or percentage
if (substr(MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT, -1) == '%') {
$shipping_surcharge = ($order->info['subtotal'] * ((float)MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT/100));
} else {
$shipping_surcharge = MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT;
}
$order->info['total'] += $shipping_surcharge;

if ($tax > 0) {
$tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);

$order->info['tax'] += zen_calculate_tax($shipping_surcharge, $tax);
$order->info['tax_groups'][$tax_description] += zen_calculate_tax($shipping_surcharge, $tax);
$order->info['total'] += zen_calculate_tax($shipping_surcharge, $tax);
if (DISPLAY_PRICE_WITH_TAX == 'true') {
$shipping_surcharge += zen_calculate_tax($shipping_surcharge, $tax);
}
}

$this->output[] = array('title' => $this->title . ':',
'text' => $currencies->format($shipping_surcharge, true, $order->info['currency'], $order->info['currency_value']),
'value' => $shipping_surcharge);
}[/PHP]
17 Apr 2025, 18:09
#12
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
346
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

pilou2:

Your second problem is due to the fact there is no tax applied but module try to calculate it anyway. Suppressing this line won't work if you want to apply some tax on the surcharge, which is probably the case if you already applied some tax everywhere else.
You can modify code as follow:
[PHP] if ($charge_it) {
$tax_address = zen_get_tax_locations();
$tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);

// calculate from flat fee or percentage
if (substr(MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT, -1) == '%') {
$shipping_surcharge = ($order->info['subtotal'] * ((float)MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT/100));
} else {
$shipping_surcharge = MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_AMOUNT;
}
$order->info['total'] += $shipping_surcharge;

if ($tax > 0) {
$tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_SHIPPINGSURCHARGE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);

$order->info['tax'] += zen_calculate_tax($shipping_surcharge, $tax);
$order->info['tax_groups'][$tax_description] += zen_calculate_tax($shipping_surcharge, $tax);
$order->info['total'] += zen_calculate_tax($shipping_surcharge, $tax);
if (DISPLAY_PRICE_WITH_TAX == 'true') {
$shipping_surcharge += zen_calculate_tax($shipping_surcharge, $tax);
}
}

$this->output[] = array('title' => $this->title . ':',
'text' => $currencies->format($shipping_surcharge, true, $order->info['currency'], $order->info['currency_value']),
'value' => $shipping_surcharge);
}[/PHP]


It works! Thanks for your tip!
19 Apr 2025, 15:37
#13
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
346
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

Another issue, but it is not critical to me.

Under the order-total, there is an option under this surcharge plug-in: Charge a Shipping Surcharge. By default, it is set to true. I checked my checkout page, and the surcharge only applied to the sub-total number. Shipping is not included. But anyway, I don't plan to apply surcharge on the shipping.

If I set this option to false, surcharge option is missing under the OPC checkout page. If I select different shipping options, the following warning is generated.

[PHP][19-Apr-2025 11:30:15 America/New_York] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /includes/classes/order_total.php:143
Stack trace:
#0 /includes/classes/ajax/zcAjaxOnePageCheckout.php(428): order_total->output()
#1 /includes/classes/ajax/zcAjaxOnePageCheckout.php(92): zcAjaxOnePageCheckout->createOrderTotalHtml()
#2 /ajax.php(92): zcAjaxOnePageCheckout->updateShippingSelection()
#3 {main}
thrown in /includes/classes/order_total.php on line 143

[19-Apr-2025 11:30:15 America/New_York] Request URI: /ajax.php?act=ajaxOnePageCheckout&method=updateShippingSelection, IP address: xxxx
--> PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /includes/classes/order_total.php:143
Stack trace:
#0 /includes/classes/ajax/zcAjaxOnePageCheckout.php(428): order_total->output()
#1 /includes/classes/ajax/zcAjaxOnePageCheckout.php(92): zcAjaxOnePageCheckout->createOrderTotalHtml()
#2 /ajax.php(92): zcAjaxOnePageCheckout->updateShippingSelection()
#3 {main}
thrown in /includes/classes/order_total.php on line 143.
[/PHP]

Line 143 in order_total.php is the following in my code:

[PHP] $size = count($GLOBALS[$class]->output);[/PHP]
20 Apr 2025, 13:46
#14
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Posts:
332
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

The option you set to false is the one that activates the shipping surcharge... Which is why it does not appear anymore in checkout page. I know some other modules have an option to include shipping fee in calcuation at this place, but this one does not. There are few weird things in this module, if I have time, I might rewrite it.

Your log is an OPC problem, I have seen the same here, but there was no answer due to a lack of information from poster.
21 Apr 2025, 09:50
#15
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Posts:
332
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

I submitted an updated version in plugins section here. It should be available in few days.

The OPC log above might be link to the fact the module was always activated even when calculation is de-activated by the option 'Charge a Shipping Surcharge'.
21 Apr 2025, 15:30
#16
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
346
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

Thanks for your help and contribution! I will try the new plug-in when it is available and let you know.

This plug-in will benefit many sellers under the current tariff condition...
28 Apr 2025, 04:11
#17
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Posts:
332
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

It is available now!
28 Apr 2025, 20:33
#19
njcyx avatar

njcyx

Zen Follower

Join Date:
Apr 2019
Posts:
346
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

pilou2:

Forgot the link:
https://www.zen-cart.com/downloads.php?do=file&id=2308


Hi @pilou2, I just tried v2.0.0 and it worked great on my end. No warnings.

One small issue, but it doesn't bother me: "Tax Class" options still doesn't work. There is no change on the surcharge value, no matter Taxable Goods is selected or not. But anyway, I don't plan to surcharge the sales tax. I used the local sales tax module here.
29 Apr 2025, 08:27
#20
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Posts:
332
Plugin Contributions:
0

Re: Shipping Surcharge [Support Thread]

njcyx:

Hi @pilou2, I just tried v2.0.0 and it worked great on my end. No warnings.

One small issue, but it doesn't bother me: "Tax Class" options still doesn't work. There is no change on the surcharge value, no matter Taxable Goods is selected or not. But anyway, I don't plan to surcharge the sales tax. I used the local sales tax module here.


Tax works well on a standard ZC. The plugin Local Sales Tax only support ZC standard modules and need some modification to support Shipping Surchage.