protection double facture

This commit is contained in:
Jean-Philippe Staelen 2026-01-25 15:34:47 +01:00
parent 75cd96080a
commit 16fda3c959

View File

@ -46,12 +46,19 @@ class PEPPOL_Woocommerce_controller {
public static function post_payment(int $order_id): void { public static function post_payment(int $order_id): void {
$order_id = (int) $order_id; $order_id = (int) $order_id;
global $wpdb;
if ($order_id <= 0) { if ($order_id <= 0) {
return; return;
} }
$order = \wc_get_order($order_id); $order = \wc_get_order($order_id);
$is_invoice_exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}esi_peppol_invoices WHERE order_id = %d", $order_id));
if ($is_invoice_exists > 0) {
return;
}
if (!$order instanceof \WC_Order) { if (!$order instanceof \WC_Order) {
return; return;
} }