| @@ -53,9 +53,16 @@ | ||
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | foreach ( $order->get_items( 'coupon' ) as $coupon_id => $coupon ) { |
| 57 | - $current_coupon_obj = get_page_by_title( $coupon->get_name(), OBJECT, 'shop_coupon' ); | |
| 57 | + $query_args = [ | |
| 58 | + 'post_type' => 'shop_coupon', | |
| 59 | + 'post_title' => $coupon->get_name(), | |
| 60 | + 'posts_per_page' => 1, | |
| 61 | + ]; | |
| 62 | + | |
| 63 | + $coupons_query = new WP_Query( $query_args ); | |
| 64 | + $current_coupon_obj = (object) $coupons_query->get_posts()[0]; | |
| 58 | 65 | $current_coupon_id = $current_coupon_obj->ID; |
| 59 | 66 | $current_coupon = new WC_Coupon( $current_coupon_id ); |
| 60 | 67 | |
| 61 | 68 | $order_data = $current_coupon->get_data(); |