Forums / Built-in Shipping and Payment Modules / Is it possible to enable a shipping method for only a certain customer group?

Is it possible to enable a shipping method for only a certain customer group?

Locked

Views: 5,455

Results 21 to 38 of 38
This thread is locked. New replies are disabled.
10 May 2010, 2:41 AM
#21
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Is it possible to enable a shipping method for only a certain customer group?

Sorry.... you told me where to put it... can you tell I've been looking at this too long?!?!? :blush:

10 May 2010, 3:02 AM
#22
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

I have:

function check() {
    global $db;
    if (!isset($this->check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COUPON_STATUS'");
      $this->check = $check_query->RecordCount();
    }
 if (!IS_ADMIN_FLAG) {
      if ($chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
    if ($chk_group->fields['customers_group_pricing'] == 3) {
        $this->check = 0;
      }
    }

	return $this->check;
  }

but am only getting a white blank screen...:cry:

10 May 2010, 1:46 PM
#23
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

You need to straighten out the code on this ...

  function check() {
    global $db;
    if (!isset($this->check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COUPON_STATUS'");
      $this->check = $check_query->RecordCount();
    }

    // do not check if in the admin
    if (!IS_ADMIN_FLAG) {
      // get the customers_group_pricing
      $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if ($chk_group->fields['customers_group_pricing'] == 3 || $chk_group->fields['customers_group_pricing'] == 7) {
        // if in customers_group_pricing 3 or 7 do not show
        $this->check = 0;
      }
    }

    return $this->check;
  }  

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

10 May 2010, 2:01 PM
#24
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

Thank you for that, Linda... I no longer have a blank white screen but I am still seeing the Discount Coupon box which should be hidden from that customer... :frusty:

10 May 2010, 2:16 PM
#25
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

Make sure when you login you are logged in with either group 3 or 7 ...

And on the checkout_payment you should not see the Discount Coupon input box ...

Login as a customer not in group 3 or 7 and you will see it ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

10 May 2010, 2:24 PM
#26
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

I have been using a test customer in group 2 (I have changed the code to only use this group) I have added your test account to this group as well if you'd be so kind as to take a peek... :

  function check() {
    global $db;
    if (!isset($this->check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COUPON_STATUS'");
      $this->check = $check_query->RecordCount();
    }

    // do not check if in the admin
    if (!IS_ADMIN_FLAG) {
      // get the customers_group_pricing
      $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if ($chk_group->fields['customers_group_pricing'] == 2) {
        // if in customers_group_pricing 2 
        $this->check = 0;
      }
    }

    return $this->check;
  }
10 May 2010, 2:37 PM
#27
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

Good news ... I am not getting it to work now ... :smile:

Bad news ... I am not getting it to work now ... :blink:

I am not sure when I can get back to work on this ... let me see what I can do ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

10 May 2010, 2:42 PM
#28
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

:laugh:

Thank you for helping me with this, it can sure be frustrating sometimes... kinda makes me wanna... :Flush:

10 May 2010, 2:56 PM
#29
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

Try this ...

Put the code back to the original file in ot_coupon.php

Now change the credit_selection function instead:

  function credit_selection() {
    global $discount_coupon;
    global $db;
    // note the placement of the redeem code can be moved within the array on the instructions or the title

    // do not check if in the admin
    if (!IS_ADMIN_FLAG) {
      // get the customers_group_pricing
      $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if ($chk_group->fields['customers_group_pricing'] == 3 || $chk_group->fields['customers_group_pricing'] == 7) {
        // if in customers_group_pricing 3 or 7 do not show
      } else {
    $selection = array('id' => $this->code,
                       'module' => $this->title,
                       'redeem_instructions' => MODULE_ORDER_TOTAL_COUPON_REDEEM_INSTRUCTIONS . ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_REMOVE_INSTRUCTIONS : ''),
                       'fields' => array(array('title' => ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_TEXT_CURRENT_CODE . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $discount_coupon->fields['coupon_code'] . '</a><br />' : '') . MODULE_ORDER_TOTAL_COUPON_TEXT_ENTER_CODE,
                                               'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'),
                                               'tag' => 'disc-'.$this->code
                       )));
      }
    }
    return $selection;
  }

See if that works better ...

NOTE: I am still using groups 3 and 7 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

10 May 2010, 3:10 PM
#30
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

YES!!!! That did it!!! You bring tears of joy to my eyes!!!!

THANK YOU, THANK YOU, THANK YOU!!!!!

:rotflmao:

10 May 2010, 3:21 PM
#31
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

That was loads of fun ... :frusty:

Thanks for the update that this is woking for you ... :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

10 May 2010, 3:36 PM
#32
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

I truly appreciate your patience and brilliance, Linda! :yes:

Do you mind if I sum this coupon part up and put this into a new thread to help others along?

Cheers,

J.

12 May 2010, 5:08 AM
#33
gg01 avatar

gg01

New Zenner

Join Date:
Jul 2008
Location:
Ontario, Canada
Posts:
85
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

Me again :D. Can I confirm with you that this code is okay to put into includes\modules\payment\cod.php to allow only certain customers the option to pay upon pickup? I've tested it and it seems fine, just looking for some expert eyes so as to avoid any potential problems... :blush:

'zone_id']) {
            $check_flag = true;
            break;
          }
          $check->MoveNext();
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }

	  $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
	if ($chk_group->fields['customers_group_pricing'] == 2 || $chk_group->fields['customers_group_pricing'] == 3) {
      $this->enabled = true;
    } else {
      $this->enabled = false;
    }
	  
// disable the module if the order only contains virtual products
      if ($this->enabled == true) {
        if ($order->content_type != 'physical') {
          $this->enabled = false;
        }
12 May 2010, 2:04 PM
#34
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

It appears correct, as long as you have tested that this is working correctly and only showing for Group 2 and 3 and nobody else, then is should be fine ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Dec 2010, 4:27 AM
#35
solidrock avatar

solidrock

New Zenner

Join Date:
Nov 2009
Location:
Aurora, IN
Posts:
37
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

I am also interested in only showing a particular shipping module/option when a customer is from a certain pricing group. I am not very good at coding. I have three customer groups. I call them retail, wholesale, and distributor. I want the third group to see only one particular module (staticlist)--a shipping mod I've installed.

Any help in getting this done would be greatly appreciated. Thanks!

Gary

PS. I'm using 1.3.8a (might upgrade soonish when I have time)

26 Dec 2010, 2:33 PM
#36
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

If that shipping module is like the others, you should have a setting for the $this->enabled ...

For example, on the Flat Rate flat shipping module in:
/includes/modules/shipping/flat.php

you could customize it so that it only shows for those in Group ID 3 by adding the new code in red:

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }

      // disable when Group ID is not 3
      $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if ($chk_group->fields['customers_group_pricing'] != 3)  {
        $this->enabled = false;
      }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Dec 2010, 5:48 PM
#37
solidrock avatar

solidrock

New Zenner

Join Date:
Nov 2009
Location:
Aurora, IN
Posts:
37
Plugin Contributions:
0

Re: Is it possible to enable a shipping method for only a certain customer group?

:clap: :-) Thank you! The coding works great! One more question: This mod allows me to have customizable multiple choices for shipping, with a different rate for each one. Right now I can only make it a fixed amount. Any way to make it a percentage of the order total? Or do I need to ask the mod creator?

26 Dec 2010, 5:52 PM
#38
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to enable a shipping method for only a certain customer group?

I don't know anything about the shipping module you are using so probably addressing it to the developer of it would help you best ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!