I have below code to add Custom Details as Order Line Items in WooCommerce
add_action( 'woocommerce_checkout_create_order_line_item', 'wdm_add_custom_order_line_item_meta', 10, 4 );
function wdm_add_custom_order_line_item_meta( $item, $cart_item_key, $values, $order ) {
if( array_key_exists( 'wdm_name', $values ) ) {
$item->add_meta_data( '_wdm_name', $values['wdm_name'] );
}
}
Below was my attempt to add the custom data to Shipstations Custom Field but failed:
add_filter( 'woocommerce_shipstation_export_custom_field_2', '__return_true' );
add_filter( 'woocommerce_shipstation_export_custom_field_2_value', 'woo_shipstation_custom_field_2_value', 10, 2 );
function woo_shipstation_custom_field_2_value() {
return '_wdm_name'; // Replace this with the key of your custom field
}
The custom details are currently recorded and added in my WooCommerce Admin Order Page. But these Custom details are not visible in Shipstation. I'm thinking to just Send Custom Data as a new Line Item and not to a custom field in Shipstation. Is this something that you can assist me?