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 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 prices 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:   

  // The numeric key is a region ID
  '7c337ba8befab52b27856bb048e91d8b' => array
      // The entry contains one set of prices for each currency. If your shop
      // only uses one currency, you will only have one set of prices
      'CAD' => array
          'sale_price' => '1.23',
          'regular_price' => '4.56',
          // The subscription_signup_fee is only applicable for subscription
          // products. If not needed, it can be omitted, or left empty (see
          // below)
          'subscription_signup_fee' => '7.89',
      // Prices for additional currencies
      'EUR' => array
          'sale_price' => '2.34',
          'regular_price' => '3.45',
          // To leave a product empty, set it as an empty string. Don't set it
          // as zero, as that is a valid price and it will be used for the product
          'subscription_signup_fee' => '',

 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 prices

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 prices in the "Prices by Country" section (see below).

You can purchase the Prices by Country plugin from our online shop.