Skip to content

Commit

Permalink
Merge pull request #9702 from awesomemotive/release/3.2.6
Browse files Browse the repository at this point in the history
Release 3.2.6
  • Loading branch information
cklosowski committed Dec 11, 2023
2 parents 715373d + 36f483b commit 7e68d57
Show file tree
Hide file tree
Showing 32 changed files with 391 additions and 263 deletions.
4 changes: 2 additions & 2 deletions assets/js/admin/components/chosen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jQuery( document ).ready( function( $ ) {
no_bundles = container.hasClass( 'no-bundles' ),
variations = container.hasClass( 'variations' ),
variations_only = container.hasClass( 'variations-only' ),

current_id = container.hasClass( 'exclude-current' ) ? edd_vars.post_id : 0,
lastKey = e.which,
search_type = 'edd_download_search';

Expand Down Expand Up @@ -110,7 +110,7 @@ jQuery( document ).ready( function( $ ) {
no_bundles: no_bundles,
variations: variations,
variations_only: variations_only,
current_id: edd_vars.post_id,
current_id: current_id,
},

beforeSend: function() {
Expand Down
3 changes: 2 additions & 1 deletion assets/js/admin/reports/charts/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export const tooltipConfig = ( config ) => ( {
*/
label: function( t, d ) {
const { options: { datasets } } = config;
const datasetConfig = datasets[ Object.keys( datasets )[ t.datasetIndex ] ];
const dataset = d.datasets[ t.datasetIndex ];
// as options dataset contains pie chart data we need to find the dataset by label here.
const datasetConfig = Object.values( datasets ).find( value => value.label && value.label.toLowerCase() === dataset.label.toLowerCase() );

const total = dataset.data.reduce( function( previousValue, currentValue, currentIndex, array ) {
return previousValue + currentValue;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/edd-admin-reports.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/edd-admin.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions easy-digital-downloads.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
* Plugin Name: Easy Digital Downloads
* Plugin Name: Easy Digital Downloads (Pro)
* Plugin URI: https://easydigitaldownloads.com
* Description: The easiest way to sell digital products with WordPress.
* Author: Easy Digital Downloads
* Author URI: https://easydigitaldownloads.com
* Version: 3.2.5
* Version: 3.2.6
* Text Domain: easy-digital-downloads
* Domain Path: /languages
* Requires at least: 5.8
Expand All @@ -27,7 +27,7 @@
* @package EDD
* @category Core
* @author Easy Digital Downloads
* @version 3.2.5
* @version 3.2.6
*/

// Exit if accessed directly.
Expand Down
3 changes: 1 addition & 2 deletions includes/admin/downloads/metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ function edd_render_refund_row( $post_id ) {

$types = edd_get_refundability_types();
$global_ability = edd_get_option( 'refundability', 'refundable' );
$refundability = edd_get_download_refundability( $post_id );
$global_window = edd_get_option( 'refund_window', 30 );
$edd_refund_window = edd_get_download_refund_window( $post_id ); ?>

Expand All @@ -821,7 +820,7 @@ function edd_render_refund_row( $post_id ) {
'' => sprintf(
/* translators: Default refund status */
esc_html_x( 'Default (%1$s)', 'Download refund status', 'easy-digital-downloads' ),
ucwords( $refundability )
ucwords( $global_ability )
),
),
$types
Expand Down
2 changes: 2 additions & 0 deletions includes/admin/downloads/views/metabox-bundled-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'show_variations_only' => false,
'class' => 'edd-form-group__input',
'bundles' => false,
'exclude_current' => true,
)
);
?>
Expand Down Expand Up @@ -124,6 +125,7 @@
'variations' => true,
'show_variations_only' => false,
'bundles' => false,
'exclude_current' => true,
) );
?>
</div>
Expand Down
13 changes: 3 additions & 10 deletions includes/admin/reporting/export/class-batch-export-sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function csv_cols() {
'download' => edd_get_label_singular(),
'quantity' => __( 'Quantity', 'easy-digital-downloads' ),
'amount' => __( 'Item Amount', 'easy-digital-downloads' ),
'tax' => __( 'Tax', 'easy-digital-downloads' ),
'currency' => __( 'Currency', 'easy-digital-downloads' ),
'order_id' => __( 'Order ID', 'easy-digital-downloads' ),
'price_id' => __( 'Price ID', 'easy-digital-downloads' ),
Expand Down Expand Up @@ -97,15 +98,6 @@ public function get_data() {
/** @var EDD\Orders\Order_Item $item */
$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,
'user_id' => $order->user_id,
Expand All @@ -114,7 +106,8 @@ function( $total, $refund_item ) {
'name' => edd_get_customer_field( $order->customer_id, 'name' ),
'download' => $item->product_name,
'quantity' => $item->quantity,
'amount' => edd_format_amount( $amount ),
'amount' => edd_format_amount( $item->get_net_total() ),
'tax' => edd_format_amount( $item->tax ),
'currency' => $order->currency,
'order_id' => $order->id,
'price_id' => $item->price_id,
Expand Down
2 changes: 1 addition & 1 deletion includes/blocks/includes/checkout/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function do_personal_info_forms( $block_attributes ) {
echo '<div class="' . esc_attr( $class ) . '">';
foreach ( $forms as $id => $form ) {
printf(
'<button class="edd-button-secondary edd-blocks__checkout-%1$s link" data-attr="%1$s"%2$s>%3$s</button>',
'<button type="button" class="edd-button-secondary edd-blocks__checkout-%1$s link" data-attr="%1$s"%2$s>%3$s</button>',
esc_attr( $id ),
empty( $i ) ? ' disabled' : '',
esc_html( $form['label'] )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
if ( function_exists( 'EDD_CFM' ) ) {
return;
}
$is_user_logged_in = is_user_logged_in();
?>
<fieldset id="edd_checkout_user_info" class="edd-blocks-form">
<legend><?php esc_html_e( 'Personal Info', 'easy-digital-downloads' ); ?></legend>
<?php if ( empty( $customer['email'] ) ) : ?>
<?php if ( ! $is_user_logged_in || empty( $customer['email'] ) ) : ?>
<div id="edd-email-wrap">
<label class="edd-label" for="edd-email">
<?php
Expand All @@ -17,7 +18,7 @@
<p class="edd-description" id="edd-email-description"><?php esc_html_e( 'We will send the purchase receipt to this address.', 'easy-digital-downloads' ); ?></p>
</div>
<?php endif; ?>
<?php if ( empty( $customer['first_name'] ) ) : ?>
<?php if ( ! $is_user_logged_in || empty( $customer['first_name'] ) ) : ?>
<div id="edd-first-name-wrap">
<label class="edd-label" for="edd-first">
<?php
Expand All @@ -31,7 +32,7 @@
<p class="edd-description" id="edd-first-description"><?php esc_html_e( 'We will use this to personalize your account experience.', 'easy-digital-downloads' ); ?></p>
</div>
<?php endif; ?>
<?php if ( empty( $customer['last_name'] ) ) : ?>
<?php if ( ! $is_user_logged_in || empty( $customer['last_name'] ) ) : ?>
<div id="edd-last-name-wrap">
<label class="edd-label" for="edd-last">
<?php
Expand Down
8 changes: 4 additions & 4 deletions includes/cart/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function edd_add_rewrite_endpoints( $rewrite_rules ) {
* Process cart endpoints.
*
* @since 1.3.4
*/
*/
function edd_process_cart_endpoints() {
global $wp_query;

Expand Down Expand Up @@ -80,8 +80,8 @@ function edd_process_add_to_cart( $data ) {
}

if ( edd_straight_to_checkout() && ! edd_is_checkout() ) {
$query_args = remove_query_arg( array( 'edd_action', 'download_id', 'edd_options', 'edd_download_quantity' ) );
$query_part = strpos( $query_args, "?" );
$query_args = remove_query_arg( array( 'edd_action', 'download_id', 'edd_options', 'edd_download_quantity' ) );
$query_part = strpos( $query_args, '?' );
$url_parameters = '';

if ( false !== $query_part ) {
Expand Down Expand Up @@ -118,7 +118,7 @@ function edd_process_remove_from_cart( $data ) {
edd_remove_from_cart( $cart_key );
}

edd_redirect( remove_query_arg( array( 'edd_action', 'cart_item', 'nocache' ) ) );
edd_redirect( remove_query_arg( array( 'edd_action', 'cart_item', 'nocache', 'edd_remove_from_cart_nonce' ) ) );
}
add_action( 'edd_remove', 'edd_process_remove_from_cart' );

Expand Down
2 changes: 1 addition & 1 deletion includes/class-easy-digital-downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private function setup_constants() {

// Plugin version.
if ( ! defined( 'EDD_VERSION' ) ) {
define( 'EDD_VERSION', '3.2.5' );
define( 'EDD_VERSION', '3.2.6' );
}

// Make sure CAL_GREGORIAN is defined.
Expand Down
28 changes: 11 additions & 17 deletions includes/class-edd-download.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public function get_prices() {

if ( true === $this->has_variable_prices() ) {
if ( empty( $this->prices ) ) {
$this->prices = get_post_meta( $this->ID, 'edd_variable_prices', true );
$this->prices = array_filter( (array) get_post_meta( $this->ID, 'edd_variable_prices', true ) );
}
}

Expand All @@ -494,7 +494,7 @@ public function get_prices() {
* @param array $prices The array of variables prices.
* @param int|string The ID of the download.
*/
return array_filter( (array) apply_filters( 'edd_get_variable_prices', $this->prices, $this->ID ) );
return (array) apply_filters( 'edd_get_variable_prices', $this->prices, $this->ID );
}

/**
Expand Down Expand Up @@ -676,27 +676,21 @@ public function get_refund_window() {
public function get_refundability() {

if ( ! isset( $this->refundability ) ) {
$default = 'refundable';
$refundable = get_post_meta( $this->ID, '_edd_refundability', true );
$global = edd_get_option( 'refundability', $default );

// Download specific window
if ( ! empty( $refundable ) ) {
$retval = $refundable;

// Use global
} elseif ( ! empty( $global ) ) {
$retval = $global;
// Check the global value first. The default is `refundable`.
$refundability = edd_get_option( 'refundability', 'refundable' );
$meta = get_post_meta( $this->ID, '_edd_refundability', true );

// Default
} else {
$retval = $default;
// The download specific value will override the global.
if ( ! empty( $meta ) ) {
$refundability = $meta;
}

$this->refundability = $retval;
$this->refundability = $refundability;
}

return $this->refundability; // No filter
// This is not filtered.
return $this->refundability;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions includes/class-edd-html-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public function product_dropdown( $args = array() ) {
$args['class'] .= ' variations-only';
}

if ( ! empty( $args['exclude_current'] ) ) {
$args['class'] .= ' exclude-current';
}

// 'all' gets created as an option if passed via the `selected` argument.
if ( isset( $options['all'] ) ) {
unset( $options['all'] );
Expand Down
6 changes: 2 additions & 4 deletions includes/class-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2895,9 +2895,8 @@ private function pre_query( $query = array() ) {
$date_query_sql = ' AND ';

if ( ! empty( $this->query_vars['start'] ) ) {
$start_date = EDD()->utils->date( $this->query_vars['start'], edd_get_timezone_id(), false )->format( 'mysql' );
$date_query_sql .= "{$this->query_vars['table']}.{$this->query_vars['date_query_column']} ";
$date_query_sql .= $this->get_db()->prepare( '>= %s', $start_date );
$date_query_sql .= $this->get_db()->prepare( '>= %s', $this->query_vars['start'] );
}

// Join dates with `AND` if start and end date set.
Expand All @@ -2906,8 +2905,7 @@ private function pre_query( $query = array() ) {
}

if ( ! empty( $this->query_vars['end'] ) ) {
$end_date = EDD()->utils->date( $this->query_vars['end'], edd_get_timezone_id(), false )->format( 'mysql' );
$date_query_sql .= $this->get_db()->prepare( "{$this->query_vars['table']}.{$this->query_vars['date_query_column']} <= %s", $end_date );
$date_query_sql .= $this->get_db()->prepare( "{$this->query_vars['table']}.{$this->query_vars['date_query_column']} <= %s", $this->query_vars['end'] );
}

$this->query_vars['date_query_sql'] = $date_query_sql;
Expand Down
9 changes: 7 additions & 2 deletions includes/database/tables/class-adjustments.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,13 @@ protected function __202102161() {
$this->get_db()->query( "ALTER TABLE {$this->table_name} DROP INDEX code_status_type_scope_amount" );
}

$this->get_db()->query( "ALTER TABLE {$this->table_name} ADD INDEX type_status (type(20), status(20))" );
$this->get_db()->query( "ALTER TABLE {$this->table_name} ADD INDEX code (code)" );
if ( ! $this->index_exists( 'type_status' ) ) {
$this->get_db()->query( "ALTER TABLE {$this->table_name} ADD INDEX type_status (type(20), status(20))" );
}

if ( ! $this->index_exists( 'code' ) ) {
$this->get_db()->query( "ALTER TABLE {$this->table_name} ADD INDEX code (code)" );
}

return true;
}
Expand Down
13 changes: 10 additions & 3 deletions includes/gateways/stripe/includes/i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* @return array $error_list List of error codes and corresponding error messages.
*/
function edds_get_localized_error_messages() {
$generic_different_payment_method = __( 'There was an error processing your payment. Please try with a different payment method.', 'easy-digital-downloads' );
$generic_contact_issuer_message = __( 'There was an error processing your payment. Please contact your card issuer for more information.', 'easy-digital-downloads' );
$generic_different_payment_method = __( 'There was an error processing your payment. Please try with a different payment method.', 'easy-digital-downloads' );
$generic_contact_issuer_message = __( 'There was an error processing your payment. Please contact your card issuer for more information.', 'easy-digital-downloads' );

$error_list = array(
'incomplete' => __( 'Payment processing cancelled; your order is not yet complete.', 'easy-digital-downloads' ),
Expand Down Expand Up @@ -128,7 +128,14 @@ function edds_get_localized_error_message( $error_code, $error_message, $decline
* @return string The translatable string for the single subscription requirement error.
*/
function edds_get_single_subscription_cart_error() {
return esc_html__(
if ( function_exists( 'edd_recurring' ) && edd_recurring()->cart_is_mixed() ) {
return esc_html__(
'Subscriptions and non-subscriptions may not be purchased at the same time. Please purchase each separately.',
'easy-digital-downloads'
);
}

return esc_html__(
'Subscriptions must be purchased individually. Please update your cart to only contain a single subscription.',
'easy-digital-downloads'
);
Expand Down
28 changes: 28 additions & 0 deletions includes/orders/classes/class-order-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,32 @@ public function get_refunded_items() {
public function is_deliverable() {
return in_array( $this->status, edd_get_deliverable_order_item_statuses(), true );
}


/**
* Retrieves the net total for this order item.
*
* @since 3.2.6
* @return float Item net total.
*/
public function get_net_total() {
$net_total = $this->total - floatval( $this->tax );

$net_total = array_reduce(
$this->get_refunded_items(),
function( $total, $refund_item ) {
return $total + $refund_item->total;
},
$net_total
);

/**
* Allow item net total to be filtered.
*
* @since 3.2.6
* @param float $net_total Item net total.
* @param EDD\Orders\Order_Item $this Order item object.
*/
return (float) apply_filters( 'edd_order_item_net_total', $net_total, $this );
}
}
Loading

0 comments on commit 7e68d57

Please sign in to comment.