PHP Class WC_Coupon_Data_Store_CPT

Author: WooThemes
Inheritance: extends WC_Data_Store_WP, implements WC_Coupon_Data_Store_Interface, implements WC_Object_Data_Store_Interface
Show file Open project: woocommerce/woocommerce

Protected Properties

Property Type Description
$internal_meta_keys array Data stored in meta keys, but not considered "meta" for a coupon.
$meta_type string Internal meta type used to store coupon data.

Public Methods

Method Description
create ( &$coupon ) Method to create a new coupon in the database.
decrease_usage_count ( &$coupon, string $used_by = '' ) Decrease usage count for current coupon.
delete ( &$coupon, array $args = [] ) Deletes a coupon from the database.
get_code_by_id ( integer $id ) : string Return a coupon code for a specific ID.
get_ids_by_code ( string $code ) : array Return an array of IDs for for a specific coupon code.
get_usage_by_user_id ( &$coupon, id $user_id ) : integer Get the number of uses for a coupon by user ID.
increase_usage_count ( &$coupon, string $used_by = '' ) Increase usage count for current coupon.
read ( &$coupon ) Method to read a coupon.
update ( &$coupon ) Updates a coupon in the database.

Private Methods

Method Description
update_post_meta ( $coupon ) Helper method that updates all the post meta for a coupon based on it's settings in the WC_Coupon class.

Method Details

create() public method

Method to create a new coupon in the database.
Since: 2.7.0
public create ( &$coupon )

decrease_usage_count() public method

Decrease usage count for current coupon.
Since: 2.7.0
public decrease_usage_count ( &$coupon, string $used_by = '' )
$used_by string Either user ID or billing email

delete() public method

Deletes a coupon from the database.
Since: 2.7.0
public delete ( &$coupon, array $args = [] )
$args array Array of args to pass to the delete method.

get_code_by_id() public method

Return a coupon code for a specific ID.
Since: 2.7.0
public get_code_by_id ( integer $id ) : string
$id integer
return string Coupon Code

get_ids_by_code() public method

Can return multiple to check for existence.
Since: 2.7.0
public get_ids_by_code ( string $code ) : array
$code string
return array Array of IDs.

get_usage_by_user_id() public method

Get the number of uses for a coupon by user ID.
Since: 2.7.0
public get_usage_by_user_id ( &$coupon, id $user_id ) : integer
$user_id id
return integer

increase_usage_count() public method

Increase usage count for current coupon.
Since: 2.7.0
public increase_usage_count ( &$coupon, string $used_by = '' )
$used_by string Either user ID or billing email

read() public method

Method to read a coupon.
Since: 2.7.0
public read ( &$coupon )

update() public method

Updates a coupon in the database.
Since: 2.7.0
public update ( &$coupon )

Property Details

$internal_meta_keys protected property

Data stored in meta keys, but not considered "meta" for a coupon.
Since: 2.7.0
protected array $internal_meta_keys
return array

$meta_type protected property

Internal meta type used to store coupon data.
Since: 2.7.0
protected string $meta_type
return string