Add limit and expiry to get_downloads, cater for empty strings expiry and limit setters

This commit is contained in:
Gerhard Potgieter 2018-01-25 11:28:12 +02:00
parent 5ef6766654
commit 18600e1d2f
2 changed files with 6 additions and 4 deletions

View File

@ -1187,6 +1187,8 @@ class WC_Product extends WC_Abstract_Legacy_Product {
$download_object->set_id( $download['download_id'] );
$download_object->set_name( $download['name'] );
$download_object->set_file( $download['file'] );
$download_object->set_limit( $download['limit'] );
$download_object->set_expiry( $download['expiry'] );
}
// Validate the file extension.

View File

@ -171,19 +171,19 @@ class WC_Product_Download implements ArrayAccess {
/**
* Set Download limit.
*
* @param int $value Download limit.
* @param string|int $value Download limit.
*/
public function set_limit( $value ) {
$this->data['limit'] = absint( $value );
$this->data['limit'] = ( -1 === (int) $value || '' === $value ? -1 : absint( $value ) );
}
/**
* Set Download Expiry
*
* @param int $value Days after download expires.
* @param string|int $value Days after download expires.
*/
public function set_expiry( $value ) {
$this->data['expiry'] = absint( $value );
$this->data['expiry'] = ( -1 === (int) $value || '' === $value ? -1 : absint( $value ) );
}
/*