WC_Customer_Download_Data_Store::delete_download_log_by_field_value()
Delete download_log related to download permission via $field with value $value.
Method of the class: WC_Customer_Download_Data_Store{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->delete_download_log_by_field_value( $field, $value );
- $field(string) (required)
- Field used to query download permission table with.
- $value(string|int|float) (required)
- Value to filter the field by.
WC_Customer_Download_Data_Store::delete_download_log_by_field_value() WC Customer Download Data Store::delete download log by field value code WC 9.4.2
private function delete_download_log_by_field_value( $field, $value ) { global $wpdb; $value_placeholder = ''; if ( is_int( $value ) ) { $value_placeholder = '%d'; } elseif ( is_string( $value ) ) { $value_placeholder = '%s'; } elseif ( is_float( $value ) ) { $value_placeholder = '%f'; } else { wc_doing_it_wrong( __METHOD__, __( 'Unsupported argument type provided as value.', 'woocommerce' ), '7.0' ); // The `prepare` further down would fail if the placeholder was missing, so skip download log removal. return; } $query = "DELETE FROM {$wpdb->prefix}wc_download_log WHERE permission_id IN ( SELECT permission_id FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE {$field} = {$value_placeholder} )"; $wpdb->query( $wpdb->prepare( $query, $value ) // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared ); }