Post by RockingSkier » Mon Jan 04, 2010 9:27 pm

Hi All,

Is it possible to assign a delivery option to a customer group?

i.e. "cash on delivery" is only available to the cutomer group "people_I_trust_to_pay".

I have had a look at all the features and played with some of the code but I am not sure how to go about doing this.

Is there a variable I can check for the customer group so I could simply add a little php check?

Code: Select all

// --------
// cod.tpl
// --------

<?php if( $customerGroup == "people_I_trust_to_pay") { ?>
   // cod.tpl code
<?php }?>
I know this would be a bit of a hack but if thats what it needs then I dont mind.

Thanks in advance.

RockingSkier

p.s. Awesome work Daniel. OpenCart is damn impressive. Looking forward to future versions.

Newbie

Posts

Joined
Mon Jan 04, 2010 8:26 pm

Post by scwhost » Wed Jan 06, 2010 12:05 am

I too am looking for the same type of thing! Good Question

Newbie

Posts

Joined
Thu Dec 31, 2009 3:32 am

Post by JNeuhoff » Wed Jan 06, 2010 12:11 am

You could copy and modify one of the existing payment modules and then simply add a check in the getMethod function of the catalog/model/payment/whatever.php file. The check would would make sure that the customer is logged in and belongs to the right customer group. The admin backend of the payment module could be extended so as to make the allowed customer group for the payment module configurable.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Wed Jan 06, 2010 1:24 am

I had actually had started adding this to my last few payment modules I made for this exact reason. Trusted customers were allowed to use Purchase Order and Bank Transfer while newbies only get to see paypal or visa
Image

The caveat is that it is done at the individual payment module level. Would be nice to have it at the global level so it will work dynamically for any and all payment (and even shipping) modules.

Maybe I can add it to the Customer->Customer Group menu and then improve the getExtensions model function to check the customer group allowance

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by RockingSkier » Wed Jan 06, 2010 8:38 pm

Brilliant ideas, thanks.

I will give it a go today. I am still trying to get my head round all the different files etc so if you have any helpful pointers they would be hugely appreciated. I only need it for one payment method, cash on delivery (at least at the moment).

I will let you know how it goes.

Cheers.

RockingSkier

Newbie

Posts

Joined
Mon Jan 04, 2010 8:26 pm

Post by RockingSkier » Wed Jan 06, 2010 9:20 pm

I know it is very much a hack but it works for now.

Qphoria I know you are fairly skilled at OpenCart so please dont be offended by my cheap hackery :) .

It will do until I (or someone else) comes up with a more permanent fix.

Code: Select all

	// 1-3-2\catalog\model\payment\cod.php

	$customer_group_id = $this->customer->getCustomerGroupId();
	
	// If customer is part of group 9 (Credit account)
	if($customer_group_id == 9 ){
		if (!$this->config->get('cod_geo_zone_id')) {
			$status = TRUE;
		} elseif ($query->num_rows) {
			$status = TRUE;
		} else {
			$status = FALSE;
		}
	} else  {
		$status = FALSE;
	}

Newbie

Posts

Joined
Mon Jan 04, 2010 8:26 pm

Post by Qphoria » Wed Jan 06, 2010 10:26 pm

That's not too bad. If it works that is all that matters.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by oyvpet » Tue Feb 01, 2011 4:04 am

This works great, thx alot.
One small error in the code, it was missing an: } at the end. The correct code is:

Code: Select all

   // 1-3-2\catalog\model\payment\cod.php

   $customer_group_id = $this->customer->getCustomerGroupId();
   
   // If customer is part of group 9 (Credit account)
   if($customer_group_id == 9 ){
      if (!$this->config->get('cod_geo_zone_id')) {
         $status = TRUE;
      } elseif ($query->num_rows) {
         $status = TRUE;
      } else {
         $status = FALSE;
      }
   } else  {
      $status = FALSE;
   }
   }
It worked for me. I have extremly limited coding experience but i think Im right. :-)

Newbie

Posts

Joined
Mon Jan 31, 2011 2:49 am

Post by mrcraz » Thu Aug 18, 2011 11:52 pm

Try this one. I a bit adjust (For bank transfer, you may change for COD same concept.) to keep original code work. Only more group affect.

$customer_group_id = $this->customer->getCustomerGroupId();
if($customer_group_id == 6 ){
$status = TRUE;
}

elseif
($this->config->get('bank_transfer_status')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('bank_transfer_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get('bank_transfer_geo_zone_id')) {
$status = TRUE;
} elseif ($query->num_rows) {
$status = TRUE;
} else {
$status = FALSE;
}
} else {
$status = FALSE;
}

Newbie

Posts

Joined
Fri Jul 22, 2011 5:57 pm
Who is online

Users browsing this forum: Bing [Bot] and 103 guests