- Create a custom fields to handle your custom woocommerce field in Site B ( WPCargo Website ).
- Copy and paste the following code into the functions.php of your current theme.
//Woo API
function api_additonal_data( $shipment_data, $order_id, $shipment_number ){
//Note: Please use the meta key you have set in the custom fields addon
$shipment_data['_wpcwp2p_order_data'] = array(
'_date_created' => wc_format_datetime( $order->get_date_created(), get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ),
'_payment_method' => $order->get_payment_method_title(),
'_payment_subtotal' => $order->get_subtotal_to_display(),
'_payment_total' => $order->get_formatted_order_total(),
'_total_tax' => wc_price( $order->get_total_tax(), array( 'currency' => $order->get_currency() ) ),
'_total_discount' => wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ),
'_shipping_tax' => wc_price( $order->get_shipping_tax(), array( 'currency' => $order->get_currency() ) ),
'_shipping_total' => wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ),
'_payment_items_fee' => $items_fee,
'_total_fees' => wc_price( $order->get_total_fees(), array( 'currency' => $order->get_currency() ) ),
'billing_kg' => get_post_meta( $order_id, '_billing_kg', true );
);
return $shipment_data;
}
add_filter( 'wpcwp2p_after_order_completed', 'api_additonal_data', 99, 3 );