Merged branch master into Generic.ControlStructures.InlineControlStructure.NotAllowed

This commit is contained in:
Aristeides Stathopoulos 2017-03-07 20:29:06 +02:00
commit 694f11f91f
6 changed files with 50 additions and 33 deletions

View File

@ -67,39 +67,42 @@ class WC_Meta_Box_Coupon_Data {
// Type // Type
woocommerce_wp_select( array( woocommerce_wp_select( array(
'id' => 'discount_type', 'id' => 'discount_type',
'label' => __( 'Discount type', 'woocommerce' ), 'label' => __( 'Discount type', 'woocommerce' ),
'options' => wc_get_coupon_types() 'options' => wc_get_coupon_types(),
) ); ) );
// Amount // Amount
woocommerce_wp_text_input( array( woocommerce_wp_text_input( array(
'id' => 'coupon_amount', 'id' => 'coupon_amount',
'label' => __( 'Coupon amount', 'woocommerce' ), 'label' => __( 'Coupon amount', 'woocommerce' ),
'placeholder' => wc_format_localized_price( 0 ), 'placeholder' => wc_format_localized_price( 0 ),
'description' => __( 'Value of the coupon.', 'woocommerce' ), 'description' => __( 'Value of the coupon.', 'woocommerce' ),
'data_type' => 'price', 'data_type' => 'price',
'desc_tip' => true 'desc_tip' => true,
) ); ) );
// Free Shipping // Free Shipping
if ( wc_shipping_enabled() ) { if ( wc_shipping_enabled() ) {
woocommerce_wp_checkbox( array( woocommerce_wp_checkbox( array(
'id' => 'free_shipping', 'id' => 'free_shipping',
'label' => __( 'Allow free shipping', 'woocommerce' ), 'label' => __( 'Allow free shipping', 'woocommerce' ),
'description' => sprintf( __( 'Check this box if the coupon grants free shipping. A <a href="%s" target="_blank">free shipping method</a> must be enabled in your shipping zone and be set to require "a valid free shipping coupon" (see the "Free Shipping Requires" setting).', 'woocommerce' ), 'https://docs.woocommerce.com/document/free-shipping/' ) 'description' => sprintf( __( 'Check this box if the coupon grants free shipping. A <a href="%s" target="_blank">free shipping method</a> must be enabled in your shipping zone and be set to require "a valid free shipping coupon" (see the "Free Shipping Requires" setting).', 'woocommerce' ), 'https://docs.woocommerce.com/document/free-shipping/' ),
) ); ) );
} }
// Expiry date // Expiry date
$expiry_date = $coupon->get_date_expires() ? date( 'Y-m-d', $coupon->get_date_expires() ) : ''; $expiry_date = $coupon->get_date_expires() ? date( 'Y-m-d', $coupon->get_date_expires() ) : '';
woocommerce_wp_text_input( array( woocommerce_wp_text_input( array(
'id' => 'expiry_date', 'id' => 'expiry_date',
'value' => esc_attr( $expiry_date ), 'value' => esc_attr( $expiry_date ),
'label' => __( 'Coupon expiry date', 'woocommerce' ), 'label' => __( 'Coupon expiry date', 'woocommerce' ),
'placeholder' => 'YYYY-MM-DD', 'description' => '', 'placeholder' => 'YYYY-MM-DD',
'class' => 'date-picker', 'description' => '',
'custom_attributes' => array( 'pattern' => apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) 'class' => 'date-picker',
'custom_attributes' => array(
'pattern' => apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ),
),
) ); ) );
do_action( 'woocommerce_coupon_options', $coupon->get_id(), $coupon ); do_action( 'woocommerce_coupon_options', $coupon->get_id(), $coupon );
@ -111,34 +114,36 @@ class WC_Meta_Box_Coupon_Data {
// minimum spend // minimum spend
woocommerce_wp_text_input( array( woocommerce_wp_text_input( array(
'id' => 'minimum_amount', 'id' => 'minimum_amount',
'label' => __( 'Minimum spend', 'woocommerce' ), 'label' => __( 'Minimum spend', 'woocommerce' ),
'placeholder' => __( 'No minimum', 'woocommerce' ), 'placeholder' => __( 'No minimum', 'woocommerce' ),
'description' => __( 'This field allows you to set the minimum spend (subtotal, including taxes) allowed to use the coupon.', 'woocommerce' ), 'description' => __( 'This field allows you to set the minimum spend (subtotal, including taxes) allowed to use the coupon.', 'woocommerce' ),
'data_type' => 'price', 'desc_tip' => true 'data_type' => 'price',
'desc_tip' => true,
) ); ) );
// maximum spend // maximum spend
woocommerce_wp_text_input( array( woocommerce_wp_text_input( array(
'id' => 'maximum_amount', 'id' => 'maximum_amount',
'label' => __( 'Maximum spend', 'woocommerce' ), 'label' => __( 'Maximum spend', 'woocommerce' ),
'placeholder' => __( 'No maximum', 'woocommerce' ), 'placeholder' => __( 'No maximum', 'woocommerce' ),
'description' => __( 'This field allows you to set the maximum spend (subtotal, including taxes) allowed when using the coupon.', 'woocommerce' ), 'description' => __( 'This field allows you to set the maximum spend (subtotal, including taxes) allowed when using the coupon.', 'woocommerce' ),
'data_type' => 'price', 'desc_tip' => true 'data_type' => 'price',
'desc_tip' => true,
) ); ) );
// Individual use // Individual use
woocommerce_wp_checkbox( array( woocommerce_wp_checkbox( array(
'id' => 'individual_use', 'id' => 'individual_use',
'label' => __( 'Individual use only', 'woocommerce' ), 'label' => __( 'Individual use only', 'woocommerce' ),
'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' ) 'description' => __( 'Check this box if the coupon cannot be used in conjunction with other coupons.', 'woocommerce' ),
) ); ) );
// Exclude Sale Products // Exclude Sale Products
woocommerce_wp_checkbox( array( woocommerce_wp_checkbox( array(
'id' => 'exclude_sale_items', 'id' => 'exclude_sale_items',
'label' => __( 'Exclude sale items', 'woocommerce' ), 'label' => __( 'Exclude sale items', 'woocommerce' ),
'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are no sale items in the cart.', 'woocommerce' ) 'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are no sale items in the cart.', 'woocommerce' ),
) ); ) );
echo '</div><div class="options_group">'; echo '</div><div class="options_group">';

