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 Code:
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);
}
Re: Shipping Surcharge [Support Thread]
Quote:
Originally Posted by
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 Code:
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);
}
It works! Thanks for your tip!
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 Code:
[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.
Line 143 in order_total.php is the following in my code:
PHP Code:
$size = count($GLOBALS[$class]->output);
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.
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'.
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...
Re: Shipping Surcharge [Support Thread]
Re: Shipping Surcharge [Support Thread]
Quote:
Originally Posted by
pilou2
It is available now!
Forgot the link:
https://www.zen-cart.com/downloads.php?do=file&id=2308
Re: Shipping Surcharge [Support Thread]
Quote:
Originally Posted by
pilou2
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.
Re: Shipping Surcharge [Support Thread]
Quote:
Originally Posted by
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.