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.


Top ↑

Return Return

(string) Coupon Code


Top ↑

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
			)
		);
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.