25% off Bakery prices if user is logged on

jacobi22

see the post from marmot in the top of the thread here, it works without problems

Lighat


jacobi22

QuoteCan you point me to the german forum as I wouldn't know how to search for it in German (I don't speak the language) so I can try translating it with google translate!

http://www.websitebaker.org/forum/index.php/topic,24695.0.html

svsanchez

Hello Marmot and Jacobi for your help. Yes I use version bakery 1.6!

Jacobi, any way I could achieve having the 2 prices depending on the 'usergroup' as Marmot suggested is worth looking at. Can you point me to the german forum as I wouldn't know how to search for it in German (I don't speak the language) so I can try translating it with google translate!

Thanks again!

jacobi22

if i remember correct, svsanchez  use the bakery 1.60,  if so, take a look to the code lines before you change anything

the code from marmot (bakery 1.70) is the same in bakery 1.60, but the code lines are different

\modules\bakery\view.php(273)  in Vers. 1.70 is line 250 in Vers 1.60
\modules\bakery\view_item.php(100) in Vers. 1.70 is line 78 in Vers 1.60
\modules\bakery\view_overview.php(69) in Vers. 1.70 is line 85 in Vers 1.60

in the german bakery thread we have some solutions for a new price, if you use a item options, based on javascript or jquery. can that be a way?

marmot

#3
Hi,

Quote from: svsanchez on February 12, 2014, 10:15:23 PM
Hmmm... I guess it's not so easily achievable?
depends on what you consider to be easy. Just find the relevant places where the price is read from the database: \modules\bakery\view.php(273):    
$sql_result2 = $database->query("SELECT title, price, sku, stock, tax_rate FROM " .TABLE_PREFIX."mod_bakery_items WHERE item_id = '$item_id'");
----------------------------------------
\modules\bakery\view_item.php(100):
$query_item = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_bakery_items WHERE item_id = '".ITEM_ID."' AND active = '1'");
----------------------------------------
\modules\bakery\view_overview.php(69):
$query_items = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_bakery_items WHERE section_id = '$section_id' AND active = '1' AND title != '' ORDER BY position ASC".$limit_sql);
and combine them with detection of user Group (patch "Administrator" group to your needs): \modules\bakery\view.php(273):
$sel = $sel = isset($_SESSION['GROUP_NAME']) && in_array('Administrators', $_SESSION['GROUP_NAME']) ? "item_id, section_id, page_id, group_id, active, position, title, sku, stock, (price * 0.75) AS price, shipping, tax_rate, definable_field_0, definable_field_1, definable_field_2, link, description, full_desc, modified_when, modified_by, created_when, created_by" : "*";
$sql_result2 = $database->query("SELECT ".$sel." FROM " .TABLE_PREFIX."mod_bakery_items WHERE item_id = '$item_id'");
----------------------------------------
\modules\bakery\view_item.php(100):
$sel = $sel = isset($_SESSION['GROUP_NAME']) && in_array('Administrators', $_SESSION['GROUP_NAME']) ? "item_id, section_id, page_id, group_id, active, position, title, sku, stock, (price * 0.75) AS price, shipping, tax_rate, definable_field_0, definable_field_1, definable_field_2, link, description, full_desc, modified_when, modified_by, created_when, created_by" : "*";
$query_item = $database->query("SELECT ".$sel." FROM ".TABLE_PREFIX."mod_bakery_items WHERE item_id = '".ITEM_ID."' AND active = '1'");
----------------------------------------
\modules\bakery\view_overview.php(69):
$sel = $sel = isset($_SESSION['GROUP_NAME']) && in_array('Administrators', $_SESSION['GROUP_NAME']) ? "item_id, section_id, page_id, group_id, active, position, title, sku, stock, (price * 0.75) AS price, shipping, tax_rate, definable_field_0, definable_field_1, definable_field_2, link, description, full_desc, modified_when, modified_by, created_when, created_by" : "*";
please backup and test before using this.

regards

Edith: added test for session field GROUP_NAME to avoid warnings and notices

svsanchez

Hmmm... I guess it's not so easily achievable? And what about using a 'discount code' at checkout? Like "enter your member code in order to get your member discount"?

svsanchez

Hello community

I have a customer who wants to sell products both to regular visitors as to "members" of his shop, who act as resellers. He has asked me if it would be possible to show a 25% off price to customers who sign-in to his bakery cart.

So, not logged customer would see $100
But a logged customer would see $75 instead

Given the flexibility of Bakery, I guess this shouldn't be too difficult to do? What do you think?