【发布时间】:2019-04-09 09:09:44
【问题描述】:
我正在尝试将结帐中的自定义字段导出到 ShipStation 中的自定义字段 2,但数据没有被拉入自定义字段 2。我可能在代码中使用了错误的元数据吗?
我已经从船站站点复制了我应该添加到我的functions.php中的片段
// Add this code to your theme functions.php file or a custom plugin
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
}
// This is for custom field 3
add_filter( 'woocommerce_shipstation_export_custom_field_3', 'shipstation_custom_field_3' );
function shipstation_custom_field_3() {
return '_meta_key_2'; // Replace this with the key of your custom field
}
对于我正在开发的网站,我在结帐时有一个自定义结帐字段,用于显示缺货选项。我已将“_meta_key_2”替换为客户缺货选项“outofstockoption”的元数据
function my_custom_checkout_field_update_order_meta( $order_id ) {
if ( ! empty( $_POST['outofstockoption'] ) ) {
update_post_meta( $order_id, 'Out of Stock Option', sanitize_text_field( $_POST['outofstockoption'] ) );
}
}
// Add this code to your theme functions.php file or a custom plugin
add_filter( 'woocommerce_shipstation_export_custom_field_2', 'shipstation_custom_field_2' );
function shipstation_custom_field_2() {
return 'outofstockoption'; // Replace this with the key of your custom field
}
我希望有人可以指导我如何让 ShipStation 拉出“缺货选项”并将其放入 ShipStation 自定义字段。提前致谢。
【问题讨论】:
标签: php wordpress woocommerce