最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

woocommerce offtopic - Modifying custom order item meta from admin order view

programmeradmin2浏览0评论

I'd like to have a simple custom meta for order items that says if the item has been fulfilled or not.

I have this in my functions.php:

add_action( 'woocommerce_admin_order_item_values', 'pd_admin_order_item_values', 10, 3 );
function pd_admin_order_item_values( $product, $item, $item_id ) {
    //Get what you need from $product, $item or $item_id
    echo '<td class="fulfilled">';
    $fulfilled = wc_get_order_item_meta($item_id, '_fulfilled', true);
    if ($fulfilled) {
        echo '<p><strong>Fulfilled:</strong> <span style="color:#00FF00;">Yes</span></p>';
    } else {
        echo '<p><strong>Fulfilled:</strong> <span style="color:#FF0000;">No</span></p>';
    }
    echo'</td>';
}

Is there an easy way to update the meta value just by clicking the Yes/No?

Like, click the green Yes and it updates to a red No and viceversa.

Will I have to create a custom WC API endpoint?

发布评论

评论列表(0)

  1. 暂无评论