问题描述
我是wordpress的新手,我在项目中使用WooCommerce插件,需要在其中修改WooCommerce的一些模板文件和一些核心文件。
我添加了一些自定义代码,这些代码以如下详细信息添加了供应商的产品状态:
/**
* Show status of product in order details wp-admin
*/
add_action( 'woocommerce_admin_order_item_headers','product_status_from_supplier_admin_order_item_headers',10,0 );
function product_status_from_supplier_admin_order_item_headers(){
echo '<th class="item">Product Status</th>';
}
/**
* Show product status in order details wp-admin
*/
add_action( 'woocommerce_admin_order_item_values','product_status_from_supplier_order_item_values',3 );
function product_status_from_supplier_order_item_values( $_product,$item,$item_id ){
// Calling global $post to get the order ID
global $post;
// The Order ID
$order_id = $post->ID;
// the Product ID and variation ID (if different of zero for variations)
$product_id = $item['product_id'];
// Added a condition to avoid other line items than products
echo '<td class=" ">';
$value = get_post_meta( $product_id,'porduct_status_in_supplier',true );
?>
<input type="radio" name="porduct_status_in_supplier<?PHP echo $product_id; ?>" value="Yes" <?PHP checked( $value,'Yes' ); ?> >Yes<br><br>
<input type="radio" name="porduct_status_in_supplier<?PHP echo $product_id; ?>" value="NO" <?PHP checked( $value,'NO' ); ?> >NO<br><br>
<?PHP
echo '</td>';
}
/**
* Save custom Meta Box come from hook woocommerce_admin_order_item_values
*/
add_action( 'woocommerce_process_shop_order_Meta','abukotsh_save_general_details' );
function abukotsh_save_general_details( $order_id ){
$order = wc_get_order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
$product_id = $item->get_product_id();
update_post_Meta( $product_id,wc_clean( $_POST[ 'porduct_status_in_supplier'.$product_id.'' ] ) );
}
}
此代码向我的网站上的员工显示角色是(admin),管理员登录到我的wp-admin并检查订单,并查看订单中的项目,我没有存储,因此,如果有任何用户订单从我的网站上获得订单,并与供应商联系(如果可以,可以从他那里获得或否),是的,请输入管理员签入单选按钮(如果不存在,则他选择否)。
因此,在订单详细信息的末尾。我需要显示一个警报,如果30%的产品不可用(否),我们需要显示一条自定义消息。
那怎么办?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)