Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 07-31-2026 14:33:00

antsevo
Member
From: West Sussex, UK
Registered: 02-08-2005
Posts: 646
Website

EU Customs and Duties

I have installed the EU Customs Script.

However I use PDDP - I pay for the taxes, duties and fees, actually the customer pays me and I pay it in royal mail


I have a base starting price for 1 product of £5.79 each addition product they buy adds £0.85

So, I already have the base price, but I need to add 85p for each additional item in the cart

I assume this should be done in my custom shipping methods.

Has anyone any pointer to this

or

is there a way it can be added into the EU Customs and Duties script.

Not too sure what would be easier


Anthony - Manufacturers of Personalised and Celebrity Face Masks

Offline

 

#2 07-31-2026 15:20:08

antsevo
Member
From: West Sussex, UK
Registered: 02-08-2005
Posts: 646
Website

Re: EU Customs and Duties

I think I have solved it... I am using a base of £6.00 for duties and an extra £1 for each item in the cart.... it seems to work, so have posted it here:

<?php

// +--
// | EU Flat Customs Duty Controls.  Designed for use on Kryptronic eCommerce
// | versions 9.0.1 and greater.  Versions 9.0.1 through 9.0.3 use iseu logic
// | and versions 9.1.0 and greater use region logic to identify EU countries.
// |
// | Use the country_duty array to override duty on the country level.  The duty
// | calculated by this script is flat rate per line item for line items under
// | a set amount.  The duty rate and max are to be entered in Euros.
// +--

$display_duty  = 'Customs & Taxes - Paid by Funkybunky';
$default_duty  = 1.00;
$maxline_total = 150.00;

$country_duty = array('France'  => 1.00,
                      'Romania' => 2.00);

// +--
// | Load objects, cart, checkout session, address book, currency info,
// | and build a list of EU countries.
// +--

$CORE_DB  =& $this->quick_object('CORE_DB','core','CORE_DB_1');
$CORE_App =& $this->quick_object('CORE_App','core');

$cartids = $this->globals('ecom.checkout_cartids');
$cosess  = $this->globals('ecom.checkout_cosess');
$addbook = $this->globals('core_session.addbook');

$currcore = $this->globals('core_settings.core.basecurrency');
$currconv = 'EUR';

$countries = array();

$sql = 'SELECT * FROM core_country';
$res = $CORE_DB->sql_do(array('sql' => $sql, 'table' => 'core_country', 'order' => array('id' => 'ASC')));

if ((!($this->isError($res))) && (!(empty($res)))) {

     foreach ($res as $num => $data) {

          if     ($data['id'] == 'UK - Northern Ireland') {$countries[$data['id']] = 'EU';}
          elseif (!(empty($data['region'])))              {$countries[$data['id']] = $data['region'];}
          elseif (!(empty($data['iseu'])))                {$countries[$data['id']] = 'EU';}
          else                                            {$countries[$data['id']] = 'OTHER';}

     } // End of foreach statement.

} // End of if statement.

if (empty($countries)) {return 1;}

// +--
// | Loop through our cart and identify any items being exported to
// | into the EU from outside the EU.
// +--

$exports = array();

foreach ($cartids as $cartid => $cartdata) {

     if (empty($cartdata['sinshipinfo']))                      {continue;}
     if (empty($cosess['items'][$cartid]))                     {continue;}
     if (empty($addbook[$cosess['items'][$cartid]['deladd']])) {continue;}

     $origincountry = $cartdata['sinshipinfo']['shipcountry'];
     $destcountry   = $addbook[$cosess['items'][$cartid]['deladd']]['country'];

     if ((empty($countries[$origincountry])) || (empty($countries[$destcountry]))) {continue;}
     if ($countries[$origincountry] == 'EU')                                       {continue;}
     if ($countries[$destcountry] != 'EU')                                         {continue;}     

     if (!(isset($exports[$destcountry]))) {$exports[$destcountry] = array('lines' => 0, 'quantity' => 0, 'total' => 0.00);}

     $exports[$destcountry]['lines']++;
     $exports[$destcountry]['quantity'] += $cartdata['quantity'];
     $exports[$destcountry]['total']    += $cartdata['subtotal'];

} // End of foreach statement.

