WC_Coupon_Data_Store_CPT::get_code_by_id( int $id )
Return a coupon code for a specific ID.
Description Description
Parameters Parameters
- $id
-
(Required) Coupon ID.
Return Return
(string) Coupon Code
Source Source
File: includes/data-stores/class-wc-coupon-data-store-cpt.php
public function get_code_by_id( $id ) {
global $wpdb;
return $wpdb->get_var(
$wpdb->prepare(
"SELECT post_title
FROM $wpdb->posts
WHERE ID = %d
AND post_type = 'shop_coupon'
AND post_status = 'publish'",
$id
)
);
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |