Negative discount group on some custommers
Hello, Im working on a membership design for my site, I made one simple change that works pretty fine:
I modified functions_prices.php around line 26
PHP Code:
if ($specials->RecordCount() > 0) {
// if ($product->fields['products_priced_by_attribute'] == 1) {
$special_price = ($specials->fields['specials_new_products_price']);
to
PHP Code:
if ($specials->RecordCount() > 0) {
// if ($product->fields['products_priced_by_attribute'] == 1) {
if ($_SESSION['customer_id']) {$special_price = $specials->fields['specials_new_products_price'];}
else {$special_price = (($specials->fields['specials_new_products_price'])*1.05);}
that way all custommers that have registration and are logged in can see prices normal and the customers that are not logged will see the prices +5%, also that makes the changes in the cart and on shipping total.
The problem is here: I want to have an profile (lets name it - orders by phone) from wich I can make order with 5% above the regular price that registed user pay, because this 5% are the income that goes for phone and employe expenses.
Is there a way to create an group discount -5% (not +5%!) so I can assign it to that profile "orders by phone"?
I assume that I have to give
PHP Code:
$_SESSION['customer_id'] = id (of that profile)
but I cant find the right way to do it.
Thank you
Re: Negative discount group on some custommers
Quote:
Originally Posted by
perfumbg
Hello, Im working on a membership design for my site, I made one simple change that works pretty fine:
I modified functions_prices.php around line 26
PHP Code:
if ($specials->RecordCount() > 0) {
// if ($product->fields['products_priced_by_attribute'] == 1) {
$special_price = ($specials->fields['specials_new_products_price']);
to
PHP Code:
if ($specials->RecordCount() > 0) {
// if ($product->fields['products_priced_by_attribute'] == 1) {
if ($_SESSION['customer_id']) {$special_price = $specials->fields['specials_new_products_price'];}
else {$special_price = (($specials->fields['specials_new_products_price'])*1.05);}
that way all custommers that have registration and are logged in can see prices normal and the customers that are not logged will see the prices +5%, also that makes the changes in the cart and on shipping total.
The problem is here: I want to have an profile (lets name it - orders by phone) from wich I can make order with 5% above the regular price that registed user pay, because this 5% are the income that goes for phone and employe expenses.
Is there a way to create an group discount -5% (not +5%!) so I can assign it to that profile "orders by phone"?
I assume that I have to give
PHP Code:
$_SESSION['customer_id'] = id (of that profile)
but I cant find the right way to do it.
Thank you
Understand that in part asking for custom code. That said, if you have say a single "order by phone" profile which has its own limits when providing information to call in customers, then something like the below would charge the same 5 percent that is seen by a non-registered/not logged in customer. Additionally, I've added some additional "sanitization" checks to your code:
Code:
if ($specials->RecordCount() > 0) {
// if ($product->fields['products_priced_by_attribute'] == 1) {
if (isset($_SESSION['customer_id']) && is_numeric($_SESSION['customer_id']) && zen_not_null($_SESSION['customer_id']) && (int)$_SESSION['customer_id'] == $_SESSION['customer_id'] && $_SESSION['customer_id'] == X) {$special_price = $specials->fields['specials_new_products_price'] * 1.05;}
elseif (isset($_SESSION['customer_id']) && is_numeric($_SESSION['customer_id']) && zen_not_null($_SESSION['customer_id']) && (int)$_SESSION['customer_id'] == $_SESSION['customer_id'] && $_SESSION['customer_id']) {$special_price = $specials->fields['specials_new_products_price'];}
else {$special_price = (($specials->fields['specials_new_products_price'])*1.05);}
Now, if your user is in fact part of a group, then need extra code to identify whether the user is in the desired group(ing). That would be an additional check at the end of the first if test and entered similar as provided. It would replace the session test against X.
BTW, X is the number for the customers_id that represents your phone order user.
Re: Negative discount group on some custommers
Quote:
Originally Posted by
mc12345678
Now, if your user is in fact part of a group, then need extra code to identify whether the user is in the desired group(ing). That would be an additional check at the end of the first if test and entered similar as provided. It would replace the session test against X.
BTW, X is the number for the customers_id that represents your phone order user.
Hello, no I dont specialy need that profile to be an part of a group, however I managed to do what I needed and if it will be usefull to somebody I'm posting the code below:
PHP Code:
$admincustomer = $_SESSION['customer_id'];
$adminarray = array(1,2,3/[B]whatever the customer ID is[/B]/);
if ($specials->RecordCount() > 0) {
// if ($product->fields['products_priced_by_attribute'] == 1) {
if (in_array($admincustomer, $adminarray)) {$special_price = (($specials->fields['specials_new_products_price'])*1.05);}
elseif ($_SESSION['customer_id']) {$special_price = $specials->fields['specials_new_products_price'];}
else {$special_price = (($specials->fields['specials_new_products_price'])*1.05);}
You mentioned "sanitization" do I have to change something else?
Kind regards and thanks for the help!