- Create custom fields through WPCargo Manage Form Fields
- Copy and paste the following code in the functions.php of your current theme.
Note: Make sure to use the same metakeys for your woocommerce fields and wpcargo fields
//saving
add_action('wpcwi_after_shipment_order_save', 'additional_sunc_data', 99, 2 );
add_action('wpcwoo_integration_after_shipment_save', 'additional_sunc_data', 99, 2 );
function additional_sunc_data( $shipmentID, $order_id ){
//Note: This kb is a sample used in saving the custom kg and date to courier call field. Please change the metakey depending on the metakey you have used.
// $order = wc_get_order( $order_id );
// $order_data = $order->get_data();
// $meta_data = $order_data['meta_data'];
$kilogram = get_post_meta( $order_id, '_billing_kg', true );
$dateTime = get_post_meta( $order_id, 'wpcargo_pickup_date_picker', true );
//update shiment data
update_post_meta( $shipmentID, 'wpcargo_pickup_date_picker', $dateTime);
update_post_meta( $shipmentID, 'billing_kg', $kilogram);
}