cyanoxide Posted November 28, 2016 Share Posted November 28, 2016 (edited) I have a feeling this will be quite a simple one but I need to pull the the delivery address to a theme file (more specifically the country or country id) and I'm not sure how to go about doing that. I found this topic that explains it in some detail but I'm not sure where exactly in the cart file the code needs to be added: https://www.prestashop.com/forums/topic/372465-get-id-country-value-from-cart-id-address-delivery/ And I also found a thread where someone wanted to add it into the payment hook: https://www.prestashop.com/forums/topic/243717-get-shipping-address-in-payment-module/ Any help on this will be greatly appreciated. If you'd like some context on why I need this, I'm using a cloudflare CDN and because of the nature of CDNs it is interfering with the way prestashop handles geolocation, it doesn't seem to stop the right currency from being displayed however it does effect the right tax rule from being applied to that country. I've managed to resolve this for the most cases as Cloudflare passes on the location information in the http header which can be called in smarty with {$smarty.server.HTTP_CF_IPCOUNTRY}. With this I can correct the tax however if for example they are in the US but set their delivery address to be in the UK prestashop would normally update the taxes on the site to reflect the new country however my solution does not do this so I need to add an extra if statement that checks for a delivery country before displaying prices. Edited November 28, 2016 by cyanoxide (see edit history) Link to comment Share on other sites More sharing options...
cyanoxide Posted November 28, 2016 Author Share Posted November 28, 2016 (edited) This is the code I'm using in product_list.tpl for the time being, as of right now I'm just doing this in the US as this is where the issue was first noticed but once it's finished I'll be expanding this to all countries outside of the EU. {if {$smarty.server.HTTP_CF_IPCOUNTRY} } {if {$smarty.server.HTTP_CF_IPCOUNTRY} == 'US' } {convertPrice price=$product.price_tax_exc} {else} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} {/if} {else} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} {/if} Edited November 28, 2016 by cyanoxide (see edit history) Link to comment Share on other sites More sharing options...
IcyApril Posted November 28, 2016 Share Posted November 28, 2016 It is possible for Cloudflare to transparently handle IP Address rewriting using their Apache extension called Mod_Cloudflare. Because Cloudflare acts as a proxy, you will notice changes to the way that your website visitors' IP addresses are displayed both in your server logs and web applications - notably that all access appears to be coming from Cloudflare IP addresses. You can read more about the reasons for this in our knowledge base article. You can change this behavior and log & display the actual visitor IP addresses by using mod_cloudflare. Link to comment Share on other sites More sharing options...
GoPure Kratom Posted October 1, 2022 Share Posted October 1, 2022 Hi! This is an interesting (although old) thread for my purposes. I have been battling on how to "suggest" the correct shop for my customers in US and in Europe. There are separate instances running for both of these regions. There are few Geo location modules which can suggest the correct shop and/or redirect the user. However, there's a couple of issues with these: They seem to use the Presta's MaxMind or other commercial or freeware databases They work "high on up the chain", meaning that the whole shop page is usually loaded before redirect etc (=slow) I realized that both Cloudways and Cloudfare send the country information in the headers and according to documentations, they are more accurate than the Prestashop "native" way to get that information. I am looking for a solution that redirects the user as early on as possible, to prevent any delays or loading content from the wrong shop. It was a gold nugget to find out what smarty variable holds the information. Now asking where is the most optimal place to put the code to handle the check and redirect? 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