/** * * @param unknown $actions * @param unknown $order * @return multitype:string Ambigous <string, mixed> */ function add_wc_cancel_my_account_orders_status($actions, $order) { $check = wcw_check_the_order_status($order->id, $order->post_status); if ($check == 1) { $actions['cancelled'] = array('url' => wp_nonce_url(admin_url('admin-ajax.php?action=request_for_cancell_wcw&order_id=' . $order->id), 'mark_order_as_cancell_request'), 'name' => 'Send Cancel Request', 'action' => "mark_order_as_cancell_request"); } else { if ($check == 2) { $actions['cancelled'] = array('url' => '#', 'name' => 'Cancel request sent', 'action' => "mark_order_as_cancell_request"); } } return $actions; }
/** * * @param int $order_id * @todo This function is triggered, when a order is cancelled in woocommerce. */ function wc_m_move_order_money_to_user($order_id, $old_status, $new_status) { if ($new_status != "cancelled") { return; } if (array_search($order_id, get_the_order_in_log()) === false) { $opm = array_search(get_post_meta($order_id, '_payment_method', true), get_wcw_only_methods()) !== false || get_post_meta($order_id, '_payment_method', true) == "" ? true : false; if (count(get_wcw_only_methods()) != 0 && $opm && wcw_check_the_order_status($order_id, $old_status)) { $order_total = get_post_meta($order_id, '_order_total', true); $order = wc_get_order($order_id); $ttyl = $order->get_fees(); foreach ($ttyl as $key => $yl) { if ($yl['name'] == "Credits") { $e = $key; } } $c = (string) $e; if (-1 * $ttyl[$c]['line_total']) { $order_autho = get_post_meta($order_id, '_customer_user', true); $author_wallet = get_user_meta($order_autho, 'wc_wallet', true); update_user_meta($order_autho, 'wc_wallet', $author_wallet + $order_total + -$ttyl[$c]['line_total']); wc_w_add_to_log($order_autho, $order_total + -$ttyl[$c]['line_total'], 1, $order_id); } else { $order_autho = get_post_meta($order_id, '_customer_user', true); $author_wallet = get_user_meta($order_autho, 'wc_wallet', true); update_user_meta($order_autho, 'wc_wallet', $author_wallet + $order_total); wc_w_add_to_log($order_autho, $order_total, 1, $order_id); } } } }