CouponRepository extends AbstractRepository
in package

Tags
since
1.11.0

Table of Contents

$entitiesCache  : array<string|int, mixed>
$postType  : string
__construct()  : mixed
findAll()  : array<string|int, mixed>
findAllByMeta()  : array<string|int, mixed>
Usage: <pre> findAllByMeta($metaKey, $metaValue) findAllByMeta($metaKey, $metaValue, $operator) findAllByMeta($metaKey, $operator) </pre>
findAllByValueInMeta()  : array<string|int, mixed>
findByCode()  : Coupon|null
findById()  : AbstractEntity|null
findByMeta()  : AbstractEntity|null
Usage: <pre> findByMeta($metaKey, $metaValue) findByMeta($metaKey, $metaValue, $operator) findByMeta($metaKey, $operator) </pre>
findIdByMeta()  : int
mapPostsToEntities()  : array<string|int, AbstractEntity>
mapPostToEntity()  : AbstractEntity|null
saveUsageCount()  : mixed
addActions()  : mixed
defaultQueryArgs()  : array<string|int, mixed>
entitySchema()  : array<string|int, mixed>
getCategories()  : array<string|int, mixed>
getPost()  : WP_Post|null
getPosts()  : array<string|int, WP_Post>|array<string|int, int>
mapPostDataToEntity()  : Coupon
mapPostToPostData()  : array<string|int, mixed>
metaQueryArgs()  : array<string|int, mixed>

Properties

$entitiesCache

protected array<string|int, mixed> $entitiesCache = []
Tags
since
1.0

$postType

protected string $postType
Tags
since
1.0

Methods

__construct()

public __construct(string $postType) : mixed
Parameters
$postType : string
Tags
since
1.0
Return values
mixed

findAll()

public findAll([array<string|int, mixed> $args = [] ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = []

Optional. @param string|array $args['fields'] 'all', 'ids' or [Key field => Value field], for example: ['id' => 'name'].

Tags
since
1.0
Return values
array<string|int, mixed>

Entities, IDs or mixed values (when "fields" argument is an array).

findAllByMeta()

Usage: <pre> findAllByMeta($metaKey, $metaValue) findAllByMeta($metaKey, $metaValue, $operator) findAllByMeta($metaKey, $operator) </pre>

public findAllByMeta(string $metaKey, mixed $metaValue[, string $operator = null ][, array<string|int, mixed> $args = [] ]) : array<string|int, mixed>
Parameters
$metaKey : string
$metaValue : mixed
$operator : string = null

Optional.

$args : array<string|int, mixed> = []

Optional.

Tags
since
1.0
Return values
array<string|int, mixed>

Entities, IDs or mixed values.

findAllByValueInMeta()

public findAllByValueInMeta(string $metaKey, mixed $value[, array<string|int, mixed> $args = [] ]) : array<string|int, mixed>
Parameters
$metaKey : string
$value : mixed

Value to search in the arrays of postmetas.

$args : array<string|int, mixed> = []

Optional.

Tags
since
1.0
Return values
array<string|int, mixed>

Entities, IDs or mixed values.

findByCode()

public findByCode(string $couponCode) : Coupon|null
Parameters
$couponCode : string
Return values
Coupon|null

findById()

public findById(int $id[, bool $forceReload = false ]) : AbstractEntity|null
Parameters
$id : int

Optional. Current post by default.

$forceReload : bool = false

Optional. False by default.

Tags
since
1.0
since
1.2

$id is optional.

Return values
AbstractEntity|null

findByMeta()

Usage: <pre> findByMeta($metaKey, $metaValue) findByMeta($metaKey, $metaValue, $operator) findByMeta($metaKey, $operator) </pre>

public findByMeta(string $metaKey, mixed $metaValue[, string $operator = null ]) : AbstractEntity|null
Parameters
$metaKey : string
$metaValue : mixed
$operator : string = null

Optional.

Tags
since
1.0
Return values
AbstractEntity|null

findIdByMeta()

public findIdByMeta(string $metaKey, mixed $metaValue) : int
Parameters
$metaKey : string
$metaValue : mixed
Tags
global

\wpdb $wpdb

Return values
int

Post ID or 0.

mapPostsToEntities()

public mapPostsToEntities(array<string|int, WP_Post$posts) : array<string|int, AbstractEntity>
Parameters
$posts : array<string|int, WP_Post>
Tags
since
1.0
Return values
array<string|int, AbstractEntity>

mapPostToEntity()

public mapPostToEntity(WP_Post|null $post) : AbstractEntity|null
Parameters
$post : WP_Post|null
Tags
since
1.0
Return values
AbstractEntity|null

saveUsageCount()

public saveUsageCount(Coupon|int $coupon, int $usageCount) : mixed
Parameters
$coupon : Coupon|int
$usageCount : int
Return values
mixed

addActions()

protected addActions() : mixed
Tags
since
1.0
Return values
mixed

defaultQueryArgs()

protected defaultQueryArgs() : array<string|int, mixed>
Tags
since
1.0
Return values
array<string|int, mixed>

entitySchema()

protected entitySchema() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCategories()

protected getCategories(string $taxonomy, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$taxonomy : string
$args : array<string|int, mixed>

@param int $args['post_id'] Optional. Custom argument. Retrieve the terms of the taxonomy that are attached to the post.

Tags
since
1.0
Return values
array<string|int, mixed>

[Term ID => \WP_Term]

getPost()

protected getPost(int $id) : WP_Post|null
Parameters
$id : int
Tags
since
1.0
Return values
WP_Post|null

getPosts()

protected getPosts(array<string|int, mixed> $args) : array<string|int, WP_Post>|array<string|int, int>
Parameters
$args : array<string|int, mixed>
Tags
since
1.0
Return values
array<string|int, WP_Post>|array<string|int, int>

mapPostDataToEntity()

protected mapPostDataToEntity(array<string|int, mixed> $postData) : Coupon
Parameters
$postData : array<string|int, mixed>
Return values
Coupon

mapPostToPostData()

protected mapPostToPostData(WP_Post $post) : array<string|int, mixed>
Parameters
$post : WP_Post
Tags
since
1.0
Return values
array<string|int, mixed>

metaQueryArgs()

protected metaQueryArgs(string $metaKey, mixed $metaValue, string|null $operator) : array<string|int, mixed>
Parameters
$metaKey : string
$metaValue : mixed
$operator : string|null
Tags
since
1.0
Return values
array<string|int, mixed>

Search results