woocommerce_order_itemmeta值为子订单为空

时间:2017-07-26 06:39:27

标签: wordpress woocommerce

在我的订单中,订单商品元表值为0.请检查屏幕截图。

1 个答案:

答案 0 :(得分:0)

该问题与Dokan插件有关。 Dokan将根据卖家自动创建子订单。

在wp-contents / plugins / [dokan] /includes/wc-functions.php

中添加了以下代码
    function dokan_get_order_item_meta_map() {
    return apply_filters( 'dokan_get_order_item_meta_keymap', array(
        'product_id'   => '_product_id',
        'variation_id' => '_variation_id',
        'quantity'     => '_qty',
        'tax_class'    => '_tax_class',
        'subtotal'     => '_line_subtotal',
        'subtotal_tax' => '_line_subtotal_tax',
        'total'        => '_line_total',
        'total_tax'    => '_line_tax',
        'taxes'        => '_line_tax_data'
    ) );
}

还修改了这个功能 function dokan_create_seller_order( $parent_order, $seller_id, $seller_products )

之后更改了部分  if ($itemid){

if ( $item_id ) {
                $item_meta_data = $item->get_data();
                $meta_key_map = dokan_get_order_item_meta_map();
                foreach ( $item->get_extra_data_keys() as $meta_key ) {
                    wc_add_order_item_meta( $item_id, $meta_key_map[$meta_key], $item_meta_data[$meta_key] );
                }

现在产品元数据将保存到对应的