WordPress at Your Fingertips
function is not described

WC_Coupon_Data_Store_CPT::get_code_by_id() public WC 3.0.0

Return a coupon code for a specific ID.

{} It's a method of the class: WC_Coupon_Data_Store_CPT{}

No Hooks.


String. Coupon Code


$WC_Coupon_Data_Store_CPT = new WC_Coupon_Data_Store_CPT();
$WC_Coupon_Data_Store_CPT->get_code_by_id( $id );
$id(int) (required)
Coupon ID.


Since 3.0.0 Introduced.

Code of WC_Coupon_Data_Store_CPT::get_code_by_id() WC 5.7.1

public function get_code_by_id( $id ) {
	global $wpdb;
	return $wpdb->get_var(
			"SELECT post_title
			FROM $wpdb->posts
			WHERE ID = %d
			AND post_type = 'shop_coupon'
			AND post_status = 'publish'",