Merge pull request #13247 from woocommerce/fix-13243

Fix download count
This commit is contained in:
Claudio Sanches 2017-02-20 12:28:37 -03:00 committed by GitHub
commit 88b38423f6
2 changed files with 23 additions and 23 deletions

View File

@ -21,7 +21,7 @@ class WC_Download_Handler {
* Hook in methods. * Hook in methods.
*/ */
public static function init() { public static function init() {
if ( isset( $_GET['download_file'] ) && isset( $_GET['order'] ) && isset( $_GET['email'] ) ) { if ( isset( $_GET['download_file'], $_GET['order'], $_GET['email'] ) ) {
add_action( 'init', array( __CLASS__, 'download_product' ) ); add_action( 'init', array( __CLASS__, 'download_product' ) );
} }
add_action( 'woocommerce_download_file_redirect', array( __CLASS__, 'download_file_redirect' ), 10, 2 ); add_action( 'woocommerce_download_file_redirect', array( __CLASS__, 'download_file_redirect' ), 10, 2 );
@ -74,8 +74,8 @@ class WC_Download_Handler {
); );
$count = $download->get_download_count(); $count = $download->get_download_count();
$remaining = $download->get_downloads_remaining(); $remaining = $download->get_downloads_remaining();
$download->set_download_count( $count ++ ); $download->set_download_count( $count + 1 );
$download->set_downloads_remaining( $remaining -- ); $download->set_downloads_remaining( $remaining - 1 );
$download->save(); $download->save();
self::download( $product->get_file_download_path( $download->get_download_id() ), $download->get_product_id() ); self::download( $product->get_file_download_path( $download->get_download_id() ), $download->get_product_id() );

View File

@ -21,16 +21,16 @@ class WC_Customer_Download_Data_Store implements WC_Customer_Download_Data_Store
global $wpdb; global $wpdb;
$data = array( $data = array(
'download_id' => $download->get_download_id(), 'download_id' => $download->get_download_id( 'edit' ),
'product_id' => $download->get_product_id(), 'product_id' => $download->get_product_id( 'edit' ),
'user_id' => $download->get_user_id(), 'user_id' => $download->get_user_id( 'edit' ),
'user_email' => $download->get_user_email(), 'user_email' => $download->get_user_email( 'edit' ),
'order_id' => $download->get_order_id(), 'order_id' => $download->get_order_id( 'edit' ),
'order_key' => $download->get_order_key(), 'order_key' => $download->get_order_key( 'edit' ),
'downloads_remaining' => $download->get_downloads_remaining(), 'downloads_remaining' => $download->get_downloads_remaining( 'edit' ),
'access_granted' => date( 'Y-m-d', $download->get_access_granted() ), 'access_granted' => date( 'Y-m-d', $download->get_access_granted( 'edit' ) ),
'download_count' => $download->get_download_count(), 'download_count' => $download->get_download_count( 'edit' ),
'access_expires' => $download->get_access_expires() ? date( 'Y-m-d', $download->get_access_expires() ) : null, 'access_expires' => $download->get_access_expires( 'edit' ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' ) ) : null,
); );
$format = array( $format = array(
@ -87,16 +87,16 @@ class WC_Customer_Download_Data_Store implements WC_Customer_Download_Data_Store
global $wpdb; global $wpdb;
$data = array( $data = array(
'download_id' => $download->get_download_id(), 'download_id' => $download->get_download_id( 'edit' ),
'product_id' => $download->get_product_id(), 'product_id' => $download->get_product_id( 'edit' ),
'user_id' => $download->get_user_id(), 'user_id' => $download->get_user_id( 'edit' ),
'user_email' => $download->get_user_email(), 'user_email' => $download->get_user_email( 'edit' ),
'order_id' => $download->get_order_id(), 'order_id' => $download->get_order_id( 'edit' ),
'order_key' => $download->get_order_key(), 'order_key' => $download->get_order_key( 'edit' ),
'downloads_remaining' => $download->get_downloads_remaining(), 'downloads_remaining' => $download->get_downloads_remaining( 'edit' ),
'access_granted' => date( 'Y-m-d', $download->get_access_granted() ), 'access_granted' => date( 'Y-m-d', $download->get_access_granted( 'edit' ) ),
'download_count' => $download->get_download_count(), 'download_count' => $download->get_download_count( 'edit' ),
'access_expires' => $download->get_access_expires() ? date( 'Y-m-d', $download->get_access_expires() ) : null, 'access_expires' => $download->get_access_expires( 'edit' ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' ) ) : null,
); );
$format = array( $format = array(