添加产品属性订单项元-Woocommerce

时间:2019-10-17 13:35:59

标签: php wordpress woocommerce

尝试获取产品属性名称/值并将其保存为order_item_meta。

我设法编写了下面的代码,当我将产品属性直接保存在admin的“编辑产品视图”中时,该代码可以工作。但是,当我保存属性并在Products-> Attributes中为其设置术语时,代码停止工作。

有人知道为什么吗?我猜现在这些术语保存在另一个表中,但是我不知道在哪里或如何获得。

//Add product delivery time to order details admin view
add_action( 'woocommerce_new_order_item', 'custom_add_pa_delivery', 10, 3 );
    function custom_add_pa_delivery( $item_id, $values, $cart_item_key ) {

     $deliveryt = get_post_meta( $values[ 'product_id' ], '_product_attributes', true );
     wc_add_order_item_meta( $item_id, 'Deliv', $deliveryt['deliverytime']['value'] , false );

}

0 个答案:

没有答案
相关问题