Jump to content
Sign in to follow this  
Sarah_h

xmembers and pwa ... help requested

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

 

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.

Share this post


Link to post
Share on other sites
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.

 

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;

}

......

......


Treasurer MFC

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×