435 |
435 |
{
|
436 |
436 |
$fee = 0;
|
437 |
437 |
|
438 |
|
if(MODULE_ORDER_TOTAL_COD_FEE_STATUS == 'true' && $module['moduleCode'] === $this->cashOnDeliveryModuleCode)
|
439 |
|
{
|
440 |
|
$country = false;
|
441 |
|
$zones = [];
|
442 |
|
|
443 |
|
if(strpos(MODULE_ORDER_TOTAL_COD_FEE_RULES, '|') !== false)
|
444 |
|
{
|
445 |
|
$rules = explode('|', MODULE_ORDER_TOTAL_COD_FEE_RULES);
|
446 |
|
$shipping = [];
|
447 |
|
|
448 |
|
for($i = 0; $i < count($rules); $i++)
|
449 |
|
{
|
450 |
|
if($i % 2 === 0)
|
451 |
|
{
|
452 |
|
$moduleName = $rules[$i];
|
453 |
|
}
|
454 |
|
else
|
455 |
|
{
|
456 |
|
$shipping[$moduleName] = $rules[$i];
|
457 |
|
}
|
458 |
|
}
|
459 |
|
|
460 |
|
if(isset($shipping[strtok($_SESSION['shipping']['id'], '_')]))
|
461 |
|
{
|
462 |
|
$zones = preg_split('/[:,]/', $shipping[strtok($_SESSION['shipping']['id'], '_')]);
|
463 |
|
}
|
464 |
|
}
|
465 |
|
|
466 |
|
for($i = 0; $i < count($zones); $i++)
|
467 |
|
{
|
468 |
|
if($zones[$i] === $order->delivery['country']['iso_code_2'])
|
469 |
|
{
|
470 |
|
$fee = $zones[$i + 1];
|
471 |
|
$country = true;
|
472 |
|
break;
|
473 |
|
}
|
474 |
|
elseif($zones[$i] === '00')
|
475 |
|
{
|
476 |
|
$fee = $zones[$i + 1];
|
477 |
|
$country = true;
|
478 |
|
break;
|
479 |
|
}
|
480 |
|
|
481 |
|
$i++;
|
482 |
|
}
|
483 |
|
}
|
484 |
|
|
485 |
|
if($fee !== 0 && $country)
|
486 |
|
{
|
487 |
|
$fee = $GLOBALS['xtPrice']->xtcCalculateCurr($fee);
|
488 |
|
|
489 |
|
$tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'],
|
490 |
|
$order->delivery['zone_id']);
|
491 |
|
|
492 |
|
if($_SESSION['customers_status']['customers_status_show_price_tax'] === '1')
|
493 |
|
{
|
494 |
|
$fee = $GLOBALS['xtPrice']->xtcFormat(xtc_add_tax($fee, $tax), true);
|
495 |
|
}
|
496 |
|
else
|
497 |
|
{
|
498 |
|
$fee = $GLOBALS['xtPrice']->xtcFormat($fee, true);
|
|
438 |
if(defined('MODULE_ORDER_TOTAL_COD_FEE_STATUS'))
|
|
439 |
{
|
|
440 |
if(MODULE_ORDER_TOTAL_COD_FEE_STATUS == 'true' && $module['moduleCode'] === $this->cashOnDeliveryModuleCode)
|
|
441 |
{
|
|
442 |
$country = false;
|
|
443 |
$zones = [];
|
|
444 |
|
|
445 |
if(strpos(MODULE_ORDER_TOTAL_COD_FEE_RULES, '|') !== false)
|
|
446 |
{
|
|
447 |
$rules = explode('|', MODULE_ORDER_TOTAL_COD_FEE_RULES);
|
|
448 |
$shipping = [];
|
|
449 |
|
|
450 |
for($i = 0; $i < count($rules); $i++)
|
|
451 |
{
|
|
452 |
if($i % 2 === 0)
|
|
453 |
{
|
|
454 |
$moduleName = $rules[$i];
|
|
455 |
}
|
|
456 |
else
|
|
457 |
{
|
|
458 |
$shipping[$moduleName] = $rules[$i];
|
|
459 |
}
|
|
460 |
}
|
|
461 |
|
|
462 |
if(isset($shipping[strtok($_SESSION['shipping']['id'], '_')]))
|
|
463 |
{
|
|
464 |
$zones = preg_split('/[:,]/', $shipping[strtok($_SESSION['shipping']['id'], '_')]);
|
|
465 |
}
|
|
466 |
}
|
|
467 |
|
|
468 |
for($i = 0; $i < count($zones); $i++)
|
|
469 |
{
|
|
470 |
if($zones[$i] === $order->delivery['country']['iso_code_2'])
|
|
471 |
{
|
|
472 |
$fee = $zones[$i + 1];
|
|
473 |
$country = true;
|
|
474 |
break;
|
|
475 |
}
|
|
476 |
elseif($zones[$i] === '00')
|
|
477 |
{
|
|
478 |
$fee = $zones[$i + 1];
|
|
479 |
$country = true;
|
|
480 |
break;
|
|
481 |
}
|
|
482 |
|
|
483 |
$i++;
|
|
484 |
}
|
|
485 |
}
|
|
486 |
|
|
487 |
if($fee !== 0 && $country)
|
|
488 |
{
|
|
489 |
$fee = $GLOBALS['xtPrice']->xtcCalculateCurr($fee);
|
|
490 |
|
|
491 |
$tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_COD_FEE_TAX_CLASS, $order->delivery['country']['id'],
|
|
492 |
$order->delivery['zone_id']);
|
|
493 |
|
|
494 |
if($_SESSION['customers_status']['customers_status_show_price_tax'] === '1')
|
|
495 |
{
|
|
496 |
$fee = $GLOBALS['xtPrice']->xtcFormat(xtc_add_tax($fee, $tax), true);
|
|
497 |
}
|
|
498 |
else
|
|
499 |
{
|
|
500 |
$fee = $GLOBALS['xtPrice']->xtcFormat($fee, true);
|
|
501 |
}
|
499 |
502 |
}
|
500 |
503 |
}
|
501 |
|
|
502 |
504 |
return (string)$fee;
|
503 |
505 |
}
|
504 |
506 |
}
|