Jump to content

[SOLVED] Price tax depending on group


Recommended Posts

Hi everyone,

I want to be able to display different price tax settings to different groups. (Retail shop with tax included, where trade shop with tax excluded until checkout)

I don't mind hard coding this into PS as the group id of the trade group wont change.

I'm pretty sure I know how to code it, im just struggling to find how to pull the correct variable from PS...

I need to get a list of the groups the current logged in user is part of, then check that this contains 2 (my trade group id) and then show the ex tax price... if it does not contain 2, show then normal tax inc price.

Any help would be great

Thanks

Dan

Link to comment
Share on other sites

To check whether the customer is in the trade group, change lines 21-22 of init.php from:

// Init Cookie
$cookie = new Cookie('ps');



to:

// Init Cookie
$cookie = new Cookie('ps');

$customer = new Customer(intval($cookie->id_customer));
$trade = $customer->isMemberOfGroup(2);
$smarty->assign('trade', $trade);



This code will make a new variable $trade available to all your TPL files so you can use code like the following:

{if $trade}
  Do trade stuff
{else}
  Do retail stuff
{/if}

Link to comment
Share on other sites

At the bottom of init.php, you will find a list of most of the variables that are available to your templates. The if section are the variables when "v1.1 theme compatibility" is turned off and the else section are the variables when "v1.1 theme compatibility" is turned on.

Link to comment
Share on other sites

  • 2 weeks later...

so, a related question: is there a place (or places) that describes the programming model in general, the template engine, etc? Not expecting a "manual" but something to get started. I'm pretty programming and OO savy.

thanks,
Artyom

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

How do you do this in 1.4?

************

Solved it myself after reading a few more Rocky related posts.

1. Create a new Override file and save it locally into override/classes/
2. Name the new override file FrontController.php (just like the original)
3. In your override file, add this code to the file and save

<?php

class FrontController extends FrontControllerCore
{

paste the init function here

}
?>



4. In the new override file, you will need to copy/paste the entire init function from the original classes/FrontController.php.

Look to around line 71 for public function init() and copy down to around line 317 just under $this->setMedia();. Be sure to grab the last }

5. With the old init function pasted in the new override file, look for $cookie = new Cookie('ps');

6. Paste this code under $cookie = new Cookie('ps');

/* New code entered here - - - - - - - - - - - - - - - - - - - - - - */
       $customer = new Customer(intval($cookie->id_customer));
       $wholesaleGroup = $customer->isMemberOfGroup(2);
       $smarty->assign('wholesale', $wholesaleGroup);    
/* New code entered here - - - - - - - - - - - - - - - - - - - - - - */



7. FTP your new override file to override/classes/

8. On the tpl file where you want the information to show only for your group, use something like this

{if $wholesale}
getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockcms'}">{l s='Specials' mod='blockcms'}
       {/if}



The important parts being the {if $wholesale) and {/if}

It worked for me.

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...