I’m having trouble deleting Meta Data when uploading to WooCommerce?

If you have Meta Data associated with a WooCommerce record, such as a Customer, Product or Order and you wish to delete this from WooCommerce you must clear out the values for the Meta Data and upload that to WooCommerce and pass a null value specifying JSONNull for the type parameter in the JSONSetElement function.

You cannot delete the Meta Data records in fmEcommerce Link and upload that to WooCommerce as it will not delete the Meta Data that exists; furthermore you cannot delete all existing Meta Data by simply uploading an empty array like this:

"meta_data" : [],

Just make sure you delete the contents of the Value field in FileMaker – make sure you leave the WooCommerce Meta Data ID – and it will clear these from WooCommerce on your next upload. Here's an example of how to pass a null value to delete an existing WooCommerce Meta Data record:

Let([

~json = JSONSetElement ( "" ; 

["id"; ProductMetaData::_kf_WooCommerceID; JSONNumber ];
["key"; ProductMetaData::Key; JSONString ];
["value"; ProductMetaData::Value; JSONNull ] )
];

JSONSetElement( $meta_data ; $counter ; ~json ; JSONObject )
)

fmEcommerce Link (WooCommerce Edition) v2.1 was updated to include examples for deleting existing Meta Data in WooCommerce using the above syntax.

Still need help? Contact Us Contact Us