WC_Customer_Download_Data_Store::update()
Method to update a download in the database.
Method of the class: WC_Customer_Download_Data_Store{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Customer_Download_Data_Store = new WC_Customer_Download_Data_Store(); $WC_Customer_Download_Data_Store->update( $download );
- $download(WC_Customer_Download) (required) (passed by reference — &)
- WC_Customer_Download object.
WC_Customer_Download_Data_Store::update() WC Customer Download Data Store::update code WC 9.4.2
public function update( &$download ) { global $wpdb; $data = array( 'download_id' => $download->get_download_id( 'edit' ), 'product_id' => $download->get_product_id( 'edit' ), 'user_id' => $download->get_user_id( 'edit' ), 'user_email' => $download->get_user_email( 'edit' ), 'order_id' => $download->get_order_id( 'edit' ), 'order_key' => $download->get_order_key( 'edit' ), 'downloads_remaining' => $download->get_downloads_remaining( 'edit' ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date 'access_granted' => date( 'Y-m-d', $download->get_access_granted( 'edit' )->getTimestamp() ), 'download_count' => $download->get_download_count( 'edit' ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date 'access_expires' => ! is_null( $download->get_access_expires( 'edit' ) ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' )->getTimestamp() ) : null, ); $format = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', ); $wpdb->update( $wpdb->prefix . 'woocommerce_downloadable_product_permissions', $data, array( 'permission_id' => $download->get_id(), ), $format ); $download->apply_changes(); }