Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1032 มุมมอง

Hello all,


I need to hide elements on my website based on someone's location/IP address. 

For example our company has two phone numbers, and I need to only show a certain phone number for people in certain provinces in Canada. 


How do I conditional show an element based on IP address or hide elements based on IP address?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

here some guidance that you can try. 

Install a Geolocation Tool:

  • Use a geolocation library (such as geoip2) to map IP addresses to geographic locations. Alternatively, consider using a third-party API like ipstack or ipinfo for this purpose.

Create a Custom Odoo Module:

  • Develop a custom Odoo module that detects a user’s location based on their IP address. This module should make the location data accessible to your website templates.

Modify Website Templates:

  • Use the location data in your website templates to conditionally show or hide elements. For instance, display specific phone numbers or content based on the user's detected province or region.
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 25
949
1
ก.ย. 24
1116
2
ก.ย. 24
1984
0
พ.ย. 24
2377
1
พ.ค. 24
3501