Populating Order Analysis fields directly.

Populating Order Analysis fields directly.

In Settings>Orders any order meta data item can be mapped to one of the 3 Sage order Analysis fields, by providing the meta key name. However, if you have custom fields that are not included in the order meta, then we have a filter for developers to use to directly populate the Analysis fields.

Add the following code to the website's functions.php (this example inserts the shipping method into Analysis 2)

add_filter('woosage_get_analysis_field', 'woosage_get_analysis_field', 10, 4);

function woosage_get_analysis_field($value, $order, $field_number, $meta_key) {

     // Return the shipping method title for analysis field 2
     if ($field_number === 2) {
          $value = $order->get_shipping_method();
     }

     return $value;

}

Replace the value of the field_number (2) with the Analysis field you wish to populate (1, 2 or 3) and set the value of $value to retrieve the data item you want to populate the Analysis field with using the relevant function.

    • Related Articles

    • Adding WooCommerce Custom Fields From the Woosage Plugin

      Custom fields in WooCommerce orders, which are usually created by your developer (e.g. PO Number), can be passed through to Sage Custom Fields Analysis1, 2 or 3. In the website backend scroll to Woosage Settings and use the drop-downs to select the ...
    • Using Custom Fields

      You can add data from Custom Fields in website orders to the Custom Fields section of the Order tab of a Product Sales Order in Sage. Note: this can now be done via the Woosage Plugin - See Adding WooCommerce Custom Fields From the Woosage Plugin ...
    • Order Classifications

      Woosage50 provides a range of setting to allow you to override your default nominal and department code settings in Sage when Woosage is processing orders. If you do not want to override the Sage defaults for nominal codes or department codes, then ...
    • Order Information Posted to Sage

      Woosage posts information from the WooCommerce Orders into Sage Sales Orders or Invoices in the following sections (as per Sage Order tabs): Details Billing address details are posted unless the billing address override is off, using the settings ...
    • Last Order & Other Product Meta Data

      When Woosage50 updates website product data from Sage there are options to include Sage product data items that are not readily available in WooCommerce (e.g. barcode), so Woosage creates and populates custom fields with this data when these options ...