Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / I want user with company name automatically assigned to specific group

I want user with company name automatically assigned to specific group

Locked

Started by jong123 on 18 Apr 2010, 11:09 AM · Views: 2,116

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
18 Apr 2010, 11:09 AM
#1
jong123 avatar

jong123

New Zenner

Join Date:
Apr 2010
Posts:
7
Plugin Contributions:
0

I want user with company name automatically assigned to specific group

Hi,

Really struggling with this - been searching forever and can't find out how to do this. If I have missed a thread with relevant info then sorry - please point me in the right direction.

But what I want is that IF a customer adds a company name when registering, they automatically get put into the 'Trade' group that I created, which will give them an immediate discount.

I realise that anyone could enter a company name in the hope of getting a discount but this isn't a problem because while the order is being processed, which takes a few days, I will be contacting them for further details.

So all I want is for them to automatically be assigned to my 'Trade' group so that they can order immediately at the discounted price.

Here's my version info:

Zen Cart 1.3.8a
Patch: 1::
Database Patch Level: 1.3.8

Can anyone help me figure this out. I'm tearing hair out in clumps now! :-)

Jon.

18 Apr 2010, 12:11 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,743
Plugin Contributions:
56

Re: I want user with company name automatically assigned to specific group

Nothing is built in to do this. You would have to customize the signup process by writing code.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

18 Apr 2010, 1:47 PM
#3
jong123 avatar

jong123

New Zenner

Join Date:
Apr 2010
Posts:
7
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

Yes, thanks - I realised there would be some editing to do. But I have no clue what to edit or what changes to make. That's the part I need the help with.

I know how to edit the files as I have already done a few mods so all I need is the name of the file to edit and the changes that need to be made. I have looked at some of the files but I can't figure it out.

18 Apr 2010, 2:42 PM
#4
jong123 avatar

jong123

New Zenner

Join Date:
Apr 2010
Posts:
7
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

In includes/functions/functions_customers.php I did find this code:

if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) ) {

  $address_out = $company . $cr . $address_out;

}

The stars are not in there but I added them here because I'm wondering if this is a place where I could insert code to put the customer into a group? I'm assuming that at this point a company name is in use.

Please can someone let me know if I'm in the right area. Thanks.

18 Apr 2010, 2:48 PM
#5
jong123 avatar

jong123

New Zenner

Join Date:
Apr 2010
Posts:
7
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

Mmmm - having thought about this, maybe not. Obviously, I only need to set this up once at registration and I assume adding code here would keep on assigning to the group each time this function is called...

Looks like I might have half the code I need - I just don't know what to add to it and where it needs to go...

18 Apr 2010, 2:55 PM
#6
jong123 avatar

jong123

New Zenner

Join Date:
Apr 2010
Posts:
7
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

Can this part be used?

if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) ) {

ADD CODE HERE TO ASSIGN TO A GROUP NAMED 'Trade'

}

Close? Miles off? I'm half guessing really so any help would be appreciated.

18 Apr 2010, 5:43 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: I want user with company name automatically assigned to specific group

Here's how to have ALL customers join a particular group: http://www.zen-cart.com/forum/showthread.php?t=123132
You can adapt it to have it use a different group number depending on whether certain fields have been filled in, or whatever.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Apr 2010, 7:20 PM
#8
jong123 avatar

jong123

New Zenner

Join Date:
Apr 2010
Posts:
7
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

Thank you! That works great. I had to make a minor change so here's what I did, in case anyone else is trying to do the same thing:

First I created two groups - Trade (1) and Standard (2). Trade has 30% off and Standard has 0% off.

Then I edited /includes/modules/create_account.php

if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) ) {

$grp = 1;

} else {

$grp = 2;

}

if ($error == true) {

// hook notifier class

$zco_notifier->notify('NOTIFY_FAILURE_DURING_CREATE_ACCOUNT');

} else {

$sql_data_array = array('customers_firstname' => $firstname,

                        'customers_lastname' => $lastname,

                        'customers_email_address' => $email_address,

                        'customers_nick' => $nick,

                        'customers_telephone' => $telephone,

                        'customers_fax' => $fax,

                        'customers_newsletter' => (int)$newsletter,

                        'customers_email_format' => $email_format,

'customers_group_pricing' => $grp,

                        'customers_default_address_id' => 0,

                        'customers_password' => zen_encrypt_password($password),

                        'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION

);

Not sure if that's the best way to get that working but it does so I hope it helps someone else. Thanks again for the help.

2 Jun 2010, 9:01 PM
#9
valnoren avatar

valnoren

New Zenner

Join Date:
Mar 2006
Posts:
63
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

This is helpful I have one small question... What if you have a certain company you want to be assigned to a specific group? how would that look in the code?

2 Jun 2010, 9:12 PM
#10
valnoren avatar

valnoren

New Zenner

Join Date:
Mar 2006
Posts:
63
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

Could you do this??

if ( (ACCOUNT_COMPANY == 'ACME') && (zen_not_null($company)) ) {

$grp = 1;

} else {

$grp = 2;

2 Jun 2010, 9:21 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: I want user with company name automatically assigned to specific group

No.

This would be more appropriate:
Change this:```
if ( (ACCOUNT_COMPANY == 'true') && (zen_not_null($company)) ) {

$grp = 1;

} else {

$grp = 2;

}
to this:
if ( (ACCOUNT_COMPANY == 'true') && ($company == 'ABC Company')) ) {

$grp = 1;

}

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Jun 2010, 3:59 PM
#12
valnoren avatar

valnoren

New Zenner

Join Date:
Mar 2006
Posts:
63
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

Ahh I see thanks ... wait what line was this on ??...

12 Aug 2010, 11:47 AM
#13
timontom avatar

timontom

New Zenner

Join Date:
Aug 2010
Posts:
25
Plugin Contributions:
0

Re: I want user with company name automatically assigned to specific group

Regarding the all "Group Pricing Per Item" issue:
I did all (I think...) I asked in the instruction of:
http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=256

When I making some test order proccess:
The Shopping Cart contain the right Sub-Total OK and the right total group price. BUT, when I continu to the checkout page:
in Step 2 of 3 - Payment Information and also
in Step 3 of 3 - Order Confirmation and also
in the Order Confirmation email

The Total shown is the regular price and not the group price. why?