The Prices by Country plugin stores product prices in post meta table. They can be manipulated by using the standard update_post_meta() and get_post_meta() functions. For the data to be used correctly, it's important that the country specific prices are associated to the correct region. Below you can find the instructions to determine the ID of each region, and how to assign it to prices.
1. Create the appropriate regions
Before prices can be imported, you must create one or more regions. To do so, go to WooCommerce > Prices by Country and create the regions you need.
2. Retrieve the ID of each region
Region IDs are alphanumeric values generated automatically and stored with the Prices by Country plugin's settings. You can retrieve the option IDs in two ways:
If you are running the Prices by Country plugin 22.214.171.124223 and later, you can find this information in the plugin's settings page. See screenshot, below.
If you are running an earlier version of the plugin, you can either update the plugin, or retrieve the region IDs from the options table. You can use the following query to get the plugin options:
select option_value -- Make sure that you change the "wp_" prefix as appropriate from wp_options where option_name = 'wc_aelia_prices_by_country'
Field option_value will contain the plugin settings, which include a section with a list of regions and their IDs.
3. Import product availability for each region
Product prices are stored in a product's meta, which can be found in the postmeta table. The data is saved as a serialised PHP array, with the meta key _prices_by_country. Here's an example of the data, unserialised:
array ( // The numeric key is a region ID // In this example, ID 7c337ba8befab52b27856bb048e91d8b is Europe. A value // of "no" means that the product is "not unavailable" (i.e. it is AVAILABLE) // for that region '7c337ba8befab52b27856bb048e91d8b' => 'no', // ID 72cffd5442ca6c49f5550fb04b7cc2b1 is North America. A value of "yes" means // that "unavailable" for that region '72cffd5442ca6c49f5550fb04b7cc2b1' => 'yes' )
Once serialised, the data will look be stored follows:
How to serialise the data in the correct format
Depending on which tool you use to store the data, the serialisation may be automatic. This is the case with several CSV Import plugins. Such plugins can accept a JSON string in the CSV file to import, and they will transform it into the correct format automatically. Here is the above data in JSON format, ready to be imported.
If you use another tool that doesn't perform serialisation automatically, or you would like to write your own custom import, you can serialise the data by calling the serialize() function provided by PHP.
4. Review the imported availability options
After you ran the import process, go to the Edit Product page for one of the imported products. If the import was successful, you should see the new availability in the "Prices by Country" section (see below).