Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

JdBk

Members
  • Content count

    17
  • Joined

  • Last visited

  1. JdBk

    [contribution] Tracking Module

    Hey chris ;) Could you tell me why I got this problem ? Regards, Julien
  2. JdBk

    [contribution] Tracking Module

    Ok I found my problem, it is order edit contribution which are not updating the general status, it appeared to be updated, but it wasn't when checking the database. I have another problem, the link on the track code doesn't work, using your module RM or mine LP. it shows java script:void(0); (using RM or LP module) -> My javascript is active. Regards,
  3. JdBk

    [contribution] Tracking Module

    Hello chris, I am still changing the code for my couriers. But I have a problem with a tracking code : I entered '/^\\\d{1}\\\D{1}\\\d{11}$/' for a tracking code which is 1 digit + 1 letter + 11 digits (8D00432154798) Could you help me ? EDIT: it accepted the code but it tells me that the order has not been updated... Thx ya JD
  4. And my order.php file: <?php /* $Id: order.php,v 1.33 2003/06/09 22:25:35 hpdl Exp $ adapted for Separate Pricing Per Customer v4.0 2005/02/06 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class order { var $info, $totals, $products, $customer, $delivery, $content_type; function order($order_id = '') { $this->info = array(); $this->totals = array(); $this->products = array(); $this->customer = array(); $this->delivery = array(); if (tep_not_null($order_id)) { $this->query($order_id); } else { $this->cart(); } } function query($order_id) { global $languages_id; $order_id = tep_db_prepare_input($order_id); //Add for TVA_intracom : "billing_tva_intracom" $order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_tva_intracom, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); $order = tep_db_fetch_array($order_query); $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); while ($totals = tep_db_fetch_array($totals_query)) { $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text']); } $order_total_query = tep_db_query("select text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'"); $order_total = tep_db_fetch_array($order_total_query); $shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'"); $shipping_method = tep_db_fetch_array($shipping_method_query); $order_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$languages_id . "'"); $order_status = tep_db_fetch_array($order_status_query); $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order_status['orders_status_name'], 'last_modified' => $order['last_modified'], 'total' => strip_tags($order_total['text']), 'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title']))); $this->customer = array('id' => $order['customers_id'], 'name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']); $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']); if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) { $this->delivery = false; } $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], //BOF for VAT INTRACOM 'company_tax_id' => $order['billing_tva_intracom'], // EOF for TVA_INTRACOM 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']); $index = 0; $orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); while ($orders_products = tep_db_fetch_array($orders_products_query)) { $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'id' => $orders_products['products_id'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price']); // BOF Separate Pricing Per Customer if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } if ($customer_group_id != '0'){ $orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'"); if ($orders_customers = tep_db_fetch_array($orders_customers_price)){ $this->products[$index] = array('price' => $orders_customers['customers_group_price'], 'final_price' => $orders_customers['customers_group_price']); } } // EOF Separate Pricing Per Customer $subindex = 0; $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); if (tep_db_num_rows($attributes_query)) { while ($attributes = tep_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1'; $index++; } } function cart() { global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment; $this->content_type = $cart->get_content_type(); //Add for TVA_intracom : "ab.entry_company_tax_id" $customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_company_tax_id, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id"); $customer_address = tep_db_fetch_array($customer_address_query); $shipping_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'"); $shipping_address = tep_db_fetch_array($shipping_address_query); $billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_company_tax_id, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'"); $billing_address = tep_db_fetch_array($billing_address_query); $tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)(($this->content_type == 'virtual' || 'virtual_weight') ? $billto : $sendto) . "'"); // Edited for CCGV $tax_address = tep_db_fetch_array($tax_address_query); $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $currency, 'currency_value' => $currencies->currencies[$currency]['value'], 'payment_method' => $payment, 'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''), 'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''), 'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''), 'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''), 'shipping_method' => $shipping['title'], 'shipping_cost' => $shipping['cost'], 'subtotal' => 0, 'tax' => 0, 'tax_groups' => array(), 'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : '')); if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) { $this->info['payment_method'] = $GLOBALS[$payment]->title; if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) { $this->info['order_status'] = $GLOBALS[$payment]->order_status; } } $this->customer = array('firstname' => $customer_address['customers_firstname'], 'lastname' => $customer_address['customers_lastname'], 'company' => $customer_address['entry_company'], 'street_address' => $customer_address['entry_street_address'], 'suburb' => $customer_address['entry_suburb'], 'city' => $customer_address['entry_city'], 'postcode' => $customer_address['entry_postcode'], 'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']), 'zone_id' => $customer_address['entry_zone_id'], 'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']), 'format_id' => $customer_address['address_format_id'], 'telephone' => $customer_address['customers_telephone'], 'email_address' => $customer_address['customers_email_address']); $this->delivery = array('firstname' => $shipping_address['entry_firstname'], 'lastname' => $shipping_address['entry_lastname'], 'company' => $shipping_address['entry_company'], 'street_address' => $shipping_address['entry_street_address'], 'suburb' => $shipping_address['entry_suburb'], 'city' => $shipping_address['entry_city'], 'postcode' => $shipping_address['entry_postcode'], 'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']), 'zone_id' => $shipping_address['entry_zone_id'], 'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']), 'country_id' => $shipping_address['entry_country_id'], 'format_id' => $shipping_address['address_format_id']); $this->billing = array('firstname' => $billing_address['entry_firstname'], 'lastname' => $billing_address['entry_lastname'], 'company' => $billing_address['entry_company'], //BOF for VAT INTRACOM 'company_tax_id' => $billing_address['entry_company_tax_id'], // EOF for TVA_INTRACOM 'street_address' => $billing_address['entry_street_address'], 'suburb' => $billing_address['entry_suburb'], 'city' => $billing_address['entry_city'], 'postcode' => $billing_address['entry_postcode'], 'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']), 'zone_id' => $billing_address['entry_zone_id'], 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), 'country_id' => $billing_address['entry_country_id'], 'format_id' => $billing_address['address_format_id']); $index = 0; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); // BOF Separate Pricing Per Customer if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } if ($customer_group_id != '0'){ $orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'"); $orders_customers = tep_db_fetch_array($orders_customers_price); if ($orders_customers = tep_db_fetch_array($orders_customers_price)) { $this->products[$index] = array('price' => $orders_customers['customers_group_price'], 'final_price' => $orders_customers['customers_group_price'] + $cart->attributes_price($products[$i]['id'])); } } // EOF Separate Pricing Per Customer if ($products[$i]['attributes']) { $subindex = 0; reset($products[$i]['attributes']); while (list($option, $value) = each($products[$i]['attributes'])) { $attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'"); $attributes = tep_db_fetch_array($attributes_query); $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'], 'value' => $attributes['products_options_values_name'], 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } $shown_price = (tep_add_tax($this->products[$index]['final_price'], 0) * $this->products[$index]['qty']) - $applied_discount; $this->info['subtotal'] += $shown_price; $shown_price = (tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']) - $applied_discount; $products_tax = $this->products[$index]['tax']; $products_tax_description = $this->products[$index]['tax_description']; // BOF Separate Pricing Per Customer, show_tax modification // next line was original code // if (DISPLAY_PRICE_WITH_TAX == 'true') { global $sppc_customer_group_show_tax; if(!tep_session_is_registered('sppc_customer_group_show_tax')) { $customer_group_show_tax = '1'; } else { $customer_group_show_tax = $sppc_customer_group_show_tax; } if (DISPLAY_PRICE_WITH_TAX == 'true' && $customer_group_show_tax == '1') { // EOF Separate Pricing Per Customer, show_tax modification $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } else { $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } } else { $this->info['tax'] += ($products_tax / 100) * $shown_price; if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price; } else { $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price; } } $index++; } // BOF Separate Pricing Per Customer, show_tax modification // next line was original code // if (DISPLAY_PRICE_WITH_TAX == 'true') { global $sppc_customer_group_show_tax; if(!tep_session_is_registered('sppc_customer_group_show_tax')) { $customer_group_show_tax = '1'; } else { $customer_group_show_tax = $sppc_customer_group_show_tax; } if ((DISPLAY_PRICE_WITH_TAX == 'true') && ($customer_group_show_tax == '1')) { // EOF Separate Pricing Per Customer, show_tax modification $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'] + $this->info['tax']; } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } $this->info['totalHT'] = $this->info['subtotal'] + $this->info['shipping_cost'] - $applied_discount; } } ?>
  5. My ot_coupon.php file: <?php /* $Id: ot_coupon.php,v 1.1.2.37.3 2004/01/01 22:52:59 Strider Exp $ $Id: ot_coupon.php,v 1.1.2.37 2003/07/24 22:52:59 Strider-Cote Exp $ $Id: ot_coupon.php,v 1.1.2.36 2003/05/14 22:52:59 wilt Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com/ Copyright ¬ 2002 osCommerce Released under the GNU General Public License */ class ot_coupon { var $title, $output; function ot_coupon() { $this->code = 'ot_coupon'; $this->header = MODULE_ORDER_TOTAL_COUPON_HEADER; $this->title = MODULE_ORDER_TOTAL_COUPON_TITLE; $this->description = MODULE_ORDER_TOTAL_COUPON_DESCRIPTION; $this->user_prompt = ''; $this->enabled = MODULE_ORDER_TOTAL_COUPON_STATUS; $this->sort_order = MODULE_ORDER_TOTAL_COUPON_SORT_ORDER; $this->include_shipping = MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING; $this->include_tax = MODULE_ORDER_TOTAL_COUPON_INC_TAX; $this->calculate_tax = MODULE_ORDER_TOTAL_COUPON_CALC_TAX; $this->tax_class = MODULE_ORDER_TOTAL_COUPON_TAX_CLASS; $this->credit_class = true; $this->output = array(); } function process() { global $PHP_SELF, $order, $currencies; $order_total=$this->get_order_total(); $od_amount = $this->calculate_credit($order_total); $tod_amount = 0.0; //Fred $this->deduction = $od_amount; if ($this->calculate_tax != 'None') { //Fred - changed from 'none' to 'None'! $tod_amount = $this->calculate_tax_deduction($order_total, $this->deduction, $this->calculate_tax); } if ($od_amount > 0) { $order->info['total'] = $order->info['total'] - $od_amount; $order->info['totalHT'] = $order->info['totalHT'] - $od_amount; $this->output[] = array('title' => $this->title . ':' . $this->coupon_code .':','text' => '<b>-' . $currencies->format($od_amount) . '</b>', 'value' => $od_amount); //Fred added hyphen } } function selection_test() { return false; } function pre_confirmation_check($order_total) { global $customer_id; return $this->calculate_credit($order_total); } function use_credit_amount() { return $output_string; } function credit_selection() { global $customer_id, $currencies, $language; $selection_string = ''; $selection_string .= '<tr>' . "\n"; $selection_string .= ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>'; $selection_string .= ' <td class="main">' . "\n"; $image_submit = tep_image_submit('button_redeem.gif', IMAGE_REDEEM_VOUCHER, 'name="submit_redeem" onClick="submitFunction()"'); $selection_string .= TEXT_ENTER_COUPON_CODE . tep_draw_input_field('gv_redeem_code') . '</td>'; $selection_string .= ' <td align="right">' . $image_submit . '</td>'; $selection_string .= ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>'; $selection_string .= '</tr>' . "\n"; return $selection_string; } function collect_posts() { global $HTTP_POST_VARS, $customer_id, $currencies, $cc_id; if ($HTTP_POST_VARS['gv_redeem_code']) { // get some info from the coupon table $coupon_query=tep_db_query("select coupon_id, coupon_amount, coupon_type, coupon_minimum_order,uses_per_coupon, uses_per_user, restrict_to_products,restrict_to_categories from " . TABLE_COUPONS . " where coupon_code='".$HTTP_POST_VARS['gv_redeem_code']."' and coupon_active='Y'"); $coupon_result=tep_db_fetch_array($coupon_query); if ($coupon_result['coupon_type'] != 'G') { if (tep_db_num_rows($coupon_query)==0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_INVALID_REDEEM_COUPON), 'SSL')); } $date_query=tep_db_query("select coupon_start_date from " . TABLE_COUPONS . " where coupon_start_date <= now() and coupon_code='".$HTTP_POST_VARS['gv_redeem_code']."'"); if (tep_db_num_rows($date_query)==0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_STARTDATE_COUPON), 'SSL')); } $date_query=tep_db_query("select coupon_expire_date from " . TABLE_COUPONS . " where coupon_expire_date >= now() and coupon_code='".$HTTP_POST_VARS['gv_redeem_code']."'"); if (tep_db_num_rows($date_query)==0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_FINISDATE_COUPON), 'SSL')); } $coupon_count = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id']."'"); $coupon_count_customer = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id']."' and customer_id = '" . $customer_id . "'"); if (tep_db_num_rows($coupon_count)>=$coupon_result['uses_per_coupon'] && $coupon_result['uses_per_coupon'] > 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_USES_COUPON . $coupon_result['uses_per_coupon'] . TIMES ), 'SSL')); } if (tep_db_num_rows($coupon_count_customer)>=$coupon_result['uses_per_user'] && $coupon_result['uses_per_user'] > 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_INVALID_USES_USER_COUPON . $coupon_result['uses_per_user'] . TIMES ), 'SSL')); } if ($coupon_result['coupon_type']=='S') { $coupon_amount = $order->info['shipping_cost']; } else { $coupon_amount = $currencies->format($coupon_result['coupon_amount']) . ' '; } if ($coupon_result['coupon_type']=='P') $coupon_amount = $coupon_result['coupon_amount'] . '% '; if ($coupon_result['coupon_minimum_order']>0) $coupon_amount .= 'on orders greater than ' . $coupon_result['coupon_minimum_order']; if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id'); //Fred - this was commented out before $cc_id = $coupon_result['coupon_id']; //Fred ADDED, set the global and session variable // $_SESSION['cc_id'] = $coupon_result['coupon_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead. } if ($HTTP_POST_VARS['submit_redeem_coupon_x'] && !$HTTP_POST_VARS['gv_redeem_code']) tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_REDEEM_CODE), 'SSL')); } } function calculate_credit($amount) { global $customer_id, $order, $cc_id; //$cc_id = $_SESSION['cc_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead. $od_amount = 0; if (isset($cc_id) ) { $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $cc_id . "'"); if (tep_db_num_rows($coupon_query) !=0 ) { $coupon_result = tep_db_fetch_array($coupon_query); $this->coupon_code = $coupon_result['coupon_code']; $coupon_get = tep_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS ." where coupon_code = '". $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); $c_deduct = $get_result['coupon_amount']; if ($get_result['coupon_type']=='S') $c_deduct = $order->info['shipping_cost']; if ($get_result['coupon_minimum_order'] <= $this->get_order_total()) { if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) { for ($i=0; $i<sizeof($order->products); $i++) { if ($get_result['restrict_to_products']) { $pr_ids = split("[,]", $get_result['restrict_to_products']); for ($ii = 0; $ii < count($pr_ids); $ii++) { if ($pr_ids[$ii] == tep_get_prid($order->products[$i]['id'])) { if ($get_result['coupon_type'] == 'P') { /* Fixes to Gift Voucher module 5.03 ================================= Submitted by Rob Cote, robc@traininghott.com original code: $od_amount = round($amount*10)/10*$c_deduct/100; $pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pod_amount = round($pr_c*10)/10*$c_deduct/100; */ //$pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pr_c = $this->product_price($order->products[$i]['id']); // Modified by Mike Todd (2004-12-08) -- includes whole "funky" product id $pod_amount = round($pr_c*10)/10*$c_deduct/100; $od_amount = $od_amount + $pod_amount; } else { $od_amount = $c_deduct; } } } } else { $cat_ids = split("[,]", $get_result['restrict_to_categories']); for ($i=0; $i<sizeof($order->products); $i++) { $my_path = tep_get_product_path(tep_get_prid($order->products[$i]['id'])); $sub_cat_ids = split("[_]", $my_path); for ($iii = 0; $iii < count($sub_cat_ids); $iii++) { for ($ii = 0; $ii < count($cat_ids); $ii++) { if ($sub_cat_ids[$iii] == $cat_ids[$ii]) { if ($get_result['coupon_type'] == 'P') { /* Category Restriction Fix to Gift Voucher module 5.04 Date: August 3, 2003 ================================= Nick Stanko of UkiDev.com, nick@ukidev.com original code: $od_amount = round($amount*10)/10*$c_deduct/100; $pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pod_amount = round($pr_c*10)/10*$c_deduct/100; */ //$od_amount = round($amount*10)/10*$c_deduct/100; //$pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pr_c = $this->product_price($order->products[$i]['id']); // Modified by Mike Todd (2004-12-08) -- includes whole "funky" product id $pod_amount = round($pr_c*10)/10*$c_deduct/100; $od_amount = $od_amount + $pod_amount; } else { $od_amount = $c_deduct; } } } } } } } } else { if ($get_result['coupon_type'] !='P') { $od_amount = $c_deduct; } else { $od_amount = $amount * $get_result['coupon_amount'] / 100; } } } } if ($od_amount>$amount) $od_amount = $amount; } return $od_amount; } function calculate_tax_deduction($amount, $od_amount, $method) { global $customer_id, $order, $cc_id, $cart; //$cc_id = $_SESSION['cc_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead. $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $cc_id . "'"); if (tep_db_num_rows($coupon_query) !=0 ) { $coupon_result = tep_db_fetch_array($coupon_query); $coupon_get = tep_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code = '". $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); if ($get_result['coupon_type'] != 'S') { //RESTRICTION-------------------------------- if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) { // What to do here. // Loop through all products and build a list of all product_ids, price, tax class // at the same time create total net amount. // then // for percentage discounts. simply reduce tax group per product by discount percentage // or // for fixed payment amount // calculate ratio based on total net // for each product reduce tax group per product by ratio amount. $products = $cart->get_products(); $valid_product = false; for ($i=0; $i<sizeof($products); $i++) { $valid_product = false; $t_prid = tep_get_prid($products[$i]['id']); $cc_query = tep_db_query("select products_tax_class_id from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'"); $cc_result = tep_db_fetch_array($cc_query); if ($get_result['restrict_to_products']) { $pr_ids = split("[,]", $get_result['restrict_to_products']); for ($p = 0; $p < sizeof($pr_ids); $p++) { if ($pr_ids[$p] == $t_prid) $valid_product = true; } } if ($get_result['restrict_to_categories']) { $cat_ids = split("[,]", $get_result['restrict_to_categories']); for ($c = 0; $c < sizeof($cat_ids); $c++) { $cat_query = tep_db_query("select products_id from products_to_categories where products_id = '" . $products_id . "' and categories_id = '" . $cat_ids[$i] . "'"); if (tep_db_num_rows($cat_query) !=0 ) $valid_product = true; } } if ($valid_product) { $price_excl_vat = $products[$i]['final_price'] * $products[$i]['quantity']; //Fred - added $price_incl_vat = $this->product_price($t_prid); //Fred - added $valid_array[] = array('product_id' => $t_prid, 'products_price' => $price_excl_vat, 'products_tax_class' => $cc_result['products_tax_class_id']); //jason //Fred - changed from $products[$i]['final_price'] 'products_tax_class' => $cc_result['products_tax_class_id']); // $total_price += $price_incl_vat; //Fred - changed $total_price += $price_excl_vat; // changed } } if (sizeof($valid_array) > 0) { // if ($valid_product) { if ($get_result['coupon_type'] == 'P') { $ratio = $get_result['coupon_amount']/100; } else { $ratio = $od_amount / $total_price; } if ($get_result['coupon_type'] == 'S') $ratio = 1; if ($method=='Credit Note') { $tax_rate = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_desc = tep_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); if ($get_result['coupon_type'] == 'P') { $tod_amount = $od_amount / (100 + $tax_rate)* $tax_rate; } else { $tod_amount = $order->info['tax_groups'][$tax_desc] * $od_amount/100; } $order->info['tax_groups'][$tax_desc] -= $tod_amount; $order->info['total'] -= $tod_amount; // need to modify total ...OLD $order->info['tax'] -= $tod_amount; //Fred - added } else { for ($p=0; $p<sizeof($valid_array); $p++) { $tax_rate = tep_get_tax_rate($valid_array[$p]['products_tax_class'], $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_desc = tep_get_tax_description($valid_array[$p]['products_tax_class'], $order->delivery['country']['id'], $order->delivery['zone_id']); if ($tax_rate > 0) { //Fred $tod_amount[$tax_desc] += ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio; //OLD $tod_amount = ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio; // calc total tax Fred - added $order->info['tax_groups'][$tax_desc] -= ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio; $order->info['total'] -= ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio; // adjust total $order->info['tax'] -= ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio; // adjust tax -- Fred - added } } } } //NO RESTRICTION-------------------------------- } else { if ($get_result['coupon_type'] =='F') { $tod_amount = 0; if ($method=='Credit Note') { $tax_rate = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_desc = tep_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tod_amount = $od_amount / (100 + $tax_rate)* $tax_rate; $order->info['tax_groups'][$tax_desc] -= $tod_amount; } else { // $ratio1 = $od_amount/$amount; // this produces the wrong ratipo on fixed amounts reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $ratio1 = $od_amount/($amount-$order->info['tax_groups'][$key]); ////debug $tax_rate = tep_get_tax_rate_from_desc($key); $net = $tax_rate * $order->info['tax_groups'][$key]; if ($net>0) { $god_amount = $order->info['tax_groups'][$key] * $ratio1; $tod_amount += $god_amount; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } } $order->info['total'] -= $tod_amount; //OLD $order->info['tax'] -= $tod_amount; //Fred - added } if ($get_result['coupon_type'] =='P') { $tod_amount=0; if ($method=='Credit Note') { $tax_desc = tep_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tod_amount = $order->info['tax_groups'][$tax_desc] * $od_amount/100; $order->info['tax_groups'][$tax_desc] -= $tod_amount; } else { reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amout=0; $tax_rate = tep_get_tax_rate_from_desc($key); $net = $tax_rate * $order->info['tax_groups'][$key]; if ($net>0) { $god_amount = $order->info['tax_groups'][$key] * $get_result['coupon_amount']/100; $tod_amount += $god_amount; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } } $order->info['total'] -= $tod_amount; // have to modify total also $order->info['tax'] -= $tod_amount; } } } } return $tod_amount; } function update_credit_account($i) { return false; } function apply_credit() { global $insert_id, $customer_id, $REMOTE_ADDR, $cc_id; //$cc_id = $_SESSION['cc_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead. if ($this->deduction !=0) { tep_db_query("insert into " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, redeem_date, redeem_ip, customer_id, order_id) values ('" . $cc_id . "', now(), '" . $REMOTE_ADDR . "', '" . $customer_id . "', '" . $insert_id . "')"); } tep_session_unregister('cc_id'); } function get_order_total() { global $order, $cart, $customer_id, $cc_id; //$cc_id = $_SESSION['cc_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead. $order_total = $order->info['total']; // Check if gift voucher is in cart and adjust total $products = $cart->get_products(); for ($i=0; $i<sizeof($products); $i++) { $t_prid = tep_get_prid($products[$i]['id']); $gv_query = tep_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', addslashes($gv_result['products_model']))) { $qty = $cart->get_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']; // OK thats fine for global coupons but what about restricted coupons // where you can only redeem against certain products/categories. // and I though this was going to be easy !!! $coupon_query=tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id='".$cc_id."'"); if (tep_db_num_rows($coupon_query) !=0) { $coupon_result=tep_db_fetch_array($coupon_query); $coupon_get=tep_db_query("select coupon_amount, coupon_minimum_order,restrict_to_products,restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code='".$coupon_result['coupon_code']."'"); $get_result=tep_db_fetch_array($coupon_get); $in_cat = true; if ($get_result['restrict_to_categories']) { $cat_ids = split("[,]", $get_result['restrict_to_categories']); $in_cat=false; for ($i = 0; $i < count($cat_ids); $i++) { if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $cat_query = tep_db_query("select products_id from products_to_categories where products_id = '" . $products_id . "' and categories_id = '" . $cat_ids[$i] . "'"); if (tep_db_num_rows($cat_query) !=0 ) { $in_cat = true; $total_price += $this->get_product_price($products_id); } } } } } $in_cart = true; if ($get_result['restrict_to_products']) { $pr_ids = split("[,]", $get_result['restrict_to_products']); $in_cart=false; $products_array = $cart->get_products(); for ($i = 0; $i < sizeof($pr_ids); $i++) { for ($ii = 1; $ii<=sizeof($products_array); $ii++) { if (tep_get_prid($products_array[$ii-1]['id']) == $pr_ids[$i]) { $in_cart=true; $total_price += $this->get_product_price($products_array[$ii-1]['id']); } } } $order_total = $total_price; } } return $order_total; } function get_product_price($product_id) { global $cart, $order; $products_id = tep_get_prid($product_id); // products price $qty = $cart->contents[$product_id]['qty']; $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . $product_id . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } if ($this->include_tax == 'true') { $total_price += ($products_price + tep_calculate_tax($products_price, $products_tax)) * $qty; // echo("total price = " . $total_price . " products_price = " . $products_price . " products_tax = " . $products_tax . "<br>"); } else { $total_price += $products_price * $qty; } // attributes price if (isset($cart->contents[$product_id]['attributes'])) { reset($cart->contents[$product_id]['attributes']); while (list($option, $value) = each($cart->contents[$product_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { if ($this->include_tax == 'true') { $total_price += $qty * ($attribute_price['options_values_price'] + tep_calculate_tax($attribute_price['options_values_price'], $products_tax)); } else { $total_price += $qty * ($attribute_price['options_values_price']); } } else { if ($this->include_tax == 'true') { $total_price -= $qty * ($attribute_price['options_values_price'] + tep_calculate_tax($attribute_price['options_values_price'], $products_tax)); } else { $total_price -= $qty * ($attribute_price['options_values_price']); } } } } } if ($this->include_shipping == 'true') { $total_price += $order->info['shipping_cost']; } return $total_price; } //Added by Fred -- BOF ----------------------------------------------------- //JUST RETURN THE PRODUCT PRICE (INCL ATTRIBUTE PRICES) WITH OR WITHOUT TAX function product_price($product_id) { $total_price = $this->get_product_price($product_id); if ($this->include_shipping == 'true') $total_price -= $order->info['shipping_cost']; return $total_price; } //Added by Fred -- EOF ----------------------------------------------------- function check() { if (!isset($this->check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COUPON_STATUS'"); $this->check = tep_db_num_rows($check_query); } return $this->check; } function keys() { return array('MODULE_ORDER_TOTAL_COUPON_STATUS', 'MODULE_ORDER_TOTAL_COUPON_SORT_ORDER', 'MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING', 'MODULE_ORDER_TOTAL_COUPON_INC_TAX', 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'MODULE_ORDER_TOTAL_COUPON_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 ('Display Total', 'MODULE_ORDER_TOTAL_COUPON_STATUS', 'true', 'Do you want to display the Discount Coupon value?', '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 ('Sort Order', 'MODULE_ORDER_TOTAL_COUPON_SORT_ORDER', '9', 'Sort order of display.', '6', '2', now())"); 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 ('Include Shipping', 'MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING', 'true', 'Include Shipping in calculation', '6', '5', '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, set_function ,date_added) values ('Include Tax', 'MODULE_ORDER_TOTAL_COUPON_INC_TAX', 'true', 'Include Tax in calculation.', '6', '6','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, set_function ,date_added) values ('Re-calculate Tax', 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'None', 'Re-Calculate Tax', '6', '7','tep_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', 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 ('Tax Class', 'MODULE_ORDER_TOTAL_COUPON_TAX_CLASS', '0', 'Use the following tax class when treating Discount Coupon as Credit Note.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); } function remove() { $keys = ''; $keys_array = $this->keys(); for ($i=0; $i<sizeof($keys_array); $i++) { $keys .= "'" . $keys_array[$i] . "',"; } $keys = substr($keys, 0, -1); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")"); } } ?>
  6. Hey everybody, I have a new problem with CCGV. I adapted it "well" but there is a last problem. Indeed the french legislation is specific and I would like the coupon to appear excluding VAT (it is possible in admin, I can obtain 2 € -> 5%) but need the VAT to be re-calculate. That means that the 0,39 € (in the following example) which correspond to a VAT deduction on the coupon should be directly reduice the VAT amount, ie to obtain 8,82 € - 0,39 €. I tried many modifications on the ot_coupon.php and order.php files but without success. Thx for your help. What I can obtain: When Include Tax = True and re-calculate VAT on Credit Note or Standard Sub-Total Excl. VAT: 40.00€ Coupon Code:VIP: -2.39€ Shipping (Forfait): 5.00€ Total Excl. VAT: 42.61€ VAT 19,60%: 8.82€ Total Incl. VAT: 51.43€ When Include Tax = False and re-calculate VAT on Credit Note or Standard Sub-Total Excl. VAT: 40.00€ Coupon Code:VIP: -2.00€ Shipping (Forfait): 5.00€ Total Excl. VAT: 43.00€ VAT 19,60%: 8.82€ Total Incl. VAT: 51.82€ What I wanna have: Sub-Total Excl. VAT: 40.00€ Coupon Code:VIP: -2.00€ Shipping (Forfait): 5.00€ Total Excl. VAT: 43.00€ VAT 19,60%: 8.43€ Total Incl. VAT: 51.43€ JD
  7. Hello ;) Yes it works now ;) Thank you very much ! JD
  8. Hello ;) I just came back from holidays... First of all, Thx for ur help ! But it doesnt work ;)... This is my new currencies file : <?php /* $Id: currencies.php,v 1.16 2003/06/05 23:16:46 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ //// // Class to handle currencies // TABLES: currencies class currencies { var $currencies; // class constructor function currencies() { $this->currencies = array(); $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES); while ($currencies = tep_db_fetch_array($currencies_query)) { $this->currencies[$currencies['code']] = array('title' => $currencies['title'], 'symbol_left' => $currencies['symbol_left'], 'symbol_right' => $currencies['symbol_right'], 'decimal_point' => $currencies['decimal_point'], 'thousands_point' => $currencies['thousands_point'], 'decimal_places' => $currencies['decimal_places'], 'value' => $currencies['value']); } } // class methods function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { global $currency; if (empty($currency_type)) $currency_type = $currency; if ($calculate_currency_value == true) { $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value']; $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; // if the selected currency is in the european euro-conversion and the default currency is euro, // the currency will displayed in the national currency and euro currency if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) { $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>'; } } else { $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; } return $format_string; } function is_set($code) { if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) { return true; } else { return false; } } function get_value($code) { return $this->currencies[$code]['value']; } function get_decimal_places($code) { return $this->currencies[$code]['decimal_places']; } function display_price($products_price, $products_tax, $quantity = 1) { if (!isset($_SESSION['sppc_customer_group_show_tax'])) { $customer_group_show_tax = '1'; } else { $customer_group_show_tax = $_SESSION['sppc_customer_group_show_tax']; } if ((DISPLAY_PRICE_WITH_TAX == 'true') && ($customer_group_show_tax == '1')) { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Incl. VAT'; } else { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Excl. VAT'; } } ?> And this is the error I have (I don't really know coding etc) : Parse error: syntax error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home.10.8/azrecept/www/boutique/includes/classes/currencies.php on line 83 Thx u again JD
  9. Hello ;) Thx Janz for this contributions which is really good ;). I just wanna know if it is possible to indicate in the catalog at the right of the prices (after money € symbol) if these prices are including VAT or Excluding VAT depending on the different customer group. I tried to modify the currencies files in catalog\includes\classes\currencies.php : replacing (line 71 for me) : function display_price($products_price, $products_tax, $quantity = 1) { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity); } But I dont know what to put exactly to make it work. Indeed, I know how to do it without SPPC installed : Replace : function display_price($products_price, $products_tax, $quantity = 1) { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity); } By : function display_price($products_price, $products_tax, $quantity = 1) { if (DISPLAY_PRICE_WITH_TAX == 'true') { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Incl. VAT'; } else { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity) . ' Excl. VAT'; } } So I would like to adapt this code for your contribution. There is probably another way to use this only for catalog prices and not for prices in the check out, invoice, etc... I think it can be a good thing for the contribution and people who use it. THx u JD
  10. Well I just deleted these lines and its working now... JD
  11. Hey ;) I installed the contribution and im still having this problem: Fatal error: Call to undefined function: tep_hide_session_id() in /home.10.8/azrecept/www/boutique/supplier/supplier_s_categories_products.php on line 797 and Fatal error: Call to undefined function: tep_hide_session_id() in /home.10.8/azrecept/www/boutique/supplier/supplier_s_orders.php on line 341 I really think it can work well and would like to know how to proceed ;) THx u JD
×