Sarah_h Posted August 8, 2005 Posted August 8, 2005 Hi All I have pwa installed and working. I wanted a simple member discount add-on and installed xmembers 2.2. In itself it works great, nice and simple and give anyone who adds an account a predeturmined discount. BUT this discount is given even when someone uses pwa!!!! My question therefore is: has anyone any experience with configuring xmembers to only give discount if the visitor has added an account?? Any help here would be very useful and appriciated. Regards Sarah Quote
Sarah_h Posted August 8, 2005 Author Posted August 8, 2005 Hi All I have pwa installed and working. I wanted a simple member discount add-on and installed xmembers 2.2. In itself it works great, nice and simple and give anyone who adds an account a predeturmined discount. BUT this discount is given even when someone uses pwa!!!! My question therefore is: has anyone any experience with configuring xmembers to only give discount if the visitor has added an account?? Any help here would be very useful and appriciated. Regards Sarah <{POST_SNAPBACK}> Seems I'm replying to my own post!!! Anyway I've made ome changes to catalog/includes/modules/order_total/ot_xmembers.php so that if the visitor uses PWA then they do not get a discount. These are the changes I've made: I've changed the member_flag field in the DB so that it defaults to 1 so that it defaults to everyone getting a discount. Then I've amended ot_xmembers.php like this so that only members get a discount. function calculate_credit($amount) { global $order, $customer_id; $od_amount=0; $od_pc = $this->percentage; if ($amount > $this->minimum) { $query = tep_db_query("select member_flag, purchased_without_account from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'"); $query_result = tep_db_fetch_array($query); if ($query_result['member_flag'] == '1' && $query_result['purchased_without_account'] == '0') {// Calculate tax reduction if necessary if($this->calculate_tax == 'true') { // Calculate main tax reduction $tod_amount = round($order->info['tax']*10)/10*$od_pc/100; $order->info['tax'] = $order->info['tax'] - $tod_amount; // Calculate tax group deductions reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amount = round($value*10)/10*$od_pc/100; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } $od_amount = round($amount/10); $od_amount = $od_amount + $tod_amount; } } return $od_amount; } I'm not sure if this is the right way to do it though (probably not!! My coding skills are fairly basic) but it does work. Sarah. Quote
boxtel Posted August 8, 2005 Posted August 8, 2005 Seems I'm replying to my own post!!! Anyway I've made ome changes to catalog/includes/modules/order_total/ot_xmembers.php so that if the visitor uses PWA then they do not get a discount. These are the changes I've made: I've changed the member_flag field in the DB so that it defaults to 1 so that it defaults to everyone getting a discount. Then I've amended ot_xmembers.php like this so that only members get a discount. function calculate_credit($amount) { global $order, $customer_id; $od_amount=0; $od_pc = $this->percentage; if ($amount > $this->minimum) { $query = tep_db_query("select member_flag, purchased_without_account from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'"); $query_result = tep_db_fetch_array($query); if ($query_result['member_flag'] == '1' && $query_result['purchased_without_account'] == '0') {// Calculate tax reduction if necessary if($this->calculate_tax == 'true') { // Calculate main tax reduction $tod_amount = round($order->info['tax']*10)/10*$od_pc/100; $order->info['tax'] = $order->info['tax'] - $tod_amount; // Calculate tax group deductions reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amount = round($value*10)/10*$od_pc/100; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } $od_amount = round($amount/10); $od_amount = $od_amount + $tod_amount; } } return $od_amount; } I'm not sure if this is the right way to do it though (probably not!! My coding skills are fairly basic) but it does work. Sarah. <{POST_SNAPBACK}> that works, you could also have done: function ot_xmembers() { if (tep_session_is_registered('noaccount')) { $this->enabled = false; } else { $this->enabled = MODULE_XMEMBERS_STATUS; } ...... ...... Quote Treasurer MFC
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.