首页 > 解决方案 > Woocommerce - 在 Shipstation 中将自定义数据作为行项目发送

问题描述

我有以下代码将自定义详细信息添加为 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'] );
    }
}

以下是我尝试将自定义数据添加到 Shipstations 自定义字段但失败:

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
}

自定义详细信息当前已记录并添加到我的 WooCommerce 管理员订单页面中。但是这些自定义细节在 Shipstation 中不可见。我正在考虑将自定义数据作为新行项目发送,而不是发送到 Shipstation 中的自定义字段。这是你可以帮助我的事情吗?

标签: phpajaxwordpresswoocommerce

解决方案


推荐阅读