View File

@ -260,10 +260,14 @@ class WC_API_Products extends WC_API_Resource {
* Get standard product data that applies to every product type * Get standard product data that applies to every product type
* *
* @since 2.1 * @since 2.1
* @param WC_Product $product * @param WC_Product|int $product
* @return array * @return array
*/ */
private function get_product_data( $product ) { private function get_product_data( $product ) {
if ( is_numeric( $product ) ) {
$product = wc_get_product( $product );
}
return array( return array(
'title' => $product->get_name(), 'title' => $product->get_name(),
'id' => $product->get_id(), 'id' => $product->get_id(),

View File

@ -676,10 +676,14 @@ class WC_API_Products extends WC_API_Resource {
* Get standard product data that applies to every product type * Get standard product data that applies to every product type
* *
* @since 2.1 * @since 2.1
* @param WC_Product $product * @param WC_Product|int $product
* @return WC_Product * @return WC_Product
*/ */
private function get_product_data( $product ) { private function get_product_data( $product ) {
if ( is_numeric( $product ) ) {
$product = wc_get_product( $product );
}
$prices_precision = wc_get_price_decimals(); $prices_precision = wc_get_price_decimals();
return array( return array(
'title' => $product->get_name(), 'title' => $product->get_name(),

View File

@ -1122,10 +1122,14 @@ class WC_API_Products extends WC_API_Resource {
* Get standard product data that applies to every product type * Get standard product data that applies to every product type
* *
* @since 2.1 * @since 2.1
* @param WC_Product $product * @param WC_Product|int $product
* @return WC_Product * @return WC_Product
*/ */
private function get_product_data( $product ) { private function get_product_data( $product ) {
if ( is_numeric( $product ) ) {
$product = wc_get_product( $product );
}
return array( return array(
'title' => $product->get_name(), 'title' => $product->get_name(),
'id' => $product->get_id(), 'id' => $product->get_id(),

View File

@ -55,7 +55,7 @@ class WC_CLI_Runner {
// Loop through all of our endpoints and register any valid WC endpoints. // Loop through all of our endpoints and register any valid WC endpoints.
foreach ( $response_data['routes'] as $route => $route_data ) { foreach ( $response_data['routes'] as $route => $route_data ) {
// Only register endpoints for WC and our target version. // Only register endpoints for WC and our target version.
if ( '/wc/' . self::$target_rest_version !== substr( $route, 0, 4 + strlen( self::$target_rest_version ) ) ) { if ( substr( $route, 0, 4 + strlen( self::$target_rest_version ) ) !== '/wc/' . self::$target_rest_version ) {
continue; continue;
} }

View File

@ -72,7 +72,7 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
/** /**
* If a variation title is not in sync with the parent e.g. saved prior to 2.7, or if the parent title has changed, detect here and update. * If a variation title is not in sync with the parent e.g. saved prior to 2.7, or if the parent title has changed, detect here and update.
*/ */
if ( version_compare( get_post_meta( $product->get_id(), '_product_version', true ), '2.7', '<' ) && 0 !== strpos( $post_object->post_title, get_post_field( 'post_title', $product->get_parent_id() ) ) ) { if ( version_compare( get_post_meta( $product->get_id(), '_product_version', true ), '2.7', '<' ) && 0 !== strpos( $post_object->post_title, get_post_field( 'post_title', $product->get_parent_id() ) ) ) {
$new_title = $this->generate_product_title( $product ); $new_title = $this->generate_product_title( $product );
$product->set_name( $new_title ); $product->set_name( $new_title );
wp_update_post( array( wp_update_post( array(