WC_Customer_Download_Data_Store
in package
implements
WC_Customer_Download_Data_Store_Interface
WC Customer Download Data Store.
Tags
Interfaces, Classes and Traits
- WC_Customer_Download_Data_Store_Interface
- WC Customer Download Data Store Interface.
Table of Contents
- DOWNLOAD_PERMISSION_DB_FIELDS = array('download_id', 'product_id', 'user_id', 'user_email', 'order_id', 'order_key', 'downloads_remaining', 'access_granted', 'download_count', 'access_expires')
- Names of the database fields for the download permissions table.
- create() : mixed
- Create download permission for a user.
- create_from_data() : mixed
- Create download permission for a user, from an array of data.
- delete() : mixed
- Method to delete a download permission from the database.
- delete_by_download_id() : mixed
- Method to delete a download permission from the database by download ID.
- delete_by_id() : mixed
- Method to delete a download permission from the database by ID.
- delete_by_order_id() : mixed
- Method to delete a download permission from the database by order ID.
- delete_by_user_email() : bool
- Method to delete a download permission from the database by user email.
- delete_by_user_id() : bool
- Method to delete a download permission from the database by user ID.
- get_downloads() : array<string|int, mixed>
- Get array of download ids by specified args.
- get_downloads_for_customer() : array<string|int, mixed>
- Get a customers downloads.
- read() : mixed
- Method to read a download permission from the database.
- update() : mixed
- Method to update a download in the database.
- update_download_id() : mixed
- Update download ids if the hash changes.
- update_user_by_order_id() : mixed
- Update user prop for downloads based on order id.
- adjust_date_for_db() : string
- Adjust a date value to be inserted in the database.
- delete_download_log_by_field_value() : void
- Delete download_log related to download permission via $field with value $value.
- get_download() : WC_Customer_Download
- Get a download object.
- insert_new_download_permission() : int
- Create download permission for a user, from an array of data.
Constants
DOWNLOAD_PERMISSION_DB_FIELDS
Names of the database fields for the download permissions table.
public
mixed
DOWNLOAD_PERMISSION_DB_FIELDS
= array('download_id', 'product_id', 'user_id', 'user_email', 'order_id', 'order_key', 'downloads_remaining', 'access_granted', 'download_count', 'access_expires')
Methods
create()
Create download permission for a user.
public
create(WC_Customer_Download &$download) : mixed
Parameters
- $download : WC_Customer_Download
-
WC_Customer_Download object.
Return values
mixed —create_from_data()
Create download permission for a user, from an array of data.
public
create_from_data(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
-
Data to create the permission for.
Tags
Return values
mixed —delete()
Method to delete a download permission from the database.
public
delete(WC_Customer_Download &$download[, array<string|int, mixed> $args = array() ]) : mixed
Parameters
- $download : WC_Customer_Download
-
WC_Customer_Download object.
- $args : array<string|int, mixed> = array()
-
Array of args to pass to the delete method.
Return values
mixed —delete_by_download_id()
Method to delete a download permission from the database by download ID.
public
delete_by_download_id(int $id) : mixed
Parameters
- $id : int
-
download_id of the downloads that will be deleted.
Return values
mixed —delete_by_id()
Method to delete a download permission from the database by ID.
public
delete_by_id(int $id) : mixed
Parameters
- $id : int
-
permission_id of the download to be deleted.
Return values
mixed —delete_by_order_id()
Method to delete a download permission from the database by order ID.
public
delete_by_order_id(int $id) : mixed
Parameters
- $id : int
-
Order ID of the downloads that will be deleted.
Return values
mixed —delete_by_user_email()
Method to delete a download permission from the database by user email.
public
delete_by_user_email(string $email) : bool
Parameters
- $email : string
-
email of the downloads that will be deleted.
Tags
Return values
bool — True if deleted rows.delete_by_user_id()
Method to delete a download permission from the database by user ID.
public
delete_by_user_id(int $id) : bool
Parameters
- $id : int
-
user ID of the downloads that will be deleted.
Tags
Return values
bool — True if deleted rows.get_downloads()
Get array of download ids by specified args.
public
get_downloads([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed> = array()
-
Arguments to filter downloads. $args['return'] accepts the following values: 'objects' (default), 'ids' or a comma separated list of fields (for example: 'order_id,user_id,user_email').
Return values
array<string|int, mixed> — Can be an array of permission_ids, an array of WC_Customer_Download objects or an array of arrays containing specified fields depending on the value of $args['return'].get_downloads_for_customer()
Get a customers downloads.
public
get_downloads_for_customer(int $customer_id) : array<string|int, mixed>
Parameters
- $customer_id : int
-
Customer ID.
Return values
array<string|int, mixed> —read()
Method to read a download permission from the database.
public
read(WC_Customer_Download &$download) : mixed
Parameters
- $download : WC_Customer_Download
-
WC_Customer_Download object.
Tags
Return values
mixed —update()
Method to update a download in the database.
public
update(WC_Customer_Download &$download) : mixed
Parameters
- $download : WC_Customer_Download
-
WC_Customer_Download object.
Return values
mixed —update_download_id()
Update download ids if the hash changes.
public
update_download_id(int $product_id, string $old_id, string $new_id) : mixed
Parameters
- $product_id : int
-
Product ID.
- $old_id : string
-
Old download_id.
- $new_id : string
-
New download_id.
Tags
Return values
mixed —update_user_by_order_id()
Update user prop for downloads based on order id.
public
update_user_by_order_id(int $order_id, int $customer_id, string $email) : mixed
Parameters
- $order_id : int
-
Order ID.
- $customer_id : int
-
Customer ID.
- $email : string
-
Customer email address.
Return values
mixed —adjust_date_for_db()
Adjust a date value to be inserted in the database.
private
adjust_date_for_db(mixed $date) : string
Parameters
- $date : mixed
-
The date value. Can be a WC_DateTime, a timestamp, or anything else that "date" recognizes.
Tags
Return values
string — The date converted to 'Y-m-d' format.delete_download_log_by_field_value()
Delete download_log related to download permission via $field with value $value.
private
delete_download_log_by_field_value(string $field, string|int|float $value) : void
Parameters
- $field : string
-
Field used to query download permission table with.
- $value : string|int|float
-
Value to filter the field by.
Return values
void —get_download()
Get a download object.
private
get_download(array<string|int, mixed> $data) : WC_Customer_Download
Parameters
- $data : array<string|int, mixed>
-
From the DB.
Return values
WC_Customer_Download —insert_new_download_permission()
Create download permission for a user, from an array of data.
private
insert_new_download_permission(array<string|int, mixed> $data) : int
Assumes that all the keys in the passed data are valid.
Parameters
- $data : array<string|int, mixed>
-
Data to create the permission for.