PageRenderTime 882ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/modules/order_total/ot_coupon.php

https://bitbucket.org/flth/xtcm
PHP | 540 lines | 331 code | 96 blank | 113 comment | 98 complexity | 264ffe471eddba6f649395df940aa4d4 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /* -----------------------------------------------------------------------------------------
  3. $Id: ot_coupon.php 2093 2011-08-14 15:32:50Z web28 $
  4. xtcModified - community made shopping
  5. http://www.xtc-modified.org
  6. Copyright (c) 2010 xtcModified
  7. -----------------------------------------------------------------------------------------
  8. based on:
  9. (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
  10. (c) 2002-2003 osCommerce(ot_coupon.php,v 1.1.2.37.3); www.oscommerce.com
  11. (c) 2006 xt:Commerce (ot_coupon.php 1002 2005-07-10); www.xt-commerce.de
  12. Released under the GNU General Public License
  13. -----------------------------------------------------------------------------------------
  14. Third Party contributions:
  15. Credit Class/Gift Vouchers/Discount Coupons (Version 5.10)
  16. http://www.oscommerce.com/community/contributions,282
  17. Copyright (c) Strider | Strider@oscworks.com
  18. Copyright (c) Nick Stanko of UkiDev.com, nick@ukidev.com
  19. Copyright (c) Andre ambidex@gmx.net
  20. Copyright (c) 2001,2002 Ian C Wilson http://www.phesis.org
  21. Released under the GNU General Public License
  22. BUGFIXES & MODIFIED rev1.3.3 by web28 - www.rpa-com.de
  23. 1.3.3 optimize code
  24. 1.3.2 fix different currencies
  25. ---------------------------------------------------------------------------------------*/
  26. class ot_coupon {
  27. var $title, $output;
  28. ///////////////////////////////////////////////////////////////////////
  29. function ot_coupon() {
  30. global $xtPrice;
  31. $this->code = 'ot_coupon';
  32. $this->header = MODULE_ORDER_TOTAL_COUPON_HEADER;
  33. $this->title = MODULE_ORDER_TOTAL_COUPON_TITLE;
  34. $this->description = MODULE_ORDER_TOTAL_COUPON_DESCRIPTION;
  35. $this->user_prompt = '';
  36. $this->enabled = MODULE_ORDER_TOTAL_COUPON_STATUS;
  37. $this->sort_order = MODULE_ORDER_TOTAL_COUPON_SORT_ORDER;
  38. $this->include_shipping = 'false'; //MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING;
  39. $this->include_tax = 'true'; //MODULE_ORDER_TOTAL_COUPON_INC_TAX;
  40. $this->calculate_tax = MODULE_ORDER_TOTAL_COUPON_CALC_TAX;
  41. $this->tax_class = MODULE_ORDER_TOTAL_COUPON_TAX_CLASS;
  42. $this->credit_class = true;
  43. $this->output = array ();
  44. }
  45. ///////////////////////////////////////////////////////////////////////
  46. function process() {
  47. global $order, $xtPrice;
  48. //BOF -web28- 2010-05-23 - BUGFIX - tax_deduction, $order->info['subtotal']
  49. $order_total = $this->get_order_total(); //Betrag, der für die Kuponberechnung verwendet wird
  50. $od_amount = $this->calculate_credit($order_total); //Kuponbetrag berechnen
  51. $this->deduction = $od_amount;
  52. if ($od_amount > 0) {
  53. //$od_amount = $xtPrice->xtcFormat($od_amount, false); //Rabatt runden ??? Rundungsfehler ???
  54. if ($this->calculate_tax != 'None') {
  55. $this->new_calculate_tax_deduction($od_amount,$order_total);
  56. }
  57. $order->info['total'] = $xtPrice->xtcFormat($order->info['total'] - $od_amount, false);
  58. $order->info['deduction'] = $od_amount;
  59. $order->info['subtotal'] = $order->info['subtotal'] - $od_amount;
  60. $this->output[] = array ('title' => $this->title.' '.$this->coupon_code.$this->tax_info.':',
  61. 'text' => '<strong><font color="#ff0000">'.$xtPrice->xtcFormat($od_amount*(-1), true).'</font></strong>',
  62. 'value' => $od_amount *(-1)); //2011-08-25 - web28 - fix negativ sign
  63. }
  64. //EOF -web28- 2010-05-23 - BUGFIX - tax_deduction, $order->info['subtotal']
  65. }
  66. ///////////////////////////////////////////////////////////////////////
  67. function selection_test() {
  68. return false;
  69. }
  70. ///////////////////////////////////////////////////////////////////////
  71. function pre_confirmation_check($order_total) {
  72. return $this->calculate_credit($order_total);
  73. }
  74. ///////////////////////////////////////////////////////////////////////
  75. function use_credit_amount() {
  76. $output_string = ''; //DokuMan - 2010-08-30 - set missing variable
  77. return $output_string;
  78. }
  79. ///////////////////////////////////////////////////////////////////////
  80. function credit_selection() {
  81. return false;
  82. }
  83. ///////////////////////////////////////////////////////////////////////
  84. function collect_posts() {
  85. global $xtPrice;
  86. if (isset($_POST['gv_redeem_code']) && $_POST['gv_redeem_code']) {
  87. // INFOS ÜBER KUPON AUSLESEN
  88. $coupon_query = xtc_db_query("select coupon_id, coupon_amount,
  89. coupon_type, coupon_minimum_order,
  90. coupon_start_date, coupon_expire_date,
  91. uses_per_coupon, uses_per_user,
  92. restrict_to_products, restrict_to_categories
  93. from ".TABLE_COUPONS."
  94. where coupon_code='".$_POST['gv_redeem_code']."'
  95. and coupon_active='Y'");
  96. $coupon_result = xtc_db_fetch_array($coupon_query);
  97. if ($coupon_result['coupon_type'] != 'G') {
  98. if (xtc_db_num_rows($coupon_query) == 0) {
  99. xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message='.urlencode(ERROR_NO_INVALID_REDEEM_COUPON), 'SSL'));
  100. }
  101. // ERROR : LAUFZEIT HAT NOCH NICHT BEGONNEN
  102. if ($coupon_result['coupon_start_date'] > date('Y-m-d H:i:s')) {
  103. xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_STARTDATE_COUPON), 'SSL'));
  104. }
  105. // ERROR : LAUFZEIT BEENDET
  106. if ($coupon_result['coupon_expire_date'] < date('Y-m-d H:i:s')) {
  107. xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_FINISDATE_COUPON), 'SSL'));
  108. }
  109. // ERROR : GESAMTES VERWENDUNGSLIMIT ÜBERSCHRITTEN
  110. $coupon_count = xtc_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id'] . "'");
  111. if (xtc_db_num_rows($coupon_count) >= $coupon_result['uses_per_coupon'] && $coupon_result['uses_per_coupon'] > 0) {
  112. xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_USES_COUPON . $coupon_result['uses_per_coupon'] . TIMES), 'SSL'));
  113. }
  114. // ERROR : VERWENDUNGSLIMIT FÜR EINZELNEN KUNDEN ÜBERSCHRITTEN
  115. $coupon_count_customer = xtc_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id'] . "' and customer_id = '" . (int) $_SESSION['customer_id'] . "'");
  116. if (xtc_db_num_rows($coupon_count_customer) >= $coupon_result['uses_per_user'] && $coupon_result['uses_per_user'] > 0) {
  117. xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_USES_USER_COUPON . $coupon_result['uses_per_user'] . TIMES), 'SSL'));
  118. }
  119. // ERROR : MINDESTBESTELLWERT NICHT ERREICHT //FIX - web28 - 2012-04-24 - calculate currencies
  120. if ($xtPrice->xtcCalculateCurr($coupon_result['coupon_minimum_order']) > $_SESSION['cart']->show_total()) {
  121. xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'info_message=' . urlencode(ERROR_MINIMUM_ORDER_COUPON_1 . ' ' . $xtPrice->xtcFormat($coupon_result['coupon_minimum_order'], true, 0, true) . ' ' . ERROR_MINIMUM_ORDER_COUPON_2), 'SSL'));
  122. }
  123. }
  124. if ($_POST['submit_redeem_coupon_x'] && !$_POST['gv_redeem_code'])
  125. xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message='.urlencode(ERROR_NO_REDEEM_CODE), 'SSL'));
  126. }
  127. }
  128. ///////////////////////////////////////////////////////////////////////
  129. // RABATT BERECHNEN
  130. ///////////////////////////////////////////////////////////////////////
  131. function calculate_credit($amount) {
  132. global $order, $xtPrice, $tax_info_excl;
  133. $od_amount = 0;
  134. if (isset ($_SESSION['cc_id'])) {
  135. //web28 -2011-11-06 - FIX: only active coupon
  136. $coupon_query = xtc_db_query("select coupon_code
  137. from ".TABLE_COUPONS."
  138. where coupon_id = '".$_SESSION['cc_id']."'
  139. and coupon_active = 'Y'
  140. ");
  141. if (xtc_db_num_rows($coupon_query) != 0) {
  142. $coupon_result = xtc_db_fetch_array($coupon_query);
  143. // KUPON CODE
  144. $this->coupon_code = $coupon_result['coupon_code'];
  145. // INFOS ÜBER DEN KUPON AUSLESEN
  146. //web28 -2011-11-06 - FIX: only active coupon
  147. $coupon_get = xtc_db_query("select coupon_amount, coupon_minimum_order,
  148. restrict_to_products, restrict_to_categories,
  149. coupon_type
  150. from ".TABLE_COUPONS."
  151. where coupon_code = '".$coupon_result['coupon_code']."'
  152. and coupon_active = 'Y'
  153. ");
  154. $get_result = xtc_db_fetch_array($coupon_get);
  155. $c_deduct = $xtPrice->xtcCalculateCurr($get_result['coupon_amount']); //FIX - web28 - 2012-04-24 - calculate currencies
  156. // KUPON VERSANDKOSTENFREI
  157. if ($get_result['coupon_type'] == 'S') {
  158. //$c_deduct = $order->info['shipping_cost'];
  159. $c_deduct = $this->get_shipping_cost();
  160. }
  161. if ($get_result['coupon_type']=='S' && $get_result['coupon_amount'] > 0 ) {
  162. $c_deduct = $c_deduct + $xtPrice->xtcCalculateCurr($get_result['coupon_amount']); //FIX - web28 - 2012-04-24 - calculate currencies
  163. $flag_s = true;
  164. }
  165. //echo 'VK'. $c_deduct;
  166. if ($xtPrice->xtcCalculateCurr($get_result['coupon_minimum_order']) <= $this->get_order_total()) {
  167. if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) {
  168. //BOF -web28- 2010-06-19 - FIX - new calculate coupon amount
  169. $pr_c = 0; //web28- 2010-05-21 - FIX - restrict max coupon amount
  170. //allowed products
  171. if ($get_result['restrict_to_products']) {
  172. $pr_ids = explode(",", $get_result['restrict_to_products']); // Hetfield - 2009-08-18 - replaced depricated function split with explode to be ready for PHP >= 5.3
  173. for ($i = 0; $i < sizeof($order->products); $i ++) {
  174. for ($ii = 0; $ii < count($pr_ids); $ii ++) {
  175. if ($pr_ids[$ii] == xtc_get_prid($order->products[$i]['id'])) {
  176. if ($get_result['coupon_type'] == 'P') {
  177. $pr_c = $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - $order->products[$i]['id'] //Fred 2003-10-28, fix for the row above, otherwise the discount is calc based on price excl VAT!
  178. $pod_amount = round($pr_c*10)/10*$c_deduct/100;
  179. $od_amount = $od_amount + $pod_amount;
  180. } else {
  181. $od_amount = $c_deduct;
  182. $pr_c += $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - FIX $order->products[$i]['id'] //web28- 2010-05-21 - FIX - restrict max coupon amount
  183. }
  184. }
  185. }
  186. }
  187. }
  188. //allowed categories
  189. if ($get_result['restrict_to_categories']) {
  190. $cat_ids = explode(",", $get_result['restrict_to_categories']); // Hetfield - 2009-08-18 - replaced depricated function split with explode to be ready for PHP >= 5.3
  191. for ($i = 0; $i < sizeof($order->products); $i ++) {
  192. $my_path = xtc_get_product_path(xtc_get_prid($order->products[$i]['id']));
  193. $sub_cat_ids = explode("_", $my_path); // Hetfield - 2009-08-18 - replaced depricated function split with explode to be ready for PHP >= 5.3
  194. //BOF - web28 - 2010-06-19 - test for product_id to prevent double counting
  195. if ($get_result['restrict_to_products'] && in_array(xtc_get_prid($order->products[$i]['id']) ,$pr_ids) ) {
  196. $p_flag = true;
  197. } else $p_flag = false;
  198. //EOF - web28 - 2010-06-19 - test for product_id to prevent double counting
  199. for ($iii = 0; $iii < count($sub_cat_ids); $iii ++) {
  200. for ($ii = 0; $ii < count($cat_ids); $ii ++) {
  201. if ($sub_cat_ids[$iii] == $cat_ids[$ii] && !$p_flag) {
  202. if ($get_result['coupon_type'] == 'P') {
  203. $pr_c = $this->product_price($order->products[$i]['id']);//web28- 2010-07-29 - FIX no xtc_get_prid //Fred 2003-10-28, fix for the row above, otherwise the discount is calc based on price excl VAT!
  204. $pod_amount = round($pr_c*10)/10*$c_deduct/100;
  205. $od_amount = $od_amount + $pod_amount;
  206. continue 3; // v5.13a Tanaka 2005-4-30: to prevent double counting of a product discount
  207. } else {
  208. $od_amount = $c_deduct;
  209. $pr_c += $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - FIX no xtc_get_prid //web28- 2010-05-21 - FIX - restrict max coupon amount
  210. continue 3;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. if ($get_result['coupon_type'] == 'F' && $od_amount > $pr_c ) {$od_amount = $pr_c;} //web28- 2010-05-21 - FIX - restrict max coupon amount
  218. //EOF -web28- 2010-06-19 - FIX - new calculate coupon amount
  219. } else {
  220. if ($get_result['coupon_type'] != 'P') {
  221. $od_amount = $c_deduct;
  222. } else {
  223. $od_amount = $amount * $xtPrice->xtcCalculateCurr($get_result['coupon_amount']) / 100; //FIX - web28 - 2012-04-24 - calculate currencies
  224. }
  225. }
  226. //echo 'OD'.$od_amount;
  227. //BOF - web28- 2010-06-19 - ADD no discount for special offers
  228. if (MODULE_ORDER_TOTAL_COUPON_SPECIAL_PRICES != 'true'){
  229. $pr_c = 0;
  230. for ($i = 0; $i < sizeof($order->products); $i ++) {
  231. $product_query = "select specials_new_products_price from ".TABLE_SPECIALS." where products_id = '".xtc_get_prid($order->products[$i]['id'])."' and status=1";
  232. $product_query = xtDBquery($product_query);
  233. $product = xtc_db_fetch_array($product_query, true);
  234. if($product['specials_new_products_price']) {
  235. if ($get_result['coupon_type'] == 'P') {
  236. $pr_c = $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - FIX no xtc_get_prid
  237. $pod_amount = round($pr_c*10)/10*$c_deduct/100;
  238. $od_amount -= $pod_amount;
  239. } else {
  240. $pr_c += $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - FIX no xtc_get_prid
  241. }
  242. }
  243. }
  244. if ($od_amount < 0) $od_amount = 0;
  245. if ($amount <= $pr_c) $od_amount = 0;
  246. }
  247. //EOF - web28- 2010-06-19 - ADD no discount for special offers
  248. }
  249. }
  250. if ($flag_s) {
  251. $amount += $this->get_shipping_cost(); //Wenn Versandkostenfrei: Versandkosten und Gutscheinwert addieren
  252. }
  253. // RABATT ÜBERSTEIGT DEN BESTELLWERT, DANN RABATT GLEICH BESTELLWERT
  254. if ($od_amount > $amount) {
  255. $od_amount = $amount;
  256. }
  257. //echo 'OD'.$od_amount;
  258. }
  259. //KORREKTUR wenn Kunde Nettopreise und Steuer in Rechnung: Couponwert mit Steuersatz prozentual korrigiert
  260. $this->tax_info = '';
  261. if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1 && $amount > 0) {
  262. $od_amount = $od_amount / (1 + $order->info['tax'] / $amount);
  263. $this->tax_info = ' ('. trim(str_replace(array(' %s',','), array('',''),TAX_INFO_EXCL)) .')';
  264. }
  265. return $od_amount;
  266. }
  267. ///////////////////////////////////////////////////////////////////////
  268. // STEUER NEU BERECHNEN
  269. ///////////////////////////////////////////////////////////////////////
  270. function new_calculate_tax_deduction($od_amount, $order_total) {
  271. global $order;
  272. //Wenn der Kupon ohne Steuer definiert wurde, muss die Bestellsumme korrigiert werden
  273. if ($this->include_tax == 'false'){
  274. $order_total = $order_total + $order->info['tax'];
  275. }
  276. //Gutscheinwert in % berechnen, vereinheitlicht die Berechnungen
  277. $od_amount_pro = $od_amount/$order_total * 100;
  278. reset($order->info['tax_groups']);
  279. $tod_amount = 0;
  280. //Steuer für jede Steuergruppe korrigieren
  281. while (list ($key, $value) = each($order->info['tax_groups'])) {
  282. //Steuer neu berechnen
  283. $t_flag = true;
  284. if ($t_flag) {
  285. $god_amount = $order->info['tax_groups'][$key] * $od_amount_pro / 100;
  286. $order->info['tax_groups'][$key] -= $god_amount; //Steuer jeder Steuergruppe korrigieren
  287. //echo $god_amount . '<br>';
  288. $tod_amount += $god_amount; //hier wird die Steuer für die Gesamtsteuer aufaddiert
  289. }
  290. }
  291. //Gesamtsteuer neu berechnen
  292. $order->info['tax'] -= $tod_amount; //bei BRUTTO Preisen abziehen
  293. if ($_SESSION['customers_status']['customers_status_show_price_tax'] != '1') {
  294. $order->info['tax'] = $tod_amount; //bei NETTO Preisen ersetzen
  295. }
  296. }
  297. ///////////////////////////////////////////////////////////////////////
  298. // VERSANDKOSTEN BERECHNEN MIT STEUER
  299. ///////////////////////////////////////////////////////////////////////
  300. function get_shipping_cost() {
  301. global $order, $xtPrice;
  302. $shipping_module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
  303. $shipping_cost = $order->info['shipping_cost'];
  304. //BRUTTO PREISE - Steuer bei Versandkosten hinzufügen
  305. if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '1') {
  306. $shipping_tax_rate = xtc_get_tax_rate($GLOBALS[$shipping_module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  307. $shipping_tax = $order->info['shipping_cost'] * ($shipping_tax_rate / 100 +1) - $order->info['shipping_cost'];
  308. $shipping_cost = $order->info['shipping_cost'] + $shipping_tax;
  309. $shipping_cost = $xtPrice->xtcFormat($shipping_cost, false); //RUNDEN
  310. }
  311. return $shipping_cost;
  312. }
  313. ///////////////////////////////////////////////////////////////////////
  314. function update_credit_account($i) {
  315. return false;
  316. }
  317. ///////////////////////////////////////////////////////////////////////
  318. function apply_credit() {
  319. global $insert_id, $REMOTE_ADDR;
  320. if ($this->deduction != 0) {
  321. xtc_db_query("insert into ".TABLE_COUPON_REDEEM_TRACK." (coupon_id, redeem_date, redeem_ip, customer_id, order_id) values ('".$_SESSION['cc_id']."', now(), '".$REMOTE_ADDR."', '".$_SESSION['customer_id']."', '".$insert_id."')");
  322. }
  323. unset ($_SESSION['cc_id']);
  324. }
  325. ///////////////////////////////////////////////////////////////////////
  326. // GESAMT BESTELLSUMME BERECHNEN
  327. ///////////////////////////////////////////////////////////////////////
  328. function get_order_total() {
  329. global $order, $xtPrice;
  330. $order_total = $order->info['total'];
  331. // Check if gift voucher is in cart and adjust total
  332. $products = $_SESSION['cart']->get_products();
  333. for ($i = 0; $i < sizeof($products); $i ++) {
  334. $t_prid = xtc_get_prid($products[$i]['id']);
  335. $gv_query = xtc_db_query("select products_price, products_tax_class_id, products_model from ".TABLE_PRODUCTS." where products_id = '".$t_prid."'");
  336. $gv_result = xtc_db_fetch_array($gv_query);
  337. if (preg_match('/^GIFT/', addslashes($gv_result['products_model']))) { // Hetfield - 2009-08-19 - replaced depricated function ereg with preg_match to be ready for PHP >= 5.3
  338. $qty = $_SESSION['cart']->get_quantity($t_prid);
  339. $products_tax = $xtPrice->TAX[$gv_result['products_tax_class_id']];
  340. if ($this->include_tax == 'false') {
  341. $gv_amount = $gv_result['products_price'] * $qty;
  342. } else {
  343. $gv_amount = ($gv_result['products_price'] + $xtPrice->calcTax($gv_result['products_price'], $products_tax)) * $qty;
  344. }
  345. $order_total = $order_total - $gv_amount;
  346. }
  347. }
  348. if ($this->include_tax == 'false')
  349. $order_total = $order_total - $order->info['tax'];
  350. if ($this->include_shipping == 'false') {
  351. $order_total = $order_total - $order->info['shipping_cost'];
  352. }
  353. return $order_total;
  354. }
  355. ///////////////////////////////////////////////////////////////////////
  356. // PRODUKTPREIS BERECHNEN - INKL ATTRIBUTEPREISE
  357. ///////////////////////////////////////////////////////////////////////
  358. function get_product_price($product_id) { //wird nur bei Einschränkung Produkte/Kategorie benutzt
  359. global $order,$xtPrice;
  360. $products_id = xtc_get_prid($product_id);
  361. // products price
  362. //BOF - 2010-01-19 - Dokuman - ot_coupon Bugfixes
  363. //$qty = $_SESSION['cart']->contents[$products_id]['qty'];
  364. $qty = $_SESSION['cart']->contents[$product_id]['qty'];
  365. //EOF - 2010-01-19 - Dokuman - ot_coupon Bugfixes
  366. $total_price = 0;
  367. $product_query = xtc_db_query("select products_id, products_model, products_price, products_tax_class_id, products_weight from ".TABLE_PRODUCTS." where products_id='".$products_id."'");
  368. if ($product = xtc_db_fetch_array($product_query)) {
  369. $prid = $product['products_id'];
  370. if ($this->include_tax == 'true') {
  371. $total_price += $qty * $xtPrice->xtcGetPrice($product['products_id'], $format = false, 1, $product['products_tax_class_id'], $product['products_price'], 1);
  372. $_SESSION['total_price']=$total_price;
  373. } else {
  374. $total_price += $qty * $xtPrice->xtcGetPrice($product['products_id'], $format = false, 1, 0, $product['products_price'], 1);
  375. }
  376. // attributes price
  377. // BOF - 2011-03-16 - web28 - use xtPrice function
  378. $attribute_price = 0;
  379. if (isset ($_SESSION['cart']->contents[$product_id]['attributes'])) {
  380. reset($_SESSION['cart']->contents[$product_id]['attributes']);
  381. while (list ($option, $value) = each($_SESSION['cart']->contents[$product_id]['attributes'])) {
  382. $values = $xtPrice->xtcGetOptionPrice($product['products_id'], $option, $value);
  383. $attribute_price += $qty * $values['price'];
  384. }
  385. }
  386. $total_price += $attribute_price;
  387. // EOF - 2011-03-16 - web28 - use xtPrice function
  388. }
  389. //if ($this->include_shipping == 'true') {
  390. //$total_price += $order->info['shipping_cost'];
  391. //}
  392. return $total_price;
  393. }
  394. ///////////////////////////////////////////////////////////////////////
  395. function product_price($product_id) {
  396. $total_price = $this->get_product_price($product_id);
  397. return $total_price;
  398. }
  399. ///////////////////////////////////////////////////////////////////////
  400. function check() {
  401. if (!isset ($this->check)) {
  402. $check_query = xtc_db_query("select configuration_value from ".TABLE_CONFIGURATION." where configuration_key = 'MODULE_ORDER_TOTAL_COUPON_STATUS'");
  403. $this->check = xtc_db_num_rows($check_query);
  404. }
  405. return $this->check;
  406. }
  407. ///////////////////////////////////////////////////////////////////////
  408. function keys() {
  409. return array ('MODULE_ORDER_TOTAL_COUPON_STATUS',
  410. 'MODULE_ORDER_TOTAL_COUPON_SORT_ORDER',
  411. //'MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING',
  412. //'MODULE_ORDER_TOTAL_COUPON_INC_TAX',
  413. 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX',
  414. //'MODULE_ORDER_TOTAL_COUPON_TAX_CLASS' // web28- 2010-05-23 - FIX - unnecessary COUPON_TAX_CLASS
  415. 'MODULE_ORDER_TOTAL_COUPON_SPECIAL_PRICES' // web28- 2010-06-19 - ADD no discount for special offers
  416. );
  417. }
  418. ///////////////////////////////////////////////////////////////////////
  419. function install() {
  420. xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_STATUS', 'true', '6', '1','xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
  421. xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_SORT_ORDER', '25', '6', '2', now())");
  422. xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING', 'false', '6', '5', 'xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
  423. xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_INC_TAX', 'true', '6', '6','xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
  424. //BOF -web28- 2010-05-23 - FIX - unnecessary Credit Note
  425. //xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'Standard', '6', '7','xtc_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', now())");
  426. xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'Standard', '6', '7','xtc_cfg_select_option(array(\'None\', \'Standard\'), ', now())");
  427. //EOF -web28- 2010-05-23 - FIX - unnecessary Credit Note
  428. xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_TAX_CLASS', '0', '6', '0', 'xtc_get_tax_class_title', 'xtc_cfg_pull_down_tax_classes(', now())");
  429. //BOF - web28- 2010-06-19 - ADD no discount for special offers
  430. xtc_db_query("insert into ".TABLE_CONFIGURATION." (configuration_id, configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('', 'MODULE_ORDER_TOTAL_COUPON_SPECIAL_PRICES', 'false', '6', '5', 'xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
  431. //EOF - web28- 2010-06-19 - ADD no discount for special offers
  432. }
  433. ///////////////////////////////////////////////////////////////////////
  434. function remove() {
  435. xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key LIKE 'MODULE_ORDER_TOTAL_COUPON_%'");
  436. }
  437. }
  438. ?>