public function is_active($country = 0) { global $temp_orders_id; $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($this->instances as $data) { if ($data['status'] == 'true') { if ($temp_orders_id > 0) { if ($country > 0) { if (parent::checkZone($data['zone'], $country)) { return true; } } else { if (parent::checkZone($data['zone'], $temp_data[$temp_orders_id]['orders']['delivery_country'])) { return true; } } } else { if ($country > 0) { if (parent::checkZone($data['zone'], $country)) { return true; } } else { return true; } } } } return false; }
public function output($step = 0) { global $currencies, $cart, $temp_orders_id; if ($temp_orders_id > 0 && empty($this->temp_data[$temp_orders_id]['orders']['shipping_method'])) { $this->temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); } $this->calculate_total(); $html = ''; $html .= '<table class="table table-condensed table-striped" style="width:100%;">'; $html .= '<thead>'; $html .= '<tr>'; $html .= '<th class="product_name">' . Translate('Product') . '</th>'; $html .= '<th class="product_model">' . Translate('Referentie') . '</th>'; $html .= '<th class="product_quantity">' . Translate('Hoeveelheid') . '</th>'; $html .= '<th class="product_price">' . Translate('Prijs') . '</th>'; $html .= '</tr>'; $html .= '</thead>'; $products_query = tep_db_query('SELECT * FROM temp_orders_products WHERE orders_id = "' . $temp_orders_id . '" ORDER BY orders_products_id asc'); while ($product = tep_db_fetch_array($products_query)) { $html .= '<tr>'; $html .= '<td class="product_name">' . $product['products_name'] . '</td>'; $html .= '<td class="product_model">' . $product['products_model'] . '</td>'; $html .= '<td class="product_quantity">' . $product['products_quantity'] . '</td>'; $html .= '<td class="product_price">' . $currencies->display_price($product['final_price'], 0) . '</td>'; $html .= '</tr>'; } $html .= '</table>'; $total_query = tep_db_query('SELECT * FROM temp_orders_total WHERE orders_id = "' . $temp_orders_id . '" AND class != "' . $this->type . '" ORDER BY sort_order asc'); $html .= '<table style="width:100%; border:0;">'; while ($total = tep_db_fetch_array($total_query)) { $html .= '<tr class="' . $total['class'] . '_item">'; $class_title = $total['title']; if ($total['class'] == 'shipping') { global $Modules; $class = $this->temp_data[$temp_orders_id]['orders']['shipping_method']; foreach ($Modules->modules['shipping'] as $module) { if (strstr($class, $module)) { global ${$module}; if (method_exists(${$module}, 'getTitle')) { $class_title = ${$module}->getTitle(); } } } } $html .= '<td class="' . $total['class'] . '_title">' . Translate($class_title) . ': </td>'; $html .= '<td class="' . $total['class'] . '_quote">' . $currencies->display_price($total['value'], 0) . '</td>'; $html .= '</tr>'; } $html .= '<tr class="' . $this->type . '_item">'; $html .= '<td class="' . $this->type . '_title">' . Translate($this->config['title']) . ': </td>'; $html .= '<td class="' . $this->type . '_quote">' . $currencies->display_price($this->quote, 0) . '</td>'; $html .= '</tr>'; $html .= '</table>'; return $html; }
public function is_active() { global $temp_orders_id; $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($this->instances as $data) { if ($data['status'] == 'true') { if (parent::checkZone($data['zone'], $temp_data[$temp_orders_id]['orders']['billing_country']) && parent::checkShippingMethod($data['shipping_module'])) { return true; } } } return false; }
public function process_data() { global $temp_orders_id, $currencies; if (isset($_POST[$this->type])) { if ($_POST[$this->type] == get_class($this)) { if ($temp_orders_id == 0) { $temp_orders_id = parent::create_order(); } $ot_query = tep_db_query('SELECT orders_total_id FROM temp_orders_total WHERE orders_id = "' . $temp_orders_id . '" AND class="' . $this->type . '"'); if (tep_db_num_rows($ot_query) > 0) { tep_db_query('UPDATE temp_orders_total SET title="' . $this->config['title'] . '", text="' . $currencies->display_price($this->getQuote(), 0) . '", value="' . $this->getQuote() . '", sort_order="' . $this->config['sort_order'] . '" WHERE orders_id = "' . $temp_orders_id . '" AND class="' . $this->type . '"'); } else { tep_db_query('INSERT INTO temp_orders_total (orders_id, title, text, value, class, sort_order) VALUES ("' . $temp_orders_id . '", "' . $this->config['title'] . '", "' . $currencies->display_price($this->getQuote(), 0) . '", "' . $this->getQuote() . '", "' . $this->type . '", "' . $this->config['sort_order'] . '")'); } if (isset($_POST[get_class($this) . '_submit']) && $_POST[get_class($this) . '_submit'] == 'search_postcode') { //Search kialo points with postcode return false; } if (!isset($_POST[get_class($this) . '_kp'])) { $this->errors[$this->type] = Translate('Kies a.u.b. een Kiala punt.'); return false; } tep_db_query('UPDATE temp_orders SET shipping_method = "' . $_POST[$this->type] . '", shipping_method_extra = "' . $_POST[get_class($this) . '_kp'] . '" WHERE orders_id = "' . $temp_orders_id . '"'); } if ($temp_orders_id > 0) { $this->temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($this->temp_data[$temp_orders_id]['orders_total'] as $key => $data) { if ($data['class'] == 'order_subtotal') { $this->order_subtotal = $data['value']; } } } return true; } else { $this->errors[$this->type] = Translate('Kies a.u.b. een verzendmethode.'); if ($temp_orders_id > 0) { $this->temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($this->temp_data[$temp_orders_id]['orders_total'] as $key => $data) { if ($data['class'] == 'order_subtotal') { $this->order_subtotal = $data['value']; } } } return false; } }
public function after_extern_process() { global $temp_orders_id; if (isset($_GET['SHASIGN'])) { include DIR_WS_CLASSES . 'sha.php'; $get_params = array(); foreach ($_GET as $key => $value) { if ($key != 'SHASIGN' && $key != 'force_checkout_step' && $key != 'customer_id' && $key != 'osCsid' && trim($value) != '') { $get_params[strtoupper($key)] = $value; } } ksort($get_params); $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); $hash_string = ''; foreach ($get_params as $key => $value) { $hash_string .= strtoupper($key) . '=' . $value . $this->instances[$temp_data[$temp_orders_id]['orders']['payment_method']]['sha_string']; } $sha = new SHA(); $hasharray = $sha->hash_string($hash_string); $hash = strtoupper($sha->hash_to_string($hasharray)); if ($_GET['SHASIGN'] != $hash) { //wrong ogone parameters $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Er is iets fout gelopen bij de afhandeling van uw betaling. Contacteer ons voor meer uitleg.'); } $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $_POST['checkout_step'] = Checkout::last_active_step(); } return; }
function after_confirm() { global $temp_orders_id; $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); //get all orders data $data = ''; foreach ($_POST as $key => $value) { $data .= $key . ': ' . "\n"; $data .= $value . "\n\n"; } tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("' . get_class($this) . '", "' . $data . '", NOW())'); tep_db_query('DELETE FROM payment_log WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY)'); /*PAYMENT AUTHORISED*/ if ($_GET['Status'] == 'AU') { tep_db_query('UPDATE temp_orders SET orders_status = 2 WHERE orders_id = "' . $temp_orders_id . '"'); } else { if ($_POST['Status'] == 'DE') { tep_db_query('UPDATE temp_orders SET orders_status = 53 WHERE orders_id = "' . $temp_orders_id . '"'); Checkout::send_order_error_mail(Translate('Europabank betaling geweigerd voor bestelling') . ': ' . $temp_orders_id, sprintf(Translate('De betaling voor bestelling %s is geweigerd door Europabank.'), $temp_orders_id)); $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Uw betaling werd geweigerd.'); } else { if ($_POST['Status'] == 'CA') { tep_db_query('UPDATE temp_orders SET orders_status = 50 WHERE orders_id = "' . $temp_orders_id . '"'); $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Uw betaling werd geannuleerd.'); } else { if ($_POST['Status'] == 'EX') { tep_db_query('UPDATE temp_orders SET orders_status = 53 WHERE orders_id = "' . $temp_orders_id . '"'); Checkout::send_order_error_mail(Translate('Technisch probleem bij europabank voor bestelling') . ': ' . $temp_orders_id, sprintf(Translate('Er was een technisch probleem voor bestelling %s bij europabank.'), $temp_orders_id)); $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Er was een technisch probleem, contacteer ons voor meer info.'); } else { if ($_POST['Status'] == 'TI') { tep_db_query('UPDATE temp_orders SET orders_status = 53 WHERE orders_id = "' . $temp_orders_id . '"'); Checkout::send_order_error_mail(Translate('Timed out bij europabank voor bestelling') . ': ' . $temp_orders_id, sprintf(Translate('Er was een time out voor bestelling %s bij europabank.'), $temp_orders_id)); $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Uw sessie is verlopen, probeer a.u.b. opnieuw.'); } } } } } return $this->errors; }
function after_confirm() { global $temp_orders_id; if (isset($_GET['tx'])) { $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); //get all orders data if ($_GET['tx'] == 'canceled') { $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Uw betaling werd geannuleerd.'); } else { tep_db_query('DELETE FROM payment_log WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY)'); $req = 'cmd=_notify-synch'; $tx_token = $_GET['tx']; $auth_token = $this->instances[$temp_data[$temp_orders_id]['orders']['payment_method']]['pdt_identy_token']; $req .= "&tx={$tx_token}&at={$auth_token}"; $header = ''; $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; if ($this->instances[$temp_data[$temp_orders_id]['orders']['payment_method']]['mode'] == 'prod') { $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); } else { $fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30); } if (!$fp) { $data = ''; foreach ($_GET as $key => $value) { $data .= urldecode($key) . ': ' . "\n"; $data .= urldecode($value) . "\n\n"; } $order_id = substr($_GET['cm'], strpos($_GET['cm'], '[-]') + 3); tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("' . get_class($this) . '", "' . $data . '", NOW())'); send_order_error_mail(Translate('Er is iets fout gelopen met paypal bestelling') . ' ' . $order_id, sprintf(Translate('Voor bestelling %s is er een fout gegenereerd! Controleer dit a.u.b. voordat u deze bestelling verder verwerkt.<br />Als u vragen hebt i.v.m. de fout contacteer dan ABO Service!'), $order_id)); } else { fputs($fp, $header . $req); $res = ''; $headerdone = false; while (!feof($fp)) { $line = fgets($fp, 1024); if (strcmp($line, "\r\n") == 0) { $headerdone = true; } else { if ($headerdone) { $res .= $line; } } } $lines = explode("\n", $res); $keyarray = array(); $data = ''; if (strcmp($lines[0], "SUCCESS") == 0) { for ($i = 1; $i < count($lines); $i++) { list($key, $val) = explode("=", $lines[$i]); $keyarray[urldecode($key)] = urldecode($val); $data .= urldecode($key) . ': ' . "\n"; $data .= urldecode($val) . "\n\n"; } tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("' . get_class($this) . '", "' . $data . '", NOW())'); if (empty($keyarray['invoice'])) { $order_id = substr($keyarray['custom'], strpos($keyarray['custom'], '[-]') + 3); } else { $order_id = $keyarray['invoice']; } /*COMPLETED OR PROCESSED*/ if ($keyarray['payment_status'] == 'Completed' || $keyarray['payment_status'] == 'Processed') { tep_db_query('UPDATE temp_orders SET orders_status = 2 WHERE orders_id = "' . $order_id . '"'); /*EXPIRED*/ } else { if ($keyarray['payment_status'] == 'Expired') { send_order_error_mail(Translate('Status onzeker paypal bestelling') . ': ' . $order_id, sprintf(Translate('De status voor bestelling %s is onzeker doordat de autorisatie verlopen was op het moment dat de klant terug op de shop kwam.'), $order_id)); tep_db_query('UPDATE orders SET orders_status = 53 WHERE orders_id = "' . $order_id . '"'); $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Er is een fout opgetreden bij de betaling. Contacteer ons voor meer info.'); /*FAILED*/ } else { if ($keyarray['payment_status'] == 'Failed') { tep_db_query('UPDATE orders SET orders_status = 53 WHERE orders_id = "' . $order_id . '"'); $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Er is een fout opgetreden bij de betaling. Contacteer ons voor meer info.'); /*PENDING*/ } else { if ($keyarray['payment_status'] == 'Pending') { // } } } } } else { if (strcmp($lines[0], "FAIL") == 0) { for ($i = 1; $i < count($lines); $i++) { list($key, $val) = explode("=", $lines[$i]); $data .= urldecode($key) . ': ' . "\n"; $data .= urldecode($val) . "\n\n"; } tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("' . get_class($this) . '", "' . $data . '", NOW())'); if (empty($keyarray['invoice'])) { $order_id = substr($keyarray['custom'], strpos($keyarray['custom'], '[-]') + 3); } else { $order_id = $keyarray['invoice']; } send_order_error_mail(Translate('Er is iets fout gelopen met paypal bestelling') . ' ' . $order_id, sprintf(Translate('Voor bestelling %s is er een fout gegenereerd! Controleer dit a.u.b. voordat u deze bestelling verder verwerkt.<br />Als u vragen hebt i.v.m. de fout contacteer dan ABO Service!'), $order_id)); $_GET['force_checkout_step'] = Checkout::get_step_for_type($this->type); $this->errors[$temp_data[$temp_orders_id]['orders']['payment_method']] = Translate('Er is een fout opgetreden bij de betaling. Contacteer ons voor meer info.'); } } } fclose($fp); } } return $this->errors; }
private function calculate_instance_max($instance) { global $cart, $temp_orders_id; $temp_order_data = Checkout::get_all_data_from_temp_db($temp_orders_id); //check mode if ($this->instances[$instance]['mode'] == 'weight') { $this->instance_max[$instance] = Checkout::calculate_weight($temp_orders_id, 'temp_'); } else { //mode == price $subtotal = 0; if (is_array($temp_order_data[$temp_orders_id]['orders_total'])) { foreach ($temp_order_data[$temp_orders_id]['orders_total'] as $total_data) { if ($total_data['class'] == 'order_subtotal') { $subtotal = $total_data['value']; } } } if ($subtotal > 0) { $this->instance_max[$instance] = $subtotal; } else { $this->instance_max[$instance] = $cart->show_total(); } } }
private function calculate_amount() { global $customer_id, $temp_orders_id; $amount_query = tep_db_query('SELECT amount FROM coupon_gv_customer WHERE customer_id = "' . $customer_id . '"'); $amount = tep_db_fetch_array($amount_query); $amount = $amount['amount']; $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($temp_data[$temp_orders_id]['orders_total'] as $key => $data) { if ($data['class'] == 'order_total') { $total = $data['value']; } } if ($amount > $total) { $amount = $total; } return $amount; }
public function process_data() { global $temp_orders_id, $currencies; if (isset($_POST[$this->type])) { if ($_POST[$this->type] == get_class($this)) { if ($temp_orders_id == 0) { $temp_orders_id = parent::create_order(); } $ot_query = tep_db_query('SELECT orders_total_id FROM temp_orders_total WHERE orders_id = "' . $temp_orders_id . '" AND class="' . $this->type . '"'); if (tep_db_num_rows($ot_query) > 0) { tep_db_query('UPDATE temp_orders_total SET title="' . $this->config['title'] . '", text="' . $currencies->display_price($this->getQuote(), 0) . '", value="' . $this->getQuote() . '", sort_order="' . $this->config['sort_order'] . '" WHERE orders_id = "' . $temp_orders_id . '" AND class="' . $this->type . '"'); } else { tep_db_query('INSERT INTO temp_orders_total (orders_id, title, text, value, class, sort_order) VALUES ("' . $temp_orders_id . '", "' . $this->config['title'] . '", "' . $currencies->display_price($this->getQuote(), 0) . '", "' . $this->getQuote() . '", "' . $this->type . '", "' . $this->config['sort_order'] . '")'); } if (isset($_POST[get_class($this) . '_submit']) && $_POST[get_class($this) . '_submit'] == 'search_postcode') { //Search Bpost Service points with postcode return false; } if (!isset($_POST[get_class($this) . '_sp'])) { $this->errors[$this->type] = Translate('Kies a.u.b. een Bpost Service punt.'); return false; } if (isset($_POST[get_class($this) . '_postcode']) && !empty($_POST[get_class($this) . '_postcode'])) { $this->xml = $this->convertXMLtoArray(simplexml_load_file('http://taxipost.geo6.be/Locator?Partner=' . $this->config['account_id'] . '&AppId=' . STORE_NAME . '&Function=search&Format=xml&Zone=' . $_POST[get_class($this) . '_postcode'] . '&Language=' . $languages_code . '&Type=' . $this->config['bpost_types'] . '&Limit=' . $this->config['max_sp'])); } else { $this->xml = $this->convertXMLtoArray(simplexml_load_file('http://taxipost.geo6.be/Locator?Partner=' . $this->config['account_id'] . '&AppId=' . STORE_NAME . '&Function=search&Format=xml&Zone=' . $this->temp_data[$temp_orders_id]['orders']['delivery_postcode'] . '&Language=' . $languages_code . '&Type=' . $this->config['bpost_types'] . '&Limit=' . $this->config['max_sp'])); } $type = 1; foreach ($this->xml['PoiList']['Poi'] as $key => $data) { if ($data['Record']['Id'] == $_POST[get_class($this) . '_sp']) { $type = $data['Record']['Type']; } } tep_db_query('UPDATE temp_orders SET shipping_method = "' . $_POST[$this->type] . '", shipping_method_extra = "&Id=' . $_POST[get_class($this) . '_sp'] . '&Type=' . $type . '" WHERE orders_id = "' . $temp_orders_id . '"'); } if ($temp_orders_id > 0) { $this->temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($this->temp_data[$temp_orders_id]['orders_total'] as $key => $data) { if ($data['class'] == 'order_subtotal') { $this->order_subtotal = $data['value']; } } } return true; } else { $this->errors[$this->type] = Translate('Kies a.u.b. een verzendmethode.'); if ($temp_orders_id > 0) { $this->temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($this->temp_data[$temp_orders_id]['orders_total'] as $key => $data) { if ($data['class'] == 'order_subtotal') { $this->order_subtotal = $data['value']; } } } return false; } }
public function calculate_credit($amount) { global $temp_orders_id, $currencies, $currency; $return = array(); $return['coupon_amount'] = 0; $return['coupon_text'] = ''; $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id); foreach ($temp_data[$temp_orders_id]['orders_total'] as $key => $data) { if ($data['class'] == 'shipping') { $shipping_cost = $data['value']; } if ($data['class'] == 'order_total') { $order_total = $data['value']; } } if (isset($temp_data[$temp_orders_id]['orders']['coupon_id']) && $temp_data[$temp_orders_id]['orders']['coupon_id'] > 0) { $coupon_query = tep_db_query("select coupon_code, coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, restrict_to_zones, coupon_type from coupons where coupon_id = '" . $temp_data[$temp_orders_id]['orders']['coupon_id'] . "'"); $coupon_result = tep_db_fetch_array($coupon_query); //percent if ($coupon_result['coupon_type'] == 'P' && ($coupon_result['restrict_to_products'] != '' || $coupon_result['restrict_to_categories'] != '')) { $coupon_result['coupon_amount'] = substr($coupon_result['coupon_amount'], 0, -1); $return['coupon_text'] = number_format($coupon_result['coupon_amount']) . '% ' . Translate('op') . ' '; } else { if ($coupon_result['coupon_type'] == 'P') { $coupon_result['coupon_amount'] = substr($coupon_result['coupon_amount'], 0, -1); $return['coupon_text'] = number_format($coupon_result['coupon_amount']) . '%'; } else { if ($coupon_result['restrict_to_products'] != '' || $coupon_result['restrict_to_categories'] != '') { $return['coupon_text'] = ' ' . Translate('op') . ' '; } } } if ($coupon_result['coupon_minimum_order'] <= $order_total) { if ($coupon_result['restrict_to_products'] != '' || $coupon_result['restrict_to_categories'] != '' || $coupon_result['restrict_to_zones'] != '') { $used_restricted_categories = array(); foreach ($temp_data[$temp_orders_id]['orders_products'] as $order_products_id => $products_data) { if ($coupon_result['restrict_to_categories'] != '') { /****************************/ /* RESTRICT TO CATEGORIES */ /****************************/ $cat_ids = preg_split("/[,]/", $coupon_result['restrict_to_categories']); $my_path = tep_get_product_path($products_data['products_id']); $sub_cat_ids = preg_split("/[_]/", $my_path); for ($iii = 0; $iii < count($sub_cat_ids); $iii++) { //loop through all category IDs from the product for ($ii = 0; $ii < count($cat_ids); $ii++) { //Loop through all restricted category IDs if ($sub_cat_ids[$iii] == $cat_ids[$ii]) { //Check if there are similar category IDs if ($coupon_result['coupon_type'] == 'P') { //Percent $pr_c = $products_data['final_price'] * $products_data['products_quantity']; $pod_amount = round($pr_c * 10) / 10 * $coupon_result['coupon_amount'] / 100; $return['coupon_amount'] = $return['coupon_amount'] + $pod_amount; $used_restricted_categories[] = $cat_ids[$ii]; continue 2; } else { //Fixed amount $return['coupon_amount'] = $coupon_result['coupon_amount']; //No shipping costs if ($coupon_result['coupon_type'] == 'S') { $return['coupon_text'] = Translate('Gratis verzending'); $return['coupon_amount'] = $shipping_cost; } if ($coupon_result['coupon_type'] == 'S' && $coupon_result['coupon_amount'] > 0) { $return['coupon_amount'] = $shipping_cost + $coupon_result['coupon_amount']; } continue 2; } } } } } if ($coupon_result['restrict_to_products'] != '') { /****************************/ /* RESTRICT TO PRODUCTS */ /****************************/ $pr_ids = preg_split("/[,]/", $coupon_result['restrict_to_products']); for ($ii = 0; $ii < count($pr_ids); $ii++) { //Loop through restricted products_ids if ($pr_ids[$ii] == $products_data['products_id']) { if ($coupon_result['coupon_type'] == 'P') { //Percent $pr_c = $products_data['final_price'] * $products_data['products_quantity']; $pod_amount = round($pr_c * 10) / 10 * $coupon_result['coupon_amount'] / 100; $return['coupon_amount'] = $return['coupon_amount'] + $pod_amount; $return['coupon_text'] .= $products_data['products_name'] . ', '; } else { //fixed amount $return['coupon_text'] .= $products_data['products_name'] . ', '; $return['coupon_amount'] = $coupon_result['coupon_amount']; //No shipping costs if ($coupon_result['coupon_type'] == 'S') { $return['coupon_text'] = Translate('Gratis verzending'); $return['coupon_amount'] = $shipping_cost; } if ($coupon_result['coupon_type'] == 'S' && $coupon_result['coupon_amount'] > 0) { $return['coupon_amount'] = $shipping_cost + $coupon_result['coupon_amount']; } } } } } if ($coupon_result['restrict_to_zones'] != '') { /************************/ /* RESTRICT TO ZONES */ /************************/ $zones_ids = preg_split("/[,]/", $coupon_result['restrict_to_zones']); for ($ii = 0; $ii < count($zones_ids); $ii++) { //Loop through restricted zone_ids if (parent::checkZone($zones_ids[$ii], $temp_data[$temp_orders_id]['orders']['delivery_country'])) { if ($coupon_result['coupon_type'] == 'P') { //Percent $pr_c = $products_data['final_price'] * $products_data['products_quantity']; $pod_amount = round($pr_c * 10) / 10 * $coupon_result['coupon_amount'] / 100; $return['coupon_amount'] = $return['coupon_amount'] + $pod_amount; } else { //fixed amount $return['coupon_amount'] = $coupon_result['coupon_amount']; //No shipping costs if ($coupon_result['coupon_type'] == 'S') { $return['coupon_text'] = Translate('Gratis verzending'); $return['coupon_amount'] = $shipping_cost; } if ($coupon_result['coupon_type'] == 'S' && $coupon_result['coupon_amount'] > 0) { $return['coupon_amount'] = $shipping_cost + $coupon_result['coupon_amount']; } } } } } } $used_restricted_categories = array_unique($used_restricted_categories); foreach ($used_restricted_categories as $cat_id) { $return['coupon_text'] .= tep_get_categories_name($cat_id) . ', '; } } else { //not restricted to products, categories or zones //percent if ($coupon_result['coupon_type'] == 'P') { $return['coupon_amount'] = $amount * ($coupon_result['coupon_amount'] / 100); } //No shipping costs if ($coupon_result['coupon_type'] == 'S') { $return['coupon_text'] = Translate('Gratis verzending'); $return['coupon_amount'] = $shipping_cost; } if ($coupon_result['coupon_type'] == 'S' && $coupon_result['coupon_amount'] > 0) { $return['coupon_amount'] = $shipping_cost + $coupon_result['coupon_amount']; } //fixed amount if ($coupon_result['coupon_type'] == 'G') { $return['coupon_amount'] = $amount; } } if ($coupon_result['coupon_type'] == 'P' && ($coupon_result['restrict_to_products'] || $coupon_result['restrict_to_categories'])) { $return['coupon_text'] = substr($return['coupon_text'], 0, -2); } else { if (strlen($return['coupon_text']) > 2 && ($coupon_result['restrict_to_products'] || $coupon_result['restrict_to_categories'])) { $return['coupon_text'] = substr($return['coupon_text'], 0, -2); } } } else { //coupon minimum order is more then order total $return['errors'] = Translate('Om de kortingscode te gebruiken moet uw bestelling een minimum bedrag hebben van') . ' ' . $currencies->format($coupon_result['coupon_minimum_order']); } if ($coupon_result['coupon_type'] != 'S') { if ($return['coupon_amount'] > $amount) { $return['coupon_amount'] = $amount; } } } $return['coupon_amount'] = tep_round($return['coupon_amount'], $currencies->currencies[$currency]['decimal_places']); return $return; }