[ic] Is it possible to adjust discount per customer group basis?

Stefan Hornburg Racke interchange-users@icdevgroup.org
Fri Jun 14 05:31:02 2002


Jani Tolonen <jani@mysql.com> writes:

> Hi!
> 
> I'm using Interchange version 4.8.5
> 
> I'm looking for a way to set discount for all items per customer group
> basis. My idea was to use the 'Price Level' -labeled field in table
> 'userdb' (the real name of the field is 'price_level').
> 
> In the demo foundation this field contains values such as:
> 
> - Retail
> - Dealer
> - Distributor
> - Wholesaler
> - Small business
> - Large corporate
> - Private person
> - Governmental or educational
> 
> What I would like to do is to set a certain discount % to all of these
> groups and it would apply to all items.
> 
> For example:
> 
> customer group	discount %
> ==============	==========
> Retail		10%
> Dealer		20%
> Private		0%
> 
> Let's assume item 'A' costs 100 USD.  If a customer who is a member of
> 'Retail' group buys this item, he would get it for 90 USD. Customer
> from 'Dealer' group would get it for 80 USD and 'Private' for 100 USD.
> 
> In case of many items is purchased at once and pricing is for example
> 100 USD for one item and 90 USD for 2 items, and the customer buys 2
> items, the discount % would be taken from the quantity price.
> 
> Is this doable?
> 
> If not, is it planned for a future version of Interchange?
> 
> I'd be grateful for any input!

I use the following code for that in profiles.login. You need to use
the [discount-price] and [item-discount-subtotal] tags in place of
the regular ones in templates/components/cart and all other places
where the price appears.

__NAME__ Logout_choice

[if type=explicit compare="[userdb function=logout clear='[cgi clear_values]']"]
	[discount ALL_ITEMS][/discount]
	[set mv_no_count]1[/set]
	[set mv_no_session_id]1[/set]
	[if cgi clear_cart]
	[calc] @$Items = (); return; [/calc]
	mv_nextpage=[either][cgi mv_successpage][or][cgi mv_nextpage][/either]
[else]
	mv_nextpage=[either][cgi mv_failpage][or][cgi mv_nextpage][/either]
[/else]
[/if]

__END__

__NAME__ Logout

[if type=explicit compare="[userdb function=logout clear=1]"]
	[discount ALL_ITEMS][/discount]
	[set mv_no_count]1[/set]
	[set mv_no_session_id]1[/set]
	mv_nextpage=[either][cgi mv_successpage][or][cgi mv_nextpage][/either]
[else]
	mv_nextpage=[either][cgi mv_failpage][or][cgi mv_nextpage][/either]
[/else]
[/if]

__END__

__NAME__ Login

[if type=explicit compare="[userdb login]"]
[perl tables=userdb]
return unless $Session->{logged_in};
$pl = $Tag->data('userdb','price_level',$Session->{username});
$dc = 0;
if ($pl eq 'dealer') {
    $dc = $Variable->{DISCOUNT_DEALER};
} elsif ($pl eq 'distributor') {
    $dc = $Variable->{DISCOUNT_DISTRIBUTOR};
}
if ($dc) {
    $Tag->discount('ALL_ITEMS', "\$s - int(\$s * $dc)");
}
[/perl]
	[set mv_no_count][/set]
	[set mv_no_session_id][/set]
	mv_nextpage=[either][cgi mv_successpage][or][cgi mv_nextpage][/either]
[else]
	mv_nextpage=[either][cgi mv_failpage][or][cgi mv_nextpage][/either]
[/else]
[/if]

__END__

__NAME__ Change_password

[if type=explicit compare="[userdb change_pass]"]
	mv_nextpage=[either][cgi mv_successpage][or][cgi mv_nextpage][/either]
[else]
	mv_nextpage=[either][cgi mv_failpage][or][cgi mv_nextpage][/either]
[/else]
[/if]

__END__


Ciao
        Racke

-- 
Free resources for Interchange programming NOW !!! 
Don't hesitate to contact me if you need my professional help.
Your core developer and consultant for the most sophisticated,
flexible and extensible Open Source eCommerce software.