auto-patch 638-dev-dev01-2024-05-14T20_44_36
This commit is contained in:
@@ -558,7 +558,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||
),
|
||||
),
|
||||
'wccom_connected' => array(
|
||||
'description' => __( 'Is store connected to Woo.com?', 'woocommerce' ),
|
||||
'description' => __( 'Is store connected to WooCommerce.com?', 'woocommerce' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
@@ -569,12 +569,6 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'HPOS_feature_screen_enabled' => array(
|
||||
'description' => __( 'Is HPOS feature screen enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'HPOS_enabled' => array(
|
||||
'description' => __( 'Is HPOS enabled?', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
@@ -855,7 +849,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||
|
||||
if ( false === $get_response_code || is_wp_error( $get_response_code ) ) {
|
||||
$response = wp_safe_remote_get(
|
||||
'https://woo.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ),
|
||||
'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ),
|
||||
array(
|
||||
'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ),
|
||||
)
|
||||
@@ -870,6 +864,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||
}
|
||||
|
||||
$database_version = wc_get_server_database_version();
|
||||
$log_directory = LoggingUtil::get_log_directory();
|
||||
|
||||
// Return all environment info. Described by JSON Schema.
|
||||
return array(
|
||||
@@ -877,8 +872,8 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||
'site_url' => get_option( 'siteurl' ),
|
||||
'store_id' => get_option( \WC_Install::STORE_ID_OPTION, null ),
|
||||
'version' => WC()->version,
|
||||
'log_directory' => WC_LOG_DIR,
|
||||
'log_directory_writable' => (bool) @fopen( WC_LOG_DIR . 'test-log.log', 'a' ), // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen
|
||||
'log_directory' => $log_directory,
|
||||
'log_directory_writable' => wp_is_writable( $log_directory ),
|
||||
'wp_version' => get_bloginfo( 'version' ),
|
||||
'wp_multisite' => is_multisite(),
|
||||
'wp_memory_limit' => $wp_memory_limit,
|
||||
@@ -1069,7 +1064,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of inplugins active on the site.
|
||||
* Get a list of inactive plugins.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -1348,7 +1343,6 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||
'woocommerce_com_connected' => ConnectionHelper::is_connected() ? 'yes' : 'no',
|
||||
'enforce_approved_download_dirs' => wc_get_container()->get( Download_Directories::class )->get_mode() === Download_Directories::MODE_ENABLED,
|
||||
'order_datastore' => WC_Data_Store::load( 'order' )->get_current_class_name(),
|
||||
'HPOS_feature_screen_enabled' => wc_get_container()->get( Automattic\WooCommerce\Internal\Features\FeaturesController::class )->feature_is_enabled( 'custom_order_tables' ),
|
||||
'HPOS_enabled' => OrderUtil::custom_orders_table_usage_is_enabled(),
|
||||
'HPOS_sync_enabled' => wc_get_container()->get( Order_DataSynchronizer::class )->data_sync_is_enabled(),
|
||||
);
|
||||
|
||||
@@ -1121,8 +1121,9 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
||||
$response = array();
|
||||
$product = wc_get_product( $product_id );
|
||||
$default_values = isset( $request['default_values'] ) ? $request['default_values'] : array();
|
||||
$meta_data = isset( $request['meta_data'] ) ? $request['meta_data'] : array();
|
||||
$data_store = $product->get_data_store();
|
||||
$response['count'] = $data_store->create_all_product_variations( $product, Constants::get_constant( 'WC_MAX_LINKED_VARIATIONS' ), $default_values );
|
||||
$response['count'] = $data_store->create_all_product_variations( $product, Constants::get_constant( 'WC_MAX_LINKED_VARIATIONS' ), $default_values, $meta_data );
|
||||
|
||||
if ( isset( $request['delete'] ) && $request['delete'] ) {
|
||||
$deleted_count = $this->delete_unmatched_product_variations( $product );
|
||||
|
||||
@@ -62,6 +62,54 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<id>[\d]+)/duplicate',
|
||||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array( $this, 'duplicate_product' ),
|
||||
'permission_callback' => array( $this, 'create_item_permissions_check' ),
|
||||
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate a product and returns the duplicated product.
|
||||
* The product status is set to "draft" and the name includes a "(copy)" at the end by default.
|
||||
*
|
||||
* @param WP_REST_Request $request Request data.
|
||||
* @return WP_REST_Response|WP_Error
|
||||
*/
|
||||
public function duplicate_product( $request ) {
|
||||
$product_id = $request->get_param( 'id' );
|
||||
$product = wc_get_product( $product_id );
|
||||
|
||||
if ( ! $product ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
// Creating product object from request data in preparation for copying.
|
||||
$updated_product = $this->prepare_object_for_database( $request );
|
||||
$duplicated_product = ( new WC_Admin_Duplicate_Product() )->product_duplicate( $updated_product );
|
||||
|
||||
if ( is_wp_error( $duplicated_product ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_duplicate_error', $duplicated_product->get_error_message(), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$response_data = $duplicated_product->get_data();
|
||||
|
||||
return new WP_REST_Response( $response_data, 200 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,7 +373,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
||||
global $wpdb;
|
||||
if ( ! empty( $this->search_sku_in_product_lookup_table ) ) {
|
||||
$like_search = '%' . $wpdb->esc_like( $this->search_sku_in_product_lookup_table ) . '%';
|
||||
$where .= ' AND ' . $wpdb->prepare( '(wc_product_meta_lookup.sku LIKE %s)', $like_search );
|
||||
$where .= ' AND ' . $wpdb->prepare( '(wc_product_meta_lookup.sku LIKE %s)', $like_search );
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
@@ -1112,7 +1160,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'low_stock_amount' => array(
|
||||
'low_stock_amount' => array(
|
||||
'description' => __( 'Low Stock amount for the product.', 'woocommerce' ),
|
||||
'type' => array( 'integer', 'null' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
@@ -1344,7 +1392,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
|
||||
),
|
||||
),
|
||||
),
|
||||
'has_options' => array(
|
||||
'has_options' => array(
|
||||
'description' => __( 'Shows if the product needs to be configured before it can be bought.', 'woocommerce' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
* @since 3.5.0
|
||||
*/
|
||||
|
||||
use Automattic\WooCommerce\Utilities\OrderUtil;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
@@ -39,18 +41,18 @@ class WC_REST_Report_Orders_Totals_Controller extends WC_REST_Reports_Controller
|
||||
* @return array
|
||||
*/
|
||||
protected function get_reports() {
|
||||
$totals = wp_count_posts( 'shop_order' );
|
||||
$totals = OrderUtil::get_count_for_type( 'shop_order' );
|
||||
$data = array();
|
||||
|
||||
foreach ( wc_get_order_statuses() as $slug => $name ) {
|
||||
if ( ! isset( $totals->$slug ) ) {
|
||||
if ( ! array_key_exists( $slug, $totals ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[] = array(
|
||||
'slug' => str_replace( 'wc-', '', $slug ),
|
||||
'name' => $name,
|
||||
'total' => (int) $totals->$slug,
|
||||
'total' => (int) $totals[ $slug ],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user