Merge remote-tracking branch 'origin/master'

This commit is contained in:
Mike Jolley 2016-05-31 11:04:21 +01:00
commit 19c6b0fead
18 changed files with 105 additions and 47 deletions

View File

@ -90,6 +90,18 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
if ( ! empty( $items['create'] ) ) {
foreach ( $items['create'] as $item ) {
$_item = new WP_REST_Request( 'POST' );
// Default parameters.
$defaults = array();
$schema = $this->get_public_item_schema();
foreach ( $schema['properties'] as $arg => $options ) {
if ( isset( $options['default'] ) ) {
$defaults[ $arg ] = $options['default'];
}
}
$_item->set_default_params( $defaults );
// Set request parameters.
$_item->set_body_params( $item );
$_response = $this->create_item( $_item );

View File

@ -666,12 +666,6 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
);
}
$params['slug'] = array(
'description' => __( 'Limit result set to posts with a specific slug.', 'woocommerce', 'woocommerce' ),
'type' => 'string',
'validate_callback' => 'rest_validate_request_arg',
);
$params['filter'] = array(
'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ),
);

View File

@ -188,7 +188,7 @@ class WC_Meta_Box_Order_Data {
}
if ( $ip_address = get_post_meta( $post->ID, '_customer_ip_address', true ) ) {
echo __( 'Customer IP', 'woocommerce' ) . ': <span class="customer_ip">' . esc_html( $ip_address ) . '</span>';
echo __( 'Customer IP', 'woocommerce' ) . ': <span class="woocommerce-Order-customerIP customer-ip">' . esc_html( $ip_address ) . '</span>';
}
?></p>

View File

