Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'wcfmd_after_order_mark_delivered', 'wcfm_order_marked_completed_forcefully',20);
- add_action( 'wcfmd_after_order_item_mark_delivered', 'wcfm_order_marked_completed_forcefully',20);
- function wcfm_order_marked_completed_forcefully($order_id) {
- global $wpdb;
- $order = wc_get_order($order_id);
- if (empty($order)) return;
- $sql = 'SELECT count(ID) FROM ' . $wpdb->prefix . 'wcfm_marketplace_orders';
- $sql .= ' WHERE 1=1';
- $sql .= " AND `order_id` = " . $order_id;
- $sql .= " AND shipping_status NOT IN ('shipped','completed')";
- $sql .= " AND commission_status != 'completed'";
- $results = $wpdb->get_var( $sql );
- if($results) return;
- $sql = "SELECT count(ID) FROM `{$wpdb->prefix}wcfm_delivery_orders`";
- $sql .= " WHERE 1=1";
- $sql .= " AND order_id = {$order_id}";
- $sql .= " AND delivery_status != 'delivered'";
- $results = $wpdb->get_var( $sql );
- if($results) return;
- $order->update_status( 'completed' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement