Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Binky

Archived
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Real Name
    Andy Wong

Binky's Achievements

  1. Hi all, I've written a custom order module that calculates a discount depending on the company that they customer belongs to. The only thing is that while it calculates and takes the discount the subtotal OK, the Tax is calculated on the full cost of the product rather than the subtotal? I'm using osCommerce 2.2-MS2 Here's the listing of my discount module: <?php class ot_companydiscount { var $title, $output; function ot_companydiscount() { $this->code = 'ot_companydiscount'; $this->title = MODULE_COMPANY_DISCOUNT_TITLE; $this->description = MODULE_COMPANY_DISCOUNT_DESCRIPTION; $this->enabled = ((MODULE_COMPANY_DISCOUNT_STATUS == 'true') ? true : false); $this->sort_order = MODULE_COMPANY_DISCOUNT_SORT_ORDER; $this->output = array(); } function process() { global $order, $currencies, $customer_id; if ( MODULE_COMPANY_DISCOUNT_STATUS == 'true' ) { $discount_sql = 'SELECT company_detail.discount, company_detail.name '. 'FROM (customers INNER JOIN address_book ON (customers.customers_id = address_book.customers_id) AND '. '(customers.customers_default_address_id = address_book.address_book_id)) INNER JOIN company_detail ON '. 'address_book.entry_company = company_detail.id '. 'WHERE (((customers.customers_id)='.(int)$customer_id.'))'; $discount_query = tep_db_query( $discount_sql ); $discount_rs = tep_db_fetch_array( $discount_query ); $discount_company_name = $discount_rs['name']; $discount_amount = $discount_rs['discount']; //Calculate course total cost //Got total number of individual order items $no_items=count($order->products); //Get course order total $course_order_total=0; for($count=1; $count <= $no_items; $count++){ //Test if item is a course item or not $prod_id=$order->products[$count-1]['id']; $sql="select categories_id from products_to_categories where products_id=$prod_id"; $prod_query = tep_db_query ($sql); $prod_rs = tep_db_fetch_array ($prod_query); $category_id= $prod_rs['categories_id']; // Add discount to products in the cources category. if(tep_is_course($category_id)) $course_order_total = $course_order_total + ($order->products[$count-1]['price'] * $order->products[$count-1]['qty']); } } $discount_total = $course_order_total * ($discount_amount/100); /* Take discount of the tax and off the value of the program. We might have to change how this all works depending on what tax is paid on differnt products and how that varies depending upon where the users come from. Think about adding the discount amount directly to the order object, its stored in a session. */ $order->info['total'] = $order->info['total'] - $discount_total; $order->info['subtotal']=$order->info['total'] - $discount_total; if($discount_amount != 0){ $this->output[] = array('title' => ''.$this->title.'' . ' '. $discount_amount.'% :', 'text' => $currencies->format(tep_add_tax( (0-$discount_total) , $tax), true, $order->info['currency'], $order->info['currency_value']), 'value' => tep_add_tax( (0-$discount_total) , $tax)); } } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_COMPANY_DISCOUNT_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function keys() { return array( 'MODULE_COMPANY_DISCOUNT_STATUS', 'MODULE_COMPANY_DISCOUNT_SORT_ORDER' ); } 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 Company Discount', 'MODULE_COMPANY_DISCOUNT_STATUS', 'true', 'Do you want to display the company discount?', '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_COMPANY_DISCOUNT_SORT_ORDER', '4', 'Sort order of display.', '6', '2', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } } ?> The desired output should be: But I'm getting Which is totally wrong! Anyone got any clues? Thanks!
  2. Dude, Fantastic contribution - well done m8! Binky
  3. 2 ways you can do this: 1. Use the credit card module and process the credit card offline using "PDQ" machine ( manual credit card processing found in smaller shops ) 2. Use Paypal/WorldPay/Secpay Hope this helps!
  4. Binky

    Secpay and XML-RPC

    Anyone had any experience with the XML-RPC API for Secpay? http://www.secpay.com/secxmlrpc/index.html I would like to use Secpay but don't want to use their template - I would like the integration to be as seamless as possible and not have to take users off to an external website for payment. I know you can theme the template, but the URL is still different. Would like to keep it all on one site so it looks more "secure" and professional. Has anyone had any success in integrating this in OS Commerce using PHP? The client has already commited their merchant account to using XML-RPC as there are 2 different forms to fill in depending on whether you use the provided template or XML-RPC. May apologies if this has already been answered, in which case please direct me to the relevant FAQ/post - I'm new to all Commerce! Thanks
×
×
  • Create New...