wc_get_coupon_code_by_id

Get coupon code by ID.

Description

(string) wc_get_coupon_code_by_id( (int) $id ); 

Returns (string)

Parameters (1)

0. $id (int)
Coupon ID.

Usage

  1. if ( !function_exists( 'wc_get_coupon_code_by_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-coupon-functions.php'; 
  3.  
  4. // Coupon ID. 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_coupon_code_by_id($id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-coupon-functions.php  
  1. function wc_get_coupon_code_by_id( $id ) { 
  2. $data_store = WC_Data_Store::load( 'coupon' ); 
  3. return (string) $data_store->get_code_by_id( $id );