Plugin Updates

This commit is contained in:
Tony Volpe
2024-04-02 20:23:21 +00:00
parent 96800520e8
commit 94170ec2c4
1514 changed files with 133309 additions and 105985 deletions

View File

@@ -321,9 +321,9 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
$coupon_line = array(
'id' => $coupon_item_id,
'code' => $coupon_item['name'],
'discount' => wc_format_decimal( $coupon_item['discount_amount'], $dp ),
'discount_tax' => wc_format_decimal( $coupon_item['discount_amount_tax'], $dp ),
'code' => $coupon_item->get_name(),
'discount' => wc_format_decimal( $coupon_item->get_discount(), $dp ),
'discount_tax' => wc_format_decimal( $coupon_item->get_discount_tax(), $dp ),
);
$data['coupon_lines'][] = $coupon_line;

View File

@@ -289,6 +289,25 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller {
);
}
// Add additional applied coupon information.
if ( $item instanceof WC_Order_Item_Coupon ) {
$temp_coupon = new WC_Coupon();
$coupon_info = $item->get_meta( 'coupon_info', true );
if ( $coupon_info ) {
$temp_coupon->set_short_info( $coupon_info );
} else {
$coupon_meta = $item->get_meta( 'coupon_data', true );
if ( $coupon_meta ) {
$temp_coupon->set_props( (array) $coupon_meta );
}
}
$data['discount_type'] = $temp_coupon->get_discount_type();
$data['nominal_amount'] = (float) $temp_coupon->get_amount();
$data['free_shipping'] = $temp_coupon->get_free_shipping();
}
$data['meta_data'] = array_map(
array( $this, 'merge_meta_item_with_formatted_meta_display_attributes' ),
$data['meta_data'],
@@ -1849,29 +1868,47 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller {
'items' => array(
'type' => 'object',
'properties' => array(
'id' => array(
'id' => array(
'description' => __( 'Item ID.', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'code' => array(
'code' => array(
'description' => __( 'Coupon code.', 'woocommerce' ),
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'discount' => array(
'discount' => array(
'description' => __( 'Discount total.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'discount_tax' => array(
'discount_tax' => array(
'description' => __( 'Discount total tax.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'meta_data' => array(
'discount_type' => array(
'description' => __( 'Discount type.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
'readonly' => true,
),
'nominal_amount' => array(
'description' => __( 'Discount amount as defined in the coupon (absolute value or a percent, depending on the discount type).', 'woocommerce' ),
'type' => 'number',
'context' => array( 'view' ),
'readonly' => true,
),
'free_shipping' => array(
'description' => __( 'Whether the coupon grants free shipping or not.', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view' ),
'readonly' => true,
),
'meta_data' => array(
'description' => __( 'Meta data.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),

View File

@@ -13,7 +13,8 @@ defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Internal\WCCom\ConnectionHelper;
use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Register as Download_Directories;
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer as Order_DataSynchronizer;
use Automattic\WooCommerce\Utilities\OrderUtil;
use Automattic\WooCommerce\Utilities\{ LoggingUtil, OrderUtil };
/**
* System status controller class.
*
@@ -632,6 +633,44 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
'type' => 'string',
),
),
'logging' => array(
'description' => __( 'Logging.', 'woocommerce' ),
'type' => 'object',
'context' => array( 'view' ),
'readonly' => true,
'properties' => array(
'logging_enabled' => array(
'description' => __( 'Is logging enabled?', 'woocommerce' ),
'type' => 'boolean',
'context' => array( 'view' ),
'readonly' => true,
),
'default_handler' => array(
'description' => __( 'The logging handler class.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
'readonly' => true,
),
'retention_period_days' => array(
'description' => __( 'The number of days log entries are retained.', 'woocommerce' ),
'type' => 'integer',
'context' => array( 'view' ),
'readonly' => true,
),
'level_threshold' => array(
'description' => __( 'Minimum severity level.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
'readonly' => true,
),
'log_directory_size' => array(
'description' => __( 'The size of the log directory.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view' ),
'readonly' => true,
),
),
),
),
);
@@ -646,7 +685,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
*/
public function get_item_mappings() {
return array(
'environment' => $this->get_environment_info(),
'environment' => $this->get_environment_info_per_fields( array( 'environment' ) ),
'database' => $this->get_database_info(),
'active_plugins' => $this->get_active_plugins(),
'inactive_plugins' => $this->get_inactive_plugins(),
@@ -656,6 +695,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
'security' => $this->get_security_info(),
'pages' => $this->get_pages(),
'post_type_counts' => $this->get_post_type_counts(),
'logging' => $this->get_logging_info(),
);
}
@@ -704,6 +744,9 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
case 'post_type_counts':
$items['post_type_counts'] = $this->get_post_type_counts();
break;
case 'logging':
$items['logging'] = $this->get_logging_info();
break;
}
}
@@ -1421,6 +1464,21 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
return $pages_output;
}
/**
* Get info about the logging system.
*
* @return array
*/
protected function get_logging_info() {
return array(
'logging_enabled' => LoggingUtil::logging_is_enabled(),
'default_handler' => LoggingUtil::get_default_handler(),
'retention_period_days' => LoggingUtil::get_retention_period(),
'level_threshold' => WC_Log_Levels::get_level_label( strtolower( LoggingUtil::get_level_threshold() ) ),
'log_directory_size' => size_format( LoggingUtil::get_log_directory_size() ),
);
}
/**
* Get any query params needed.
*

View File

@@ -65,6 +65,30 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
);
}
/**
* Get the downloads for a product variation.
*
* @param WC_Product_Variation $product Product variation instance.
* @param string $context Context of the request: 'view' or 'edit'.
*
* @return array
*/
protected function get_downloads( $product, $context = 'view' ) {
$downloads = array();
if ( $product->is_downloadable() || 'edit' === $context ) {
foreach ( $product->get_downloads() as $file_id => $file ) {
$downloads[] = array(
'id' => $file_id, // MD5 hash.
'name' => $file['name'],
'file' => $file['file'],
);
}
}
return $downloads;
}
/**
* Prepare a single variation output for response.
*
@@ -95,7 +119,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
'purchasable' => $object->is_purchasable(),
'virtual' => $object->is_virtual(),
'downloadable' => $object->is_downloadable(),
'downloads' => $this->get_downloads( $object ),
'downloads' => $this->get_downloads( $object, $context ),
'download_limit' => '' !== $object->get_download_limit() ? (int) $object->get_download_limit() : -1,
'download_expiry' => '' !== $object->get_download_expiry() ? (int) $object->get_download_expiry() : -1,
'tax_status' => $object->get_tax_status(),