updated plugin Easy Digital Downloads version 3.1.3

This commit is contained in:
2023-07-03 14:52:54 +00:00
committed by Gitium
parent 19f5bf5875
commit a7f6efbebb
26 changed files with 612 additions and 380 deletions

View File

@ -52,7 +52,8 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
'download' => edd_get_label_singular(),
'quantity' => __( 'Quantity', 'easy-digital-downloads' ),
'amount' => __( 'Item Amount', 'easy-digital-downloads' ),
'payment_id' => __( 'Payment ID', 'easy-digital-downloads' ),
'currency' => __( 'Currency', 'easy-digital-downloads' ),
'order_id' => __( 'Order ID', 'easy-digital-downloads' ),
'price_id' => __( 'Price ID', 'easy-digital-downloads' ),
'date' => __( 'Date', 'easy-digital-downloads' ),
);
@ -72,17 +73,31 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
$args = array_merge(
$this->get_order_item_args(),
array(
'number' => 30,
'offset' => ( $this->step * 30 ) - 30,
'order' => 'ASC',
'number' => 30,
'offset' => ( $this->step * 30 ) - 30,
'order' => 'ASC'
)
);
$items = edd_get_order_items( $args );
foreach ( $items as $item ) {
if ( 'refunded' === $item->status ) {
continue;
}
/** @var EDD\Orders\Order_Item $item */
$order = edd_get_order( $item->order_id );
$order = edd_get_order( $item->order_id );
// If the item has been partially refunded, we need to calculate the amount
$amount = array_reduce(
$item->get_refunded_items(),
function( $total, $refund_item ) {
return $total + $refund_item->total;
},
$item->total
);
$data[] = array(
'ID' => $item->product_id,
@ -92,8 +107,9 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
'name' => edd_get_customer_field( $order->customer_id, 'name' ),
'download' => $item->product_name,
'quantity' => $item->quantity,
'amount' => $order->total,
'payment_id' => $order->id,
'amount' => edd_format_amount( $amount ),
'currency' => $order->currency,
'order_id' => $order->id,
'price_id' => $item->price_id,
'date' => $order->date_created,
);
@ -155,7 +171,7 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
public function set_properties( $request ) {
$this->start = isset( $request['sales-export-start'] ) ? sanitize_text_field( $request['sales-export-start'] ) : '';
$this->end = isset( $request['sales-export-end'] ) ? sanitize_text_field( $request['sales-export-end'] ) . ' 23:59:59' : '';
$this->end = isset( $request['sales-export-end'] ) ? sanitize_text_field( $request['sales-export-end'] ) : '';
$this->download_id = isset( $request['download_id'] ) ? absint( $request['download_id'] ) : 0;
$this->orders = $this->get_orders();
}

View File

@ -2800,7 +2800,7 @@ function edd_recapture_callback($args) {
* @return void
*/
function edd_tax_rates_callback( $args ) {
$rates = edd_get_tax_rates( array( 'number' => 9999 ), OBJECT );
$rates = edd_get_tax_rates( array(), OBJECT );
wp_enqueue_script( 'edd-admin-tax-rates' );
wp_enqueue_style( 'edd-admin-tax-rates' );

View File

@ -355,7 +355,7 @@ final class Easy_Digital_Downloads {
// Plugin version.
if ( ! defined( 'EDD_VERSION' ) ) {
define( 'EDD_VERSION', '3.1.2' );
define( 'EDD_VERSION', '3.1.3' );
}
// Make sure CAL_GREGORIAN is defined.

View File

@ -306,7 +306,7 @@ class EDD_Download {
* @param array $prices The array of variables prices.
* @param int|string The ID of the download.
*/
return (array) apply_filters( 'edd_get_variable_prices', $this->prices, $this->ID );
return array_filter( (array) apply_filters( 'edd_get_variable_prices', $this->prices, $this->ID ) );
}
/**

View File

@ -110,10 +110,12 @@ class EDD_HTML_Elements {
// If showing variations, add them to the list.
if ( $args['variations'] ) {
$prices = edd_get_variable_prices( $product->ID );
foreach ( $prices as $key => $value ) {
$name = ! empty( $value['name'] ) ? $value['name'] : '';
if ( $name ) {
$options[ absint( $product->ID ) . '_' . $key ] = esc_html( $product->post_title . ': ' . $name );
if ( ! empty( $prices ) ) {
foreach ( $prices as $key => $value ) {
$name = ! empty( $value['name'] ) ? $value['name'] : '';
if ( $name ) {
$options[ absint( $product->ID ) . '_' . $key ] = esc_html( $product->post_title . ': ' . $name );
}
}
}
}

View File

@ -220,6 +220,7 @@ class EDD_License {
'is_valid_license_option' => $this->item_shortname . '_license_active',
'item_id' => $this->item_id,
'api_url' => $this->api_url,
'file' => $this->file,
),
'size' => 'regular',
)

View File

@ -406,9 +406,10 @@ function edd_has_active_discounts() {
*
* @internal This method exists for backwards compatibility. `edd_add_discount()` should be used.
*
* @since 1.0
* @since 2.7 Updated to use EDD_Discount object.
* @since 3.0 Updated to use new query class.
* @since 1.0
* @since 2.7 Updated to use EDD_Discount object.
* @since 3.0 Updated to use new query class.
* @deprecated 3.0 Use edd_add_discount()
*
* @param array $details Discount args.
* @param int $discount_id Discount ID.
@ -416,18 +417,32 @@ function edd_has_active_discounts() {
*/
function edd_store_discount( $details, $discount_id = null ) {
edd_debug_log(
sprintf(
__( '%1$s is deprecated since Easy Digital Downloads version %2$s! Use %3$s instead.', 'easy-digital-downloads' ),
__FUNCTION__,
'3.0',
'edd_add_discount()'
),
true
);
// Set default return value to false.
$return = false;
// Back-compat for start date.
if ( isset( $details['start'] ) && strstr( $details['start'], '/' ) ) {
$details['start_date'] = date( 'Y-m-d', strtotime( $details['start'] ) ) . ' 00:00:00';
$time_format = date( 'H:i:s', strtotime( $details['start'] ) );
$date_format = date( 'Y-m-d', strtotime( $details['start'] ) ) . ' ' . $time_format;
$details['start_date'] = edd_get_utc_equivalent_date( EDD()->utils->date( $date_format, edd_get_timezone_id(), false ));
unset( $details['start'] );
}
// Back-compat for end date.
if ( isset( $details['expiration'] ) && strstr( $details['expiration'], '/' ) ) {
$details['end_date'] = date( 'Y-m-d', strtotime( $details['expiration'] ) ) . ' 23:59:59';
$time_format = date( 'H:i:s', strtotime( $details['expiration'] ) );
$date_format = date( 'Y-m-d', strtotime( $details['expiration'] ) ) . ' ' . ( '00:00:00' !== $time_format ? $time_format : '23:59:59' );
$details['end_date'] = edd_get_utc_equivalent_date( EDD()->utils->date( $date_format, edd_get_timezone_id(), false ) );
unset( $details['expiration'] );
}

View File

@ -25,7 +25,8 @@ defined( 'ABSPATH' ) || exit;
*/
function edd_trigger_purchase_receipt( $payment_id = 0, $payment = null, $customer = null ) {
// Make sure we don't send a purchase receipt while editing a payment
if ( isset( $_POST['edd-action'] ) && 'edit_payment' == $_POST['edd-action'] ) {
$action = filter_input( INPUT_POST, 'edd_action', FILTER_SANITIZE_STRING );
if ( 'update_payment_details' === $action ) {
return;
}
if ( null === $payment ) {

View File

@ -1007,17 +1007,20 @@ function edd_build_order( $order_data = array() ) {
foreach ( $item['fees'] as $fee_id => $fee ) {
$adjustment_subtotal = floatval( $fee['amount'] );
$tax_rate_amount = empty( $tax_rate->amount ) ? false : $tax_rate->amount;
$tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate_amount );
$adjustment_total = floatval( $fee['amount'] ) + $tax;
$adjustment_data = array(
$adjustment_total = floatval( $fee['amount'] );
$adjustment_tax = 0;
if ( ! empty( $tax_rate->amount ) && empty( $fee['no_tax'] ) ) {
$adjustment_tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate->amount );
$adjustment_total = floatval( $fee['amount'] ) + $adjustment_tax;
}
$adjustment_data = array(
'object_id' => $order_item_id,
'object_type' => 'order_item',
'type_key' => $fee_id,
'type' => 'fee',
'description' => $fee['label'],
'subtotal' => $adjustment_subtotal,
'tax' => $tax,
'tax' => $adjustment_tax,
'total' => $adjustment_total,
);
@ -1054,10 +1057,13 @@ function edd_build_order( $order_data = array() ) {
add_filter( 'edd_prices_include_tax', '__return_false' );
$fee_subtotal = floatval( $fee['amount'] );
$tax_rate_amount = empty( $tax_rate->amount ) ? false : $tax_rate->amount;
$tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate_amount );
$fee_total = floatval( $fee['amount'] ) + $tax;
$fee_subtotal = floatval( $fee['amount'] );
$fee_total = floatval( $fee['amount'] );
$fee_tax = 0;
if ( ! empty( $tax_rate->amount ) && empty( $fee['no_tax'] ) ) {
$fee_tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate->amount );
$fee_total = floatval( $fee['amount'] ) + $fee_tax;
}
remove_filter( 'edd_prices_include_tax', '__return_false' );
@ -1068,7 +1074,7 @@ function edd_build_order( $order_data = array() ) {
'type' => 'fee',
'description' => $fee['label'],
'subtotal' => $fee_subtotal,
'tax' => $tax,
'tax' => $fee_tax,
'total' => $fee_total,
);
@ -1076,7 +1082,7 @@ function edd_build_order( $order_data = array() ) {
$adjustment_id = edd_add_order_adjustment( $args );
$total_fees += (float) $fee['amount'];
$total_tax += $tax;
$total_tax += $fee_tax;
}
}

View File

@ -1310,10 +1310,6 @@ add_action( 'edd_checkout_error_checks', 'edd_check_purchase_email_length', 10,
*/
function edd_process_straight_to_gateway( $data ) {
if ( empty( $data['edd_straight_to_gateway'] ) || ! wp_verify_nonce( $data['edd_straight_to_gateway'], 'edd_straight_to_gateway' ) ) {
return;
}
$download_id = $data['download_id'];
$options = isset( $data['edd_options'] ) ? $data['edd_options'] : array();
$quantity = isset( $data['edd_download_quantity'] ) ? $data['edd_download_quantity'] : 1;

View File

@ -797,8 +797,8 @@ function edd_process_profile_editor_updates( $data ) {
// Fetch customer record.
$customer = edd_get_customer_by( 'user_id', $user_id );
if ( empty( $customer->user_id ) || $customer->user_id != $user_id ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return false;
if ( ! empty( $customer->user_id ) && $customer->user_id != $user_id ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
edd_set_error( 'customer_mismatch', __( 'Your profile could not be updated. Please contact a site administrator.', 'easy-digital-downloads' ) );
}
$display_name = isset( $data['edd_display_name'] ) ? sanitize_text_field( $data['edd_display_name'] ) : $old_user_data->display_name;
@ -817,16 +817,16 @@ function edd_process_profile_editor_updates( $data ) {
'first_name' => $first_name,
'last_name' => $last_name,
'display_name' => $display_name,
'user_email' => $email
'user_email' => $email,
);
$address = array(
'line1' => $line1,
'line2' => $line2,
'city' => $city,
'state' => $state,
'zip' => $zip,
'country' => $country
'line1' => $line1,
'line2' => $line2,
'city' => $city,
'state' => $state,
'zip' => $zip,
'country' => $country,
);
do_action( 'edd_pre_update_user_profile', $user_id, $userdata );
@ -874,12 +874,14 @@ function edd_process_profile_editor_updates( $data ) {
// Update user.
$updated = wp_update_user( $userdata );
// If the current user does not have an associated customer record, create one.
// If the current user does not have an associated customer record, create one so that all of the customer's data is stored.
if ( ! $customer && $updated ) {
$customer_id = edd_add_customer( array(
'user_id' => $updated,
'email' => $email,
) );
$customer_id = edd_add_customer(
array(
'user_id' => $updated,
'email' => $email,
)
);
$customer = edd_get_customer_by( 'id', $customer_id );
}
@ -893,7 +895,7 @@ function edd_process_profile_editor_updates( $data ) {
'type' => 'billing',
'is_primary' => 1,
'number' => 1,
'fields' => 'ids'
'fields' => 'ids',
) );
// Try updating the address if it exists.

View File

@ -54,7 +54,7 @@ function edd_get_tax_rates( $args = array(), $output = ARRAY_N ) {
// Parse args
$r = wp_parse_args( $args, array(
'number' => 30,
'number' => 9999,
'type' => 'tax_rate',
'orderby' => 'date_created',
'order' => 'ASC',