diff --git a/plugins/woocommerce/changelog/pr-43731 b/plugins/woocommerce/changelog/pr-43731 new file mode 100644 index 00000000000..9b574f78d88 --- /dev/null +++ b/plugins/woocommerce/changelog/pr-43731 @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Fix wpdb->prepare argument type for coupons query \ No newline at end of file diff --git a/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php b/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php index abe9022dfbd..5340c4406a7 100644 --- a/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php +++ b/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php @@ -441,7 +441,7 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat global $wpdb; $usage_count = $wpdb->get_var( $wpdb->prepare( - "SELECT COUNT( meta_id ) FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_used_by' AND meta_value = %d;", + "SELECT COUNT( meta_id ) FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_used_by' AND meta_value = %s;", $coupon->get_id(), $user_id )