How does WooCommerce get a user's country - wordpress

Ok so I know that to get the current user's location in WooCommerce you use
$woocommerce->customer->get_country( );
Woocommerce then returns the user's country as a 2 character user code i.e (GB,US,MX) My question is, where is WooCommerce getting this value? even when I am logged out it seems to get the correct location. Is this some kind of Geo coding or it uses a cookie or database to return a user inputed value?

It is using MaxMind API, class WC_Geolocation located inside includes folder.
The MaxMind GeoLite Database will be periodically downloaded to your wp-content directory if you check to use geolocation, there is option in settings.
You can find talk when they added it to WooCommerce here: https://github.com/woothemes/woocommerce/issues/6969

Never used WooCommerce before but in the past I have used GeoIP to get a users country and other information based on IP address. It's not always accurate though (country is likely to be accurate but city isn't)

Related

Booking system - WP

I need to do a reservation for 3 restaurants- in each there are 12 tables. Some of the reservations have to be paid before, the rest of them not at all.
Also, there is a need to identify if in the particular restaurant there is a reservation for different events- then the functionality of not-paid reservation must be switch off.
Ideally, if mails with reservations should be delivered to various email addresses - based on the name of the restaurant.
Everything must run on WP.
Can you please assist me with that?
For this system, I suggest you this solution.
I should say that using this answer requires average knowledge of PHP and WordPress functions.
Create a custom post type for Restaurants.
Information such as not-paid reservation, paid reservation, and events can be saved as meta values.
To save meta values for your custom post type, you can use the "advanced custom fields" plugin or just code them using add_meta_box().
For the reservations, you should make a form and in the form, users can select their reservation table, date, and time.
if the reservation requires payment, you should check the gateway documentation and use their script.
here you need to create a table in the database for payments.
after the form submits and before payment, add your user info to the database and give the payment status "pending" value.
after the successful or unsuccessful payment, the gateway will return the payment status and with that, you can save the reservation status.
For sending an email to the restaurant manager, after the successful payment, use wp_mail().
I tried to explain the whole project to you in 12 lines so, after reading this answer you may get confused.
If you have more questions, just ask.

Is it possible to retrieve posts from LinkedIn's API?

I would like to use LinkedIn's v2 API to monitor as many public-facing profiles as possible, and retrieve content from the posts made by those profiles. Then identify instances where LinkedIn users are linking to particular domains. I can't tell if this is possible through the Partner Program. Signs are pointing to using this https://learn.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api but it isn't super clear to me whether this particular use case is supported.
Yes. As long as they are authenticated member. I think this applied to Partner Program too. You need permission from owners to fetch their contents.
http:
GET https://api.linkedin.com/v2/shares?q=owners&owners={URN}&sharesPerOwner=100
The following authorization rules apply when specifying owners :
For personal shares, you may only retrieve shares for the authorized members.
Source: Find Shares by Owner

How to count Unique Website Visitor by Laravel 5.7?

Recently I'm developing a Restaurant Website Dashboard. They want to track the total unique number of visitors to their website. Now how can I solve this problem...? Can anyone please describe how to count the Visitor Number through Laravel...?
One way would be to fetch the user's ip address and then through ajax update the database and add one record in the database with that ip, then for any other updates to that table, you will first check if that particular ip already exists in the table and if it does, you wouldn't insert a new row. This could be a problem with people with dynamic url, but this should be an easy and quick implementation and it's not Laravel specific, so you could do it on every page load you fetch the ip, send it to your backend, save it and you are done

Add user on UrBackup server after order on Woocommerce site

I have wordpress site with woocommerce shop and I’m selling among others UrBackup client accounts on my server.
Do you have any idea how to automatically add UrBackup user after order in woocommerce?
Or maybe easier will be create shop based on different engine?
Any advice, tips? :)
After poking around a bit, it looks like UrBackup has an API you can use, that most likely has a 'create account' endpoint. I didn't see it immediately in their not-so-great documentation, but you'd think it'd HAVE to be there somewhere! There's also a PHP API kit you could integrate into your WordPress site here:
https://bitbucket.org/opensaucesystemsdevelopment/urbackup-api.git
So, you could load in this class, and after a WooCommerce order is placed, call the API endpoint to create a user. To do this with WooCommerce, you'd need to create a function on the "woocommerce_order_status_completed" hook.
http://hookr.io/actions/woocommerce_order_status_completed/
This would let you run any custom code you'd like after an order's payment has completed. Thus, you could check an order for if it contains the UrBackup product, and if so call the UrBackup API to create an account based on the current user's data.
Should work!

SagePay - How do you pass company name field to sagepay form?

we have recently moved over to a new website using woocommerce. We are trying to find out how to pass the company name to sage pay so when we import it into sage 50 accounts it finds the correct company to match the account to.
Currently it is creating a new company using the first and last name of the person as there is no where (it appears) for sagepay to allow this info.
How do we do this please?
The email address is used as the identifier at the moment, so if your Sage 50 records have the correct email address, and this is supplied with the transaction registration, it should match up.

Resources