【问题标题】:After Order Details Hook[Woocommerce]订单详情挂钩后[Woocommerce]
【发布时间】:2017-06-10 12:54:25
【问题描述】:

https://postimg.org/image/xgyc0hgxz/

好的,所以我想创建一个额外的字段(列),其中图片有黑色方块,但首先我不知道钩子是什么。搜索后我找到了钩子

woocommerce_admin_order_data_after_order_details

但是这个钩子超出了我想要的,如图所示..Add order metadata to WooCommerce admin order overview

我还想要显示每个对象的运输类,如果我可以访问那里的循环,我想我可以通过全局 $product 访问,但我只是不知道钩子或我想如何添加此列.有什么想法吗?

【问题讨论】:

    标签: wordpress woocommerce hook admin orders


    【解决方案1】:

    好的,我找到了解决方案,并将其发布在此处,供其他搜索此问题的人使用。

    add_action('woocommerce_before_order_itemmeta','woocommerce_before_order_itemmeta',10,3);
    function woocommerce_before_order_itemmeta($item_id, $item, $product){
        $shippingclass = $product->get_shipping_class();
    
        echo ($shippingclass) ? __('<hr><b>Shipping with: </b> <i style = "text-transform:uppercase">'. $shippingclass .'</i><hr>','woocommerce') : 'No Shipping Class is assigned to this product';
        echo '<p><b>Category:</b>  <i>'.get_the_term_list($product->id, 'product_cat').'</i></p>';
    }
    

    【讨论】:

      猜你喜欢
      • 2021-04-21
      • 2020-08-17
      • 2018-05-26
      • 2017-09-17
      • 2018-05-12
      • 1970-01-01
      • 1970-01-01
      • 2021-02-02
      • 1970-01-01
      相关资源
      最近更新 更多