code = 'ot_fixed_payment_chg';
$this->title = MODULE_FIXED_PAYMENT_CHG_TITLE;
$this->description = MODULE_FIXED_PAYMENT_CHG_DESCRIPTION;
$this->enabled = MODULE_FIXED_PAYMENT_CHG_STATUS;
$this->sort_order = MODULE_FIXED_PAYMENT_CHG_SORT_ORDER;
$this->type = MODULE_FIXED_PAYMENT_CHG_TYPE;
$this->tax_class = MODULE_FIXED_PAYMENT_CHG_TAX_CLASS;
$this->output = array();
}
function process() {
global $order, $ot_subtotal, $currencies;
$od_amount = $this->calculate_credit($this->get_order_total());
if ($od_amount != 0) {
$this->deduction = $od_amount;
$this->output[] = array('title' => $this->title . ':',
'text' => '' . $currencies->format($od_amount) . '',
'value' => $od_amount);
$order->info['total'] = $order->info['total'] + $od_amount;
if ($this->sort_order < $ot_subtotal->sort_order) {
$order->info['subtotal'] = $order->info['subtotal'] - $od_amount;
}
}
}
function calculate_credit($amount) {
global $order, $customer_id, $payment;
$od_amount=0;
$table = split("[:,]" , MODULE_FIXED_PAYMENT_CHG_TYPE);
for ($i = 0; $i < count($table); $i+=2) {
if ($payment == $table[$i]) {
$od_am=$table[$i+1];
if (MODULE_FIXED_PAYMENT_CHG_TAX_CLASS > 0) {
$tod_rate = tep_get_tax_rate(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS);
$tod_amount = tep_calculate_tax($table[$i+1], $tod_rate);
$order->info['tax'] += $tod_amount;
$order->info['tax_groups']["{$tod_rate}"] += tep_calculate_tax($table[$i+1], $tod_rate);
}
if (DISPLAY_PRICE_WITH_TAX) {
$od_amount = $od_am + $tod_amount;
} else {
$od_amount = $od_am;
$order->info['total'] += $tod_amount;
}
}
}
return $od_amount;
}
function get_order_total() {
global $order, $cart;
$order_total = $order->info['total'];
// Check if gift voucher is in cart and adjust total
$products = $cart->get_products();
for ($i=0; $iget_quantity($t_prid);
$products_tax = tep_get_tax_rate($gv_result['products_tax_class_id']);
if ($this->include_tax =='false') {
$gv_amount = $gv_result['products_price'] * $qty;
} else {
$gv_amount = ($gv_result['products_price'] + tep_calculate_tax($gv_result['products_price'],$products_tax)) * $qty;
}
$order_total=$order_total - $gv_amount;
}
}
if ($this->include_tax == 'false') $order_total=$order_total-$order->info['tax'];
if ($this->include_shipping == 'false') $order_total=$order_total-$order->info['shipping_cost'];
return $order_total;
}
function check() {
if (!isset($this->check)) {
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_FIXED_PAYMENT_CHG_STATUS'");
$this->check = tep_db_num_rows($check_query);
}
return $this->check;
}
function keys() {
return array('MODULE_FIXED_PAYMENT_CHG_STATUS', 'MODULE_FIXED_PAYMENT_CHG_SORT_ORDER', 'MODULE_FIXED_PAYMENT_CHG_TYPE', 'MODULE_FIXED_PAYMENT_CHG_TAX_CLASS');
}
function install() {
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Summe anzeigen', 'MODULE_FIXED_PAYMENT_CHG_STATUS', 'true', 'Wollen Sie die Zahlungsmethoden-Gebühr anzeigen ?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sortier-Reihenfolge', 'MODULE_FIXED_PAYMENT_CHG_SORT_ORDER', '999', 'Sortier-Reihenfolge, die angezeigt wird.', '6', '2', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Nachlass, Prozentsatz', 'MODULE_FIXED_PAYMENT_CHG_AMOUNT', '2', 'Rabattbetrag', '6', '7', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zahlungsmethode', 'MODULE_FIXED_PAYMENT_CHG_TYPE', 'cod:5', 'Zahlungsmethoden mit Gebühr', '6', '2', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Steuergebühr', 'MODULE_FIXED_PAYMENT_CHG_TAX_CLASS', '0', 'Benutzen Sie folgende Steuergebühr auf die Zahlungsmethoden-Gebühr.', '6', '6', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
}
function remove() {
$keys = '';
$keys_array = $this->keys();
for ($i=0; $i 0) {
$tod_rate = tep_get_tax_rate(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS);
$tod_amount = tep_calculate_tax($table[$i+1], $tod_rate);
}
if (DISPLAY_PRICE_WITH_TAX=="true") {
$od_amount = $od_am + $tod_amount;
} else {
$od_amount = $od_am;
}
}
}
return $od_amount;
}
}
?>