久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表

Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
本文介紹了在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

是否可以在 Woocommerce 管理產(chǎn)品列表中添加交貨時間"列?

Is it possible to add a column "delivery time" to the Woocommerce admin product list?

我知道在屏幕選項"中有一些額外的列(拇指、價格、product_cat 等)可供選擇,但交貨時間"不可用.

I know there are some additional columns (thumb, price, product_cat etc) to choose at "Screen Options" but "delivery time" is not available.

是否可以以某種方式將其添加到列表中?

Is it possible somehow to add it to the list?

我嘗試按照 LoicTheAztecs 的回答進行操作,但在找到正確的 meta_key slug 時遇到問題.

I tried to follow LoicTheAztecs answer, but I'm having problems to find the correct meta_key slug.

如果我在 wp_postmeta 中搜索delivery",我會得到 0 個結(jié)果.

If i search for "delivery" in wp_postmeta I'm getting 0 results.

但是有些產(chǎn)品指定了交貨時間.在我的產(chǎn)品頁面上有一個文本字段Lieferzeit: 1–2 Wochen"(表示交貨時間:1–2 周).如果我在整個數(shù)據(jù)庫中搜索Wochen",我會在 wp_options 中獲得 2 次點擊,在 wp_terms 中獲得 6 次點擊.

But there are products with delivery time assigned. On my product page there's a text field "Lieferzeit: 1–2 Wochen" (means Delivery time: 1–2 weeks). If I search the whole database for "Wochen" I'm getting 2 hits in wp_options und 6 hits in wp_terms.

數(shù)據(jù)庫一般搜索:

wp_terms 數(shù)據(jù)庫中的點擊次數(shù):

Hits in wp_terms DB:

你知道如何從這里找到正確的 meta_key slug 嗎?

Do you know how to find the correct meta_key slug from here?

推薦答案

這里是將 2 個自定義函數(shù)掛鉤的方法.第一個用標(biāo)題創(chuàng)建列,第二個用產(chǎn)品數(shù)據(jù)填充列.但是您需要在第二個函數(shù)中設(shè)置正確對應(yīng)的meta_key 以獲取數(shù)據(jù).

Here is the way to do it with that 2 custom functions hooked. The first one create the column with the title, the second one populate the column with the products data. But you will need to set in that second function, the correct corresponding meta_key to get the data.

代碼如下:

// ADDING A CUSTOM COLUMN TITLE TO ADMIN PRODUCTS LIST
add_filter( 'manage_edit-product_columns', 'custom_product_column',11);
function custom_product_column($columns)
{
   //add columns
   $columns['delivery'] = __( 'Delivery time','woocommerce'); // title
   return $columns;
}

// ADDING THE DATA FOR EACH PRODUCTS BY COLUMN (EXAMPLE)
add_action( 'manage_product_posts_custom_column' , 'custom_product_list_column_content', 10, 2 );
function custom_product_list_column_content( $column, $product_id )
{
    global $post;

    // HERE get the data from your custom field (set the correct meta key below)
    $delivery_time = get_post_meta( $product_id, '_delivery_time', true );

    switch ( $column )
    {
        case 'delivery' :
            echo $delivery_time; // display the data
            break;
    }
}

代碼位于活動子主題(或主題)的 function.php 文件或任何插件文件中.

經(jīng)過測試并有效.

如何獲得正確的 meta_key slug:

要找到與交付時間"對應(yīng)的正確meta_key slug,您需要使用PhpMyAdmin 在您的數(shù)據(jù)庫中進行搜索.您必須以這種方式在 wp_postmeta 表中搜索 delivery 術(shù)語:

To find the correct meta_key slug corresponding to the "delivery time", you should need to make search in your database using PhpMyAdmin. You will have to search for delivery term in wp_postmeta table this way:

然后你會得到這樣的結(jié)果(這里只有 1 行帶有假 slug):

Then you will get this kind of results (here there is just 1 line with a fake slug):

所以現(xiàn)在你應(yīng)該能夠得到正確的 slug 名稱??(比如這個假的_delivery_date") ...

So now you should be able to get the correct slug name (like this fake "_delivery_date" one)

相關(guān)答案(針對訂單):將自定義列添加到 WooCommerce 后端的管理訂單列表

Related answer (for orders): Add custom columns to admin orders list in WooCommerce backend

這篇關(guān)于在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產(chǎn)品中添加一個將更改價格的選擇字段)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
Add birthday field to WooCommerce my account and admin user page(將生日字段添加到 WooCommerce 我的帳戶和管理員用戶頁面)
主站蜘蛛池模板: 曰韩三级 | 国产三级精品三级在线观看四季网 | 日韩 欧美 二区 | 欧洲精品久久久久毛片完整版 | 欧美日韩在线成人 | 亚洲福利网 | 91天堂网| 久久久青草婷婷精品综合日韩 | 国产精品美女www爽爽爽 | 99久久免费观看 | 国产精品久久久久久久一区探花 | 97国产超碰| www.色.com| 大学生a级毛片免费视频 | 欧美美女爱爱视频 | 亚洲综合在线一区 | 久久伊人免费视频 | 黄色免费网址大全 | 国产免费观看一区 | 超碰97人人人人人蜜桃 | 盗摄精品av一区二区三区 | 黄色在线观看网站 | 国产欧美精品一区二区三区 | 中文字幕国产 | 日日噜噜噜夜夜爽爽狠狠视频, | 久久999| 亚洲成人福利在线观看 | 欧美精品一区二区三区在线播放 | www.yw193.com| 一区二区三区久久久 | 免费一区二区 | 免费在线视频精品 | 美日韩精品 | 成人夜晚看av | 日韩www| 欧美精品在线一区二区三区 | 最大av在线| 四虎在线观看 | 成人在线不卡 | 日本一二区视频 | 久久精品欧美一区二区三区不卡 |