我有一家WooCommercestore ,安装了ShipStation for WooCommerce插件.它们提供了一个简单的PHP函数来将与订单相关联的定制字段数据发送到ShipStation.以下是其中的一小段:
add_filter( 'woocommerce_shipstation_export_custom_field_2', 'shipstation_custom_field_2' );
function shipstation_custom_field_2() {
return '_meta_key'; // Replace this with the key of your custom field
}
只要您要设置的_meta_key
位于wp_postmeta
表中,这就非常有效.但是元密钥位于wp_woocommerce_order_itemmeta
表(the related meta key is 103)中.
有没有办法让上面的ShipStation函数在wp_woodcommerce_order_itemmeta
表中查找_wc_checkout_add_on_value
?
或者,作为一种解决办法,有没有办法返回固定的文本字符串而不是元键?我试了我能想到的所有方法,但就是不能奏效.似乎想要wp_postmeta
表中的元密钥,其他什么都不能做.
以下是我认为可能在这里起作用的逻辑:
- 判断
wp_woocommerce_order_itemmeta
中的特定值 每个订单的表格 - 如果找到该值,则为发送到ShipStation的"ShipStation_CUSTOM_FIELD_2"发送固定文本字符串.
我可以做第一部分.这是第二部分,向SS发送一个固定值,我似乎无法正常工作.也许这是不可能的与此功能.
任何 idea 或变通方法都是最受欢迎的.
add_filter( 'woocommerce_shipstation_export_custom_field_2', 'shipstation_custom_field_2' );
function shipstation_custom_field_2() {
//return '_meta_key'; // Replace this with the key of your custom field
//return 'test';
echo 'test';
}