if (empty($exports)) {return 1;}

// +--
// | Handle charges for exports.  Everything is compared using EUR
// | and converted back to the base currency for the total.
// +--

$totalduty = 0.00;

foreach ($exports as $country => $exportinfo) {

     $exportduty = $default_duty;

     if (!(empty($country_duty[$country]))) {$exportduty = $country_duty[$country];}
     if (empty($exportduty))                {continue;}

     $converted_total = $exportinfo['total'];

     if ($currcore != $currconv) {$converted_total = $CORE_App->price_round($converted_total * $this->globals('core_settings.core.currconv.' . $currconv));}

     if ($converted_total > $maxline_total) {continue;}

     $newtotalduty = $CORE_App->price_round($totalduty + ($exportduty * $exportinfo['lines']));
     $extraitemcost = 6.00;
     $totalduty = $newtotalduty + $extraitemcost;

} // End of foreach statement.

if (empty($totalduty)) {return 1;}

if ($currcore != $currconv) {$totalduty = $CORE_App->price_round($totalduty / $this->globals('core_settings.core.currconv.' . $currconv));}


Anthony - Manufacturers of Personalised and Celebrity Face Masks

Offline

 

#3 08-03-2026 08:16:46

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 20000
Website

Re: EU Customs and Duties

Thanks for posting this.  Your script looks good and should work as you intend it to.


Nick Hendler

Offline

 

#4 08-05-2026 02:51:27

antsevo
Member
From: West Sussex, UK
Registered: 02-08-2005
Posts: 646
Website

Re: EU Customs and Duties

Thanks Nick, its implemented and seems to be what I need... thanks again for checking


Anthony - Manufacturers of Personalised and Celebrity Face Masks

Offline

 

#5 09-21-2026 18:50:01

antsevo
Member
From: West Sussex, UK
Registered: 02-08-2005
Posts: 646
Website

Re: EU Customs and Duties

After all that, it does not seem to be working, it should add £1 to each additional item in the cart and on top of it all add a final £6.00 surcharge.

Have I made a simple error in this code?

<?php

// +--
// | EU Flat Customs Duty Controls.  Designed for use on Kryptronic eCommerce
// | versions 9.0.1 and greater.  Versions 9.0.1 through 9.0.3 use iseu logic
// | and versions 9.1.0 and greater use region logic to identify EU countries.
// |
// | Use the country_duty array to override duty on the country level.  The duty
// | calculated by this script is flat rate per line item for line items under
// | a set amount.  The duty rate and max are to be entered in Euros.
// +--

$display_duty  = 'Customs & Taxes - Paid by Funkybunky';
$default_duty  = 1.00;
$maxline_total = 150.00;

$country_duty = array('France'  => 1.00,
                      'Romania' => 2.00);

// +--
// | Load objects, cart, checkout session, address book, currency info,
// | and build a list of EU countries.
// +--

$CORE_DB  =& $this->quick_object('CORE_DB','core','CORE_DB_1');
$CORE_App =& $this->quick_object('CORE_App','core');

$cartids = $this->globals('ecom.checkout_cartids');
$cosess  = $this->globals('ecom.checkout_cosess');
$addbook = $this->globals('core_session.addbook');

$currcore = $this->globals('core_settings.core.basecurrency');
$currconv = 'EUR';

$countries = array();

$sql = 'SELECT * FROM core_country';
$res = $CORE_DB->sql_do(array('sql' => $sql, 'table' => 'core_country', 'order' => array('id' => 'ASC')));

if ((!($this->isError($res))) && (!(empty($res)))) {

     foreach ($res as $num => $data) {

          if     ($data['id'] == 'UK - Northern Ireland') {$countries[$data['id']] = 'EU';}
          elseif (!(empty($data['region'])))              {$countries[$data['id']] = $data['region'];}
          elseif (!(empty($data['iseu'])))                {$countries[$data['id']] = 'EU';}
          else                                            {$countries[$data['id']] = 'OTHER';}

     } // End of foreach statement.

} // End of if statement.

if (empty($countries)) {return 1;}

