PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.0
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.0
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
← All changes | includes/Services/QuoteExpirationService.php +14 -10 2.1.192.4.0 View file →
@@ -42,24 +42,25 @@
42 42
43 43 // Get current date in Y-m-d format
44 44 $current_date = current_time( 'Y-m-d' );
45 45
46 - // Find quotes that are past their due date and not already expired
46 + // Quotes still open (draft, available, sent) whose expiry date has passed.
47 + // Accepted, declined, converted and cancelled quotes are left alone —
48 + // the old query (which also named a post type that does not exist)
49 + // would have expired an accepted quote the day after its date.
47 50 $expired_quotes = $wpdb->get_results(
48 51 $wpdb->prepare(
49 52 "SELECT p.ID, p.post_title
50 53 FROM {$wpdb->posts} p
51 54 INNER JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id
52 - WHERE p.post_type = 'easy_quote'
55 + INNER JOIN {$wpdb->postmeta} ps ON p.ID = ps.post_id AND ps.meta_key = '_easy_invoice_quote_status'
56 + WHERE p.post_type = %s
53 57 AND p.post_status IN ('publish', 'draft')
54 58 AND pm.meta_key = '_easy_invoice_quote_expiry_date'
59 + AND pm.meta_value <> ''
55 60 AND pm.meta_value < %s
56 - AND p.ID NOT IN (
57 - SELECT post_id
58 - FROM {$wpdb->postmeta}
59 - WHERE meta_key = '_easy_invoice_quote_status'
60 - AND meta_value = 'expired'
61 - )",
61 + AND ps.meta_value IN ('draft', 'available', 'sent')",
62 + \EasyInvoice\Constants\PostTypes::EASY_INVOICE_QUOTE_POST_TYPE,
62 63 $current_date
63 64 )
64 65 );
65 66
@@ -70,10 +71,13 @@
70 71 $updated_count = 0;
71 72
72 73 foreach ( $expired_quotes as $quote ) {
73 74 // Update the quote status to expired
74 - update_post_meta( $quote->ID, '_easy_invoice_quote_status', 'expired' );
75 -
75 + update_post_meta( $quote->ID, '_easy_invoice_quote_status', 'expired' );
76 +
77 + // Fire integration hook — addons (Webhooks, etc.) subscribe to this.
78 + do_action( 'easy_invoice_quote_expired', $quote->ID );
79 +
76 80 $updated_count++;
77 81 }
78 82 }
79 83