When purchasing multiple downloadable products (same item), multiply download limit by qty purchased.
Closes #7451
This commit is contained in:
parent
d50a64dd55
commit
8126b7ef58
|
@ -227,16 +227,17 @@ function wc_register_order_type( $type, $args = array() ) {
|
|||
* @param string $download_id file identifier
|
||||
* @param int $product_id product identifier
|
||||
* @param WC_Order $order the order
|
||||
* @param int $qty purchased
|
||||
* @return int|bool insert id or false on failure
|
||||
*/
|
||||
function wc_downloadable_file_permission( $download_id, $product_id, $order ) {
|
||||
function wc_downloadable_file_permission( $download_id, $product_id, $order, $qty = 1 ) {
|
||||
global $wpdb;
|
||||
|
||||
$user_email = sanitize_email( $order->billing_email );
|
||||
$limit = trim( get_post_meta( $product_id, '_download_limit', true ) );
|
||||
$expiry = trim( get_post_meta( $product_id, '_download_expiry', true ) );
|
||||
|
||||
$limit = empty( $limit ) ? '' : absint( $limit );
|
||||
$limit = empty( $limit ) ? '' : absint( $limit ) * $qty;
|
||||
|
||||
// Default value is NULL in the table schema
|
||||
$expiry = empty( $expiry ) ? null : absint( $expiry );
|
||||
|
@ -312,7 +313,7 @@ function wc_downloadable_product_permissions( $order_id ) {
|
|||
$downloads = $_product->get_files();
|
||||
|
||||
foreach ( array_keys( $downloads ) as $download_id ) {
|
||||
wc_downloadable_file_permission( $download_id, $item['variation_id'] > 0 ? $item['variation_id'] : $item['product_id'], $order );
|
||||
wc_downloadable_file_permission( $download_id, $item['variation_id'] > 0 ? $item['variation_id'] : $item['product_id'], $order, $item['qty'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Fix - Fix place order button text on init.
|
||||
* Fix - When duplicating products, handle entities.
|
||||
* Fix - Double shop page in breadcrumb and white space issues.
|
||||
* Fix - When purchasing multiple downloadable products (same item), multiply download limit by qty purchased.
|
||||
* Tweak - Added DOMDocument item in the System Status as a requirement.
|
||||
* Tweak - Simplify default mode should be 'standard'.
|
||||
* Tweak - Set attribte 'query_var' true when public.
|
||||
|
|
Loading…
Reference in New Issue