【发布时间】:2021-12-19 06:39:51
【问题描述】:
我想在 WooCommerce 管理员订单列表中添加额外的列,其中包含付款网址
网址是/看起来像这样:
https://mydomaindotcom/checkout/order-pay/17822/?key=wc_order_w4Z53iHEeYPnq
我的意思是这个帖子很接近:
Modify woocommerce orders.php columns
这是我的代码尝试:
add_filter( 'manage_edit-shop_order_columns','hbm_order_key_column');
function hbm_order_key_column($columns)
{
// now it is time to add a custom one
$columns['wc_order'] = "Link Pay Order";
return $columns;
}
还有这个
add_action( 'manage_shop_order_posts_custom_column' , 'your_function_name2' );
function your_function_name2( $column ) {
global $the_order; // you can use the global WP_Order object here
// global $post; // is also available here
if( $column == 'custom_column' ) {
add_action( 'manage_shop_order_posts_custom_column' , 'your_function_name2' );
function your_function_name2( $column ) {
global $the_order; // you can use the global WP_Order object here
// global $post; // is also available here
if( $column == 'custom_column' ) {
//get this form other thread
$order = wc_get_order($order_id);
$pay_now_url = esc_url( $order->get_checkout_payment_url() );
echo $pay_now_url;
//http://example.com/checkout/order-pay/{order_id}?pay_for_order=true&key={order_key}
//http://example.com will be site_url and protocol will depending upon SSL checkout WooCommerce setting.
}
}
}
}
很遗憾没有得到想要的结果。有什么建议吗?
【问题讨论】:
标签: wordpress woocommerce backend orders