Untitled
unknown
plain_text
2 years ago
1.1 kB
7
Indexable
add_action('woocommerce_order_details_after_order_table', function($order ){
// if is checkout / order received, do not show button
if ( is_checkout() && !empty( is_wc_endpoint_url('order-received') ) ) {
return;
}
if ( ! $order || ! $order->has_status( apply_filters( 'marketking_valid_statuses_refunds', array( 'wc-pcompany', 'pcompany' ) ) ) || ! is_user_logged_in() ) {
return;
}
// if this user is a subaccount, do not show
$currentuserid = get_current_user_id();
$account_type = get_user_meta($currentuserid,'b2bking_account_type', true);
if ($account_type === 'subaccount'){
return;
}
// Show payment link if order already approved.
if ($order){
$order_id = $order->get_id();
// show previous subaccount orders here
$subaccount_id = $order->get_customer_id();
$args = array(
'customer_id' => $subaccount_id,
'limit' => -1, // to retrieve _all_ orders by this user
);
$subaccount_orders = wc_get_orders($args);
foreach ($subaccount_orders as $subaccount_order){
echo '#'.$subaccount_order->get_id();
echo '<br>';
}
}
}, 1000, 1);Editor is loading...