@ -66,11 +66,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'create_item' ),
'permission_callback' => array( $this, 'create_item_permissions_check' ),
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
'email' => array(
'required' => true,
),
) ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
@ -364,7 +360,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ),
),
'reason' => array(
'description' => __( 'Reason for refund', 'woocommerce' ),
'description' => __( 'Reason for refund.', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
@ -408,7 +404,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
),
'tax_class' => array(
'description' => __( 'Tax class of product.', 'woocommerce' ),
'type' => 'integer',
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
@ -439,7 +435,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ),
),
'taxes' => array(
'description' => __( 'Line total tax.', 'woocommerce' ),
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'readonly' => true,

View File

@ -151,7 +151,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'customer_user_agent' => $order->customer_user_agent,
'created_via' => $order->created_via,
'customer_note' => $order->customer_note,
'date_completed' => wc_rest_prepare_date_response( $order->completed_date, true ),
'date_completed' => wc_rest_prepare_date_response( $order->completed_date ),
'date_paid' => $order->paid_date,
'cart_hash' => $order->cart_hash,
'line_items' => array(),
@ -546,10 +546,10 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
throw new WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 );
}
if ( ! empty( $item['product_id'] ) ) {
$product_id = (int) $item['product_id'];
} else if ( ! empty( $item['sku'] ) ) {
if ( ! empty( $item['sku'] ) ) {
$product_id = (int) wc_get_product_id_by_sku( $item['sku'] );
} elseif ( ! empty( $item['product_id'] ) && empty( $item['variation_id'] ) ) {
$product_id = (int) $item['product_id'];
} elseif ( ! empty( $item['variation_id'] ) ) {
$product_id = (int) $item['variation_id'];
}
@ -1316,12 +1316,11 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ),
'type' => 'boolean',
'default' => false,
'context' => array( 'view', 'edit' ),
'writeonly' => true,
'context' => array( 'edit' ),
),
'transaction_id' => array(
'description' => __( 'Unique transaction ID.', 'woocommerce' ),
'type' => 'boolean',
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'customer_ip_address' => array(
@ -1361,7 +1360,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'cart_hash' => array(
'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ),
'type' => 'float',
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
@ -1378,7 +1377,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'name' => array(
'description' => __( 'Product name.', 'woocommerce' ),
'type' => 'integer',
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
@ -1436,7 +1435,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ),
),
'taxes' => array(
'description' => __( 'Line total tax.', 'woocommerce' ),
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'readonly' => true,
@ -1557,7 +1556,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
),
'method_id' => array(
'description' => __( 'Shipping method ID.', 'woocommerce' ),
'type' => 'integer',
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
'total' => array(
@ -1572,7 +1571,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'readonly' => true,
),
'taxes' => array(
'description' => __( 'Line total tax.', 'woocommerce' ),
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'readonly' => true,
@ -1620,7 +1619,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ),
),
'total' => array(
'description' => __( 'Line total tax (after discounts).', 'woocommerce' ),
'description' => __( 'Line total (after discounts).', 'woocommerce' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
@ -1630,7 +1629,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
'context' => array( 'view', 'edit' ),
),
'taxes' => array(
'description' => __( 'Line total tax.', 'woocommerce' ),
'description' => __( 'Line taxes.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'readonly' => true,

View File

@ -2509,6 +2509,11 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
public function get_collection_params() {
$params = parent::get_collection_params();
$params['slug'] = array(
'description' => __( 'Limit result set to posts with a specific slug.', 'woocommerce', 'woocommerce' ),
'type' => 'string',
'validate_callback' => 'rest_validate_request_arg',
);
$params['status'] = array(
'default' => 'any',
'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce' ),

View File

@ -520,7 +520,6 @@ class WC_REST_Webhooks_Controller extends WC_REST_Posts_Controller {
'type' => 'string',
'format' => 'uri',
'context' => array( 'edit' ),
'writeonly' => true,
),
'date_created' => array(
'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ),

View File

@ -2091,6 +2091,16 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
}
}
if ( ! function_exists( 'woocommerce_account_navigation' ) ) {
/**
* My Account navigation template.
*/
function woocommerce_account_navigation() {
wc_get_template( 'myaccount/navigation.php' );
}
}
if ( ! function_exists( 'woocommerce_account_orders' ) ) {
/**

View File

@ -256,6 +256,7 @@ add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' );
/**
* My Account.
*/
add_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' );
add_action( 'woocommerce_account_view-order_endpoint', 'woocommerce_account_view_order' );
add_action( 'woocommerce_account_downloads_endpoint', 'woocommerce_account_downloads' );

View File

@ -25,9 +25,14 @@ if ( ! defined( 'ABSPATH' ) ) {
$downloads = WC()->customer->get_downloadable_products();
$has_downloads = (bool) $downloads;
wc_print_notices(); ?>
wc_print_notices();
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">

View File

@ -20,7 +20,12 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wc_get_template( 'myaccount/navigation.php' ); ?>
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">
<?php if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) : ?>

View File

@ -22,7 +22,12 @@ if ( ! defined( 'ABSPATH' ) ) {
wc_print_notices();
wc_get_template( 'myaccount/navigation.php' ); ?>
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">

View File

@ -24,7 +24,12 @@ $page_title = ( $load_address === 'billing' ) ? __( 'Billing Address', 'woocomme
wc_print_notices();
wc_get_template( 'myaccount/navigation.php' ); ?>
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">

View File

@ -20,9 +20,14 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wc_print_notices(); ?>
wc_print_notices();
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">
<p>

View File

@ -23,7 +23,13 @@ if ( ! defined( 'ABSPATH' ) ) {
}
wc_print_notices();
wc_get_template( 'myaccount/navigation.php' ); ?>
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">

View File

@ -25,9 +25,15 @@ if ( ! defined( 'ABSPATH' ) ) {
$saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() );
$has_methods = (bool) $saved_methods;
$types = wc_get_account_payment_methods_types();
wc_print_notices(); ?>
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
wc_print_notices();
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">

View File

@ -22,9 +22,14 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wc_print_notices(); ?>
wc_print_notices();
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
/**
* My Account navigation.
*
* @since 2.6.0
*/
do_action( 'woocommerce_account_navigation' ); ?>
<div class="woocommerce-MyAccount-content">
<p><?php