From b8c3e159de77244ced4c9a1d34f666b5c31c6c8c Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 20 Feb 2013 20:48:40 +0000 Subject: [PATCH] Query published coupon. Closes #2487. --- classes/class-wc-coupon.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/class-wc-coupon.php b/classes/class-wc-coupon.php index ceb56b4062d..e49272fbb89 100644 --- a/classes/class-wc-coupon.php +++ b/classes/class-wc-coupon.php @@ -120,10 +120,9 @@ class WC_Coupon { $this->minimum_amount = esc_html( $coupon_data['minimum_amount'] ); $this->customer_email = esc_html( $coupon_data['customer_email'] ); - } else { - $coupon_id = $wpdb->get_var( $wpdb->prepare( apply_filters( 'woocommerce_coupon_code_query', "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon'" ), $this->code ) ); + $coupon_id = $wpdb->get_var( $wpdb->prepare( apply_filters( 'woocommerce_coupon_code_query', "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish'" ), $this->code ) ); if ( ! $coupon_id ) return; @@ -131,7 +130,7 @@ class WC_Coupon { $coupon = get_post( $coupon_id ); $coupon->post_title = apply_filters( 'woocommerce_coupon_code', $coupon->post_title ); - if ( empty( $coupon ) || $coupon->post_status !== 'publish' || $this->code !== $coupon->post_title ) + if ( empty( $coupon ) || $this->code !== $coupon->post_title ) return; $this->id = $coupon->ID;