// +--
// | Loop through our cart and identify any items being exported to
// | into the EU from outside the EU.
// +--

$exports = array();

foreach ($cartids as $cartid => $cartdata) {

     if (empty($cartdata['sinshipinfo']))                      {continue;}
     if (empty($cosess['items'][$cartid]))                     {continue;}
     if (empty($addbook[$cosess['items'][$cartid]['deladd']])) {continue;}

     $origincountry = $cartdata['sinshipinfo']['shipcountry'];
     $destcountry   = $addbook[$cosess['items'][$cartid]['deladd']]['country'];

     if ((empty($countries[$origincountry])) || (empty($countries[$destcountry]))) {continue;}
     if ($countries[$origincountry] == 'EU')                                       {continue;}
     if ($countries[$destcountry] != 'EU')                                         {continue;}     

     if (!(isset($exports[$destcountry]))) {$exports[$destcountry] = array('lines' => 0, 'quantity' => 0, 'total' => 0.00);}

     $exports[$destcountry]['lines']++;
     $exports[$destcountry]['quantity'] += $cartdata['quantity'];
     $exports[$destcountry]['total']    += $cartdata['subtotal'];

} // End of foreach statement.

if (empty($exports)) {return 1;}

// +--
// | Handle charges for exports.  Everything is compared using EUR
// | and converted back to the base currency for the total.
// +--

$totalduty = 0.00;

foreach ($exports as $country => $exportinfo) {

     $exportduty = $default_duty;

     if (!(empty($country_duty[$country]))) {$exportduty = $country_duty[$country];}
     if (empty($exportduty))                {continue;}

     $converted_total = $exportinfo['total'];

     if ($currcore != $currconv) {$converted_total = $CORE_App->price_round($converted_total * $this->globals('core_settings.core.currconv.' . $currconv));}

     if ($converted_total > $maxline_total) {continue;}

     $newtotalduty = $CORE_App->price_round($totalduty + ($exportduty * $exportinfo['lines']));
     $extraitemcost = 6.00;
    $totalduty = $newtotalduty + $extraitemcost;

} // End of foreach statement.

if (empty($totalduty)) {return 1;}

if ($currcore != $currconv) {$totalduty = $CORE_App->price_round($totalduty / $this->globals('core_settings.core.currconv.' . $currconv));}

// +--
// | Globalize and return.
// +--


$this->globals('ecom.total_customsurcharge',$totalduty);
$this->globals('ecom.customsurcharge_text',$display_duty);

return 1;

?>


Anthony - Manufacturers of Personalised and Celebrity Face Masks

Offline

 

#6 09-21-2026 23:23:19

antsevo
Member
From: West Sussex, UK
Registered: 02-08-2005
Posts: 646
Website

Re: EU Customs and Duties

There may be a simpler way to all of this..

All I want to do is apply a surcharge to all EU countries.

The surcharge will always start from £6.00 for 1 item in their cart

This will increase by £0.85 for each additional item ordered.

Sounds simple, but i appear to be struggling!!


Anthony - Manufacturers of Personalised and Celebrity Face Masks

Offline

 

#7 09-22-2026 08:05:52

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 20000
Website

Re: EU Customs and Duties

Here's the logic you're using.  It appears to be adding the base duty (£6.00) plus £1 for each line in the cart (£1 too much):

Code:

$newtotalduty = $CORE_App->price_round($totalduty + ($exportduty * $exportinfo['lines']));
$extraitemcost = 6.00;
$totalduty = $newtotalduty + $extraitemcost;

Do this instead (same calc but one less export line in the calc):

Code:

$newtotalduty = $CORE_App->price_round($totalduty + ($exportduty * ($exportinfo['lines'] - 1)));
$extraitemcost = 6.00;
$totalduty = $newtotalduty + $extraitemcost;

Nick Hendler

Offline

 

#8 09-29-2026 06:58:56

antsevo
Member
From: West Sussex, UK
Registered: 02-08-2005
Posts: 646
Website

Re: EU Customs and Duties

Excellent..... thanks Nick, for taking the time to have a look


Anthony - Manufacturers of Personalised and Celebrity Face Masks

Offline

 

Board footer