1
고객이 취소 한 주문 수를 계산하고 관리 주문 화면에 표시하려고합니다.Woocommerce Admin 주문 주문 페이지에서 고객 취소 주문 수 표시
제 문제는 원격 고객을 위해 작동하지 못하게되어 스스로 해결할 수 있다는 것입니다 (current_user).
이 내 코드입니다 (다른 인터넷 검색 및 일부 작은 수정에서했다) :
function count_order_no($atts, $content = null) {
$args = shortcode_atts(array(
'status' => 'cancelled',
), $atts);
$statuses = array_map('trim', explode(',', $args['status']));
$order_count = 0;
foreach ($statuses as $status) {
// if we didn't get a wc- prefix, add one
if (0 !== strpos($status, 'wc-')) {
$status = 'wc-' . $status;
}
$order_count += wp_count_posts('shop_order')->$status;
}
ob_start();
echo number_format($order_count);
return ob_get_clean();
}
add_shortcode('wc_order_count', 'count_order_no');
하고 어떤 도움이 많이 apreciated된다
// print the number
function print_the_number() {
echo do_shortcode('[wc_order_count]');
}
// add the action
add_action('woocommerce_admin_order_data_after_order_details', 'print_the_number', 10, 1);
관리자의 수를 표시!
대단히 고마워요, 매력처럼 작동합니다! 실제로 당신의 방법은 훨씬 간단하고 명확합니다! – RwkY