sgtbash Posted May 4, 2010 Share Posted May 4, 2010 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 greatThanksDan Link to comment Share on other sites More sharing options...
rocky Posted May 5, 2010 Share Posted May 5, 2010 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 More sharing options...
sgtbash Posted May 5, 2010 Author Share Posted May 5, 2010 Rocky... Your a legend!Thanks...Is there a place (other than the non existent PS manual...) that I can find all the current variables available to pull from?Dan Link to comment Share on other sites More sharing options...
rocky Posted May 5, 2010 Share Posted May 5, 2010 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 More sharing options...
artyom Posted May 19, 2010 Share Posted May 19, 2010 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 More sharing options...
rocky Posted May 19, 2010 Share Posted May 19, 2010 No, there is no PrestaShop architecture manual, though there is a Smarty manual. PrestaShop uses the standard Model-View-Controller for its architecture, so it isn't very hard to figure out. Link to comment Share on other sites More sharing options...
artyom Posted May 19, 2010 Share Posted May 19, 2010 thanks for link to Smarty. :- )When you say "standard", where are is the "model" and "controller" classes generally, etc? ie, where in the folder structure? Link to comment Share on other sites More sharing options...
rocky Posted May 19, 2010 Share Posted May 19, 2010 The models are in the classes directory, the controllers are in the root directory, and the views are in the themes directory. Link to comment Share on other sites More sharing options...
artyom Posted May 19, 2010 Share Posted May 19, 2010 great thanks. that's a start : - ) Link to comment Share on other sites More sharing options...
MEG Venture Posted June 27, 2010 Share Posted June 27, 2010 Rocky,You are beyond great. Now I can use my PS store as a B2B service. I really appreciate. Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 I'm glad you figured it out. Could you please write a topic about how you did it? I've seen many people asking for it. Link to comment Share on other sites More sharing options...
MEG Venture Posted June 27, 2010 Share Posted June 27, 2010 Sure I will. Let me create the topic and link here, too.Update:Here is the link:Custom B2B Solutions Link to comment Share on other sites More sharing options...
melriks Posted July 4, 2011 Share Posted July 4, 2011 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 More sharing options...
robinos Posted November 17, 2011 Share Posted November 17, 2011 Thanks!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now