Using Custom Fields

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

This would normally be done programmatically by your web developer, but any data can be added to a WooCommerce Order Custom Field called either analysis1, analysis2 or analysis3 as shown below.



These fields are to the imported to the Sales Order, Order tab Custom Fields in Sage as shown below.




Developer Note: There are several custom field plugins and it can be done with code, but which ever method is used  it is essential that the field is inserted as Order Meta.  The will appear in as a key/value pair in the Order JSON delivered by the REST API as:

{

“id”: 12345,
“key”: “analysis1”,
“value”: “PO Number: ABC123”
}
Where “id” is the postmeta id, “key” is the Analysis field that the value is to be inserted in to (analysis1, analysis2 or analysis3) and “value” is whatever text you want to place in the field (up to a maximum of 30 characters).
Woosage then picks up keys containing any of the analysis field labels and in puts the corresponding value in the relevant analysis field in the Sage order.

The following is example code that will add the the title of the payment method used with the order (e.g. Cash on Delivery) to the Sage order/invoice field custom field Analysis 1.

add_action( 'woocommerce_checkout_order_processed', 'woosage_add_analysis1_field',  10, 1 );

function woosage_add_analysis1_field( $order_id ) {
    $custom_field = get_post_meta( $order_id, '_payment_method_title', true );
    update_post_meta( $order_id, 'analysis1', $custom_field);  
}


This facility may not work if your Sage installation has changed the customer field names from the default Analysis 1, 2 and 3.
In addition it will only work for order created in the usual way (via the front end) and will not work for orders manually via the CMS.





    • Related Articles

    • 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 ...
    • 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 the ODBC Capability

      There is now a facility to create the ODBC DSN from the Utilities tab of the Woosage Control Centre, so the information below this blue box is mainly for troubleshooting or making changes to the ODBC DSN directly. To create or update the ODBC DSN use ...
    • Adding New Price List Customers (when using Elex Plugin)

      Introduction Woosage supports the application of Customer and Special Price Lists to customer roles in WooCommerce. Each Customer Price List is mapped to a website role that will apply the relevant prices to customers using a 3rd party Role Based ...
    • 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 ...