Export product fields to custom fields and taxonomies

Write affiliate-toolkit product data such as the lowest price or brand into custom fields, ACF fields, taxonomies or WooCommerce attributes.

affiliate-toolkit keeps its product data in its own database table, not in WordPress custom fields. That keeps the plugin fast, but filter plugins, page builders or WooCommerce cannot see the data. The Product Field Export module closes this gap: it copies selected fields – for example the lowest price, the cheapest shop or the brand – into custom fields, ACF fields, taxonomies or WooCommerce attributes, and keeps them up to date.

Prerequisites: affiliate-toolkit with the Product Field Export module (included in the passes). For ACF targets you need Advanced Custom Fields, for WooCommerce targets the WooCommerce Connector.

Tools → Field export: mappings that write product data (lowest price, cheapest shop, brand, rating) into custom fields or taxonomies of posts, products or WooCommerce.
Tools → Field export with mappings for price, shop, brand and rating.

Create a field mapping

Open affiliate-toolkit → Tools → Field export. Each mapping copies one field:

  1. AT field – the affiliate-toolkit field to export. All system fields are available, plus your custom fields and taxonomies and the shop name.
  2. Field format – how the value is written (see below).
  3. Function – from which offer the value is taken: main product (the first offer of the product), min price (the cheapest offer) or max price (the most expensive offer).
  4. Target field – where the value goes (see table below).
  5. Click Add new field mapping and enter the Target name: the meta key, the ACF field name, the attribute name or the taxonomy name.
  6. Save the settings.

The values are written every time a product is updated – by the cronjob or when you save the product. To fill the fields for existing products, update them once.

Field formats

  • value – the raw value without formatting, e.g. 199.9 for a price. Best for sorting and filtering.
  • formatted value – the formatted value as shown in product boxes, e.g. 199,90 €. Only available for price fields (sale price, list price, amount saved, unit price, base price, shipping).
  • formatted by WP hook – you format the value yourself with a filter. The filter name is atkp_fieldexport_format_ followed by the target name of the mapping.
// Target name of the mapping: lowest_price
add_filter( 'atkp_fieldexport_format_lowest_price', 'my_atkp_format_lowest_price', 10, 2 );

function my_atkp_format_lowest_price( $value, $product_id ) {
    // $value: the raw value of the affiliate-toolkit field
    // $product_id: ID of the affiliate-toolkit product
    return number_format( (float) $value, 0, ',', '.' ) . ' EUR';
}
ParameterTypeDescription
$valuemixedThe raw value of the selected affiliate-toolkit field.
$product_idintID of the affiliate-toolkit product being updated.
Return valuemixedThe value that is written to the target field.

Target fields

Target fieldWhere the value is written
Custom field (product)Post meta of the affiliate-toolkit product.
Custom field (main product)Post meta of every post that uses this product as its main product.
Custom field (woocommerce)Post meta of the linked WooCommerce product.
ACF field (product)Advanced Custom Fields field of the affiliate-toolkit product.
ACF field (main product)ACF field of every post that uses the product as its main product.
ACF field (woocommerce)ACF field of the linked WooCommerce product.
Custom Attribute (woocommerce)A product attribute of the WooCommerce product (e.g. for layered navigation).
Taxonomy Attribute (woocommerce)A taxonomy-based attribute (pa_…) of the WooCommerce product.
Taxonomy (product)A term of a taxonomy of the affiliate-toolkit product.
Taxonomy (main product)A term of a taxonomy of every post that uses the product as its main product.
Taxonomy (woocommerce)A term of a taxonomy of the WooCommerce product.

The WooCommerce targets only apply to products that are linked to a WooCommerce product. Taxonomy targets create the term if it does not exist yet; comma-separated values are created as a hierarchy (parent, child, …).