Customize data fields

Customize data fields

Note that this is an addon plugin to Kroconnect. Kroconnect needs to be installed and activated for Kodmyran Commerce to work.

With the Kodmyran Commerce integration it’s possible to customize what data is sent where in Kodmyran Commerce and WooCommerce. This is done through a number of configuration files that are editable by you as the merchant/developer. You can find these settings by going to WooCommerce -> Kroconnect -> Kodmyran -> Custom field map.

This feature allows the store to map data fields added by third party plugins that adds extra information to a product or an order (that is not WooCommerce standard). This could easily be added by adding an extra line to the one of the configuration files and saving it. A good way to find out what the different fields are in WooCommerce is by using a plugin like Show hidden post meta.


Configurable files


  • kodmyran.json
    Base configuration file for the Kodmyran Commerce integration.
    "units": "major" means that prices are defined with major units. Example 10 SEK is 10.
    "vat": "100" means that the vat percentage is specified up to 100. Example 6, 12 and 25(%) vat.
  • kodmyran-order.json
    How new orders in WooCommerce are sent to Kodmyran.
  • kodmyran-customer.json
    How customer data is sent in new orders to Kodmyran.
  • kodmyran-order-item.json
    How each order row in new orders are sent to Kodmyran.
  • kodmyran-product.json
    How product data is mapped in both directions (Kodmyran to WooCommerce and WooCommerce to Kodmyran) when updating a product.

Structure of the JSON files


The configuration files use the JSON format to dictate what data goes where, when the plugin receives data from Kodmyran or when data is sent from WooCommerce to Kodmyran. You can read more about the JSON format here: https://www.json.org/json-en.html

In these files you will see data looking like this (for example our default file for order items).

{
	"sku": "sku",
	"name": "name",
	"amount": "quantity",
	"vatrate": "vatrate",
	"price": "unit_price"
}

The basic format here is:

{
	"key": "value"
}

The key is the name of the data field in Kodmyran and the value is the name of the data field in WooCommerce


Logic of the data field names specified


Kodmyran

The key side, or the left side, is how the fields are named in Kodmyran Commerce. All fields that can be defined in the communication can be viewed here:

WooCommerce

The value side, or the right side, is how the fields are named in WooCommerce. The Kroconnect plugin tries to map the fields in the following order:

With the example field name weight.

  1. Test if a helper function with the given name exist. Example: $product->get_weight().
  2. Test if a meta data name with a beginning underscores exist. Example _weight.
  3. Test if a meta data name with the exact spelling exist. Example weight.

Where are customized configuration files saved?


Note that the changes you do does not overwrite the default configuration file. Editing and saving a file will create a new separate file in your WordPress installations uploads folder. You can always restore back to default by simply removing those extra files.

The customized files are not displayed by default in the media library. You might need to delete them via (S)FTP to remove them.