SametALMDR Posted June 25, 2020 Share Posted June 25, 2020 Hello everyone , I've got a question about a hook.I am trying to access the active currency (selected currency by the user) on the OrderProductPricingOverride hook. But ı could not access that variable in any way. How can access the currency which is selected by the user on the OrderProductPricingOverride hook ? Can anybody help me ? @brian! 🙂 0 Quote Link to comment Share on other sites More sharing options...
weelow Posted July 27, 2020 Share Posted July 27, 2020 Did you try choosing the hook point you want and type in it var_dump($vars); This will print all the variables available for use, then when you open that page. Use the find option of your browser and search for currency to see what you are getting. You can then use this variable in your hook. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 28, 2020 Share Posted July 28, 2020 (edited) On 25/06/2020 at 20:33, SametALMDR said: I've got a question about a hook.I am trying to access the active currency (selected currency by the user) on the OrderProductPricingOverride hook. But ı could not access that variable in any way. I thought that I had answered this thread - the backlog is far worse than I thought! 😲 On 25/06/2020 at 20:33, SametALMDR said: How can access the currency which is selected by the user on the OrderProductPricingOverride hook ? I think you would need to make upto three checks to get the users currency... if they're logged in as a client, then you can get it via $client context (remembering that clients cannot change currency). if they're not logged in and they have chosen a currency, then you can pull the value from the session array. if they're not logged in and they haven't changes currencies, then the currency value won't be set in the session and you'll have to assume they're using your default currency. untested, but it would be along the lines of.. $client = Menu::context('client'); if ($client) { $currency = $client->currency; } elseif (!empty($_SESSION['currency'])) { currency = $_SESSION['currency']; } else { $currency = 1; } i'm cheating on the third step and assuming that you will know what your default currency is and can just hardcode its id value in the hook - but you could easily use capsule (declare its use first) to pull the id from the tblcurrencies database table for the default currency. currency = Capsule::table('tblcurrencies')->where('default','1')->value('id'); then once you have your currency value, you can use it in your override hook if statements to determine what to charge per product, per currency. 15 hours ago, weelow said: This will print all the variables available for use, then when you open that page. I doubt it would print the session array. Edited July 28, 2020 by brian! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.