Merge branch 'master' into feature/network-order-widget
This commit is contained in:
commit
bd9ebdf5b1
|
@ -179,7 +179,7 @@ class WC_Admin_Profile {
|
|||
<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
|
||||
<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> />
|
||||
<?php elseif ( ! empty( $field['type'] ) && 'button' === $field['type'] ) : ?>
|
||||
<button id="<?php echo esc_attr( $key ); ?>" class="button <?php echo esc_attr( $field['class'] ); ?>"><?php echo esc_html( $field['text'] ); ?></button>
|
||||
<button type="button" id="<?php echo esc_attr( $key ); ?>" class="button <?php echo esc_attr( $field['class'] ); ?>"><?php echo esc_html( $field['text'] ); ?></button>
|
||||
<?php else : ?>
|
||||
<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -132,7 +132,7 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
|
|||
* Render columm: thumb.
|
||||
*/
|
||||
protected function render_thumb_column() {
|
||||
echo '<a href="' . esc_url( get_edit_post_link( $this->object->get_id() ) ) . '">' . wp_kses_post( $this->object->get_image( 'thumbnail' ) ) . '</a>';
|
||||
echo '<a href="' . esc_url( get_edit_post_link( $this->object->get_id() ) ) . '">' . $this->object->get_image( 'thumbnail' ) . '</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,7 +117,7 @@ class WC_Meta_Box_Coupon_Data {
|
|||
'id' => 'minimum_amount',
|
||||
'label' => __( 'Minimum spend', '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) allowed to use the coupon.', 'woocommerce' ),
|
||||
'data_type' => 'price',
|
||||
'desc_tip' => true,
|
||||
) );
|
||||
|
@ -127,7 +127,7 @@ class WC_Meta_Box_Coupon_Data {
|
|||
'id' => 'maximum_amount',
|
||||
'label' => __( 'Maximum spend', '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) allowed when using the coupon.', 'woocommerce' ),
|
||||
'data_type' => 'price',
|
||||
'desc_tip' => true,
|
||||
) );
|
||||
|
|
|
@ -18,7 +18,7 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
|
|||
</td>
|
||||
<td class="name" data-sort-value="<?php echo esc_attr( $item->get_name() ); ?>">
|
||||
<?php
|
||||
echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</a>' : '<div class=""wc-order-item-name">' . esc_html( $item->get_name() ) . '</div>';
|
||||
echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</a>' : '<div class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</div>';
|
||||
|
||||
if ( $product && $product->get_sku() ) {
|
||||
echo '<div class="wc-order-item-sku"><strong>' . __( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>';
|
||||
|
|
|
@ -1917,6 +1917,9 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
|
|||
'description' => __( 'List of available term names of the attribute.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -613,8 +613,7 @@ class WC_Discounts {
|
|||
* @return bool
|
||||
*/
|
||||
protected function validate_coupon_minimum_amount( $coupon ) {
|
||||
$subtotal = wc_remove_number_precision( array_sum( wp_list_pluck( $this->items, 'price' ) ) );
|
||||
|
||||
$subtotal = wc_remove_number_precision( $this->get_object_subtotal() );
|
||||
if ( $coupon->get_minimum_amount() > 0 && apply_filters( 'woocommerce_coupon_validate_minimum_amount', $coupon->get_minimum_amount() > $subtotal, $coupon, $subtotal ) ) {
|
||||
/* translators: %s: coupon minimum amount */
|
||||
throw new Exception( sprintf( __( 'The minimum spend for this coupon is %s.', 'woocommerce' ), wc_price( $coupon->get_minimum_amount() ) ), 108 );
|
||||
|
@ -632,8 +631,7 @@ class WC_Discounts {
|
|||
* @return bool
|
||||
*/
|
||||
protected function validate_coupon_maximum_amount( $coupon ) {
|
||||
$subtotal = wc_remove_number_precision( array_sum( wp_list_pluck( $this->items, 'price' ) ) );
|
||||
|
||||
$subtotal = wc_remove_number_precision( $this->get_object_subtotal() );
|
||||
if ( $coupon->get_maximum_amount() > 0 && apply_filters( 'woocommerce_coupon_validate_maximum_amount', $coupon->get_maximum_amount() < $subtotal, $coupon ) ) {
|
||||
/* translators: %s: coupon maximum amount */
|
||||
throw new Exception( sprintf( __( 'The maximum spend for this coupon is %s.', 'woocommerce' ), wc_price( $coupon->get_maximum_amount() ) ), 112 );
|
||||
|
@ -847,6 +845,21 @@ class WC_Discounts {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object subtotal
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get_object_subtotal() {
|
||||
if ( is_a( $this->object, 'WC_Cart' ) ) {
|
||||
return wc_add_number_precision( $this->object->get_displayed_subtotal() );
|
||||
} elseif ( is_a( $this->object, 'WC_Order' ) ) {
|
||||
return wc_add_number_precision( $this->object->get_subtotal() );
|
||||
} else {
|
||||
return array_sum( wp_list_pluck( $this->items, 'price' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a coupon is valid.
|
||||
*
|
||||
|
|
|
@ -57,6 +57,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
|
|||
'shipping_company',
|
||||
'wptests_capabilities',
|
||||
'wptests_user_level',
|
||||
'syntax_highlighting',
|
||||
'_order_count',
|
||||
'_money_spent',
|
||||
);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @author Automattic
|
||||
* @category Shortcodes
|
||||
* @package WooCommerce/Shortcodes
|
||||
* @version 3.2.0
|
||||
* @version 3.2.4
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
@ -195,7 +195,12 @@ class WC_Shortcode_Products {
|
|||
// Categories.
|
||||
$this->set_categories_query_args( $query_args );
|
||||
|
||||
return apply_filters( 'woocommerce_shortcode_products_query', $query_args, $this->attributes, $this->type );
|
||||
$query_args = apply_filters( 'woocommerce_shortcode_products_query', $query_args, $this->attributes, $this->type );
|
||||
|
||||
// Always query only IDs.
|
||||
$query_args['fields'] = 'ids';
|
||||
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -450,16 +455,16 @@ class WC_Shortcode_Products {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get products.
|
||||
* Get products IDs.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return WP_Query
|
||||
* @since 3.2.4
|
||||
* @return array
|
||||
*/
|
||||
protected function get_products() {
|
||||
protected function get_products_ids() {
|
||||
$transient_name = $this->get_transient_name();
|
||||
$products = get_transient( $transient_name );
|
||||
$ids = get_transient( $transient_name );
|
||||
|
||||
if ( false === $products || ! is_a( $products, 'WP_Query' ) ) {
|
||||
if ( false === $ids ) {
|
||||
if ( 'top_rated_products' === $this->type ) {
|
||||
add_filter( 'posts_clauses', array( __CLASS__, 'order_by_rating_post_clauses' ) );
|
||||
$products = new WP_Query( $this->query_args );
|
||||
|
@ -468,7 +473,9 @@ class WC_Shortcode_Products {
|
|||
$products = new WP_Query( $this->query_args );
|
||||
}
|
||||
|
||||
set_transient( $transient_name, $products, DAY_IN_SECONDS * 30 );
|
||||
$ids = wp_parse_id_list( $products->posts );
|
||||
|
||||
set_transient( $transient_name, $ids, DAY_IN_SECONDS * 30 );
|
||||
}
|
||||
|
||||
// Remove ordering query arguments.
|
||||
|
@ -476,7 +483,7 @@ class WC_Shortcode_Products {
|
|||
WC()->query->remove_ordering_args();
|
||||
}
|
||||
|
||||
return $products;
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -492,20 +499,23 @@ class WC_Shortcode_Products {
|
|||
$classes = $this->get_wrapper_classes( $columns );
|
||||
$woocommerce_loop['columns'] = $columns;
|
||||
$woocommerce_loop['name'] = $this->type;
|
||||
$products = $this->get_products();
|
||||
$products_ids = $this->get_products_ids();
|
||||
|
||||
ob_start();
|
||||
|
||||
if ( $products->have_posts() ) {
|
||||
// Prime caches before grabbing objects.
|
||||
update_post_caches( $products->posts, array( 'product', 'product_variation' ) );
|
||||
if ( $products_ids ) {
|
||||
// Prime meta cache to reduce future queries.
|
||||
update_meta_cache( 'post', $products_ids );
|
||||
update_object_term_cache( $products_ids, 'product' );
|
||||
|
||||
do_action( "woocommerce_shortcode_before_{$this->type}_loop", $this->attributes );
|
||||
|
||||
woocommerce_product_loop_start();
|
||||
|
||||
while ( $products->have_posts() ) {
|
||||
$products->the_post();
|
||||
foreach ( $products_ids as $product_id ) {
|
||||
$post_object = get_post( $product_id );
|
||||
$GLOBALS['post'] =& $post_object; // WPCS: override ok.
|
||||
setup_postdata( $post_object );
|
||||
|
||||
// Set custom product visibility when quering hidden products.
|
||||
add_action( 'woocommerce_product_is_visible', array( $this, 'set_product_as_visible' ) );
|
||||
|
|
51
readme.txt
51
readme.txt
|
@ -162,17 +162,60 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woocommerce/wo
|
|||
== Changelog ==
|
||||
|
||||
= 3.3.0 - 2017-XX-XX =
|
||||
* Feature - Template overrides via the wc_get_template filter now also appear in the System Status under the Templates section.
|
||||
* Feature - New default dummy data.
|
||||
* Feature - Added sandbox and live API details to the PayPal standard data, as well as an indication on the checkout to what mode is currently active.
|
||||
* Feature - Improved default appearance in themes which do not support WooCommerce, making the shop page shortcode based.
|
||||
* Feature - Products shortcodes; improved random sorting, with some caching.
|
||||
* Feature - Products shortcodes; support for pagination.
|
||||
* Feature - Added new options to the WordPress Appearance Customizer; control the product grid (rows and columns), and image sizes.
|
||||
* Feature - Improved how image sizes are defined and calculated. Set an aspect ratio (custom, 1:1, uncropped) and image sizes will be automagically calculated based on widths.
|
||||
* Feature - Changing image sizes will trigger automatic thumbnail regeneration in the background.
|
||||
* Feature - Improved how downloads are stored within products, and added new reporting/logging features to track who downloaded what, when.
|
||||
* Feature - Improved the overall appearance of the backend orders list, and added a new 'preview' button to quickly see order details.
|
||||
* Feature - New default dummy data and placeholders.
|
||||
* Feature - Added sandbox and live API details to the PayPal standard data, as well as an indication on the checkout to what mode is currently active. PayPal IPN email notifications are also now optional.
|
||||
* Feature - Introduced product category threshold filter (`woocommerce_product_category_filter_threshold`). AJAX powered select will kick in when you have over 100 categories.
|
||||
* Feature - Added `add_to_cart_description` method and aria-labels to cart buttons in the loop for accessibility.
|
||||
* Feature - Ability to search in logs when the database logger is used.
|
||||
* Performance - Adjusted how permalinks are retrieved and saved to avoid switching locales on each page load.
|
||||
* Performance - Added cache when loading product variation attributes.
|
||||
* Tweak - Moved the 'Store Notice" option into the customizer.
|
||||
* Tweak - Checkout Postcode / Zip validation error message was missing Billing / Shipping Identification.
|
||||
* Tweak - Added Iris color picker validation.
|
||||
* Tweak - Use scrollIntoView on checkout.
|
||||
* Tweak - Converted input submit elements to button submit elements across the entire codebase for consistency.
|
||||
* Tweak - Added `{site_title}` replacement for email footers.
|
||||
* Tweak - Added delete product confirmation if a product has had sales.
|
||||
* Tweak - Improved when "incl. VAT" is displayed in cart totals.
|
||||
* Tweak - Use base text color for links in email templates.
|
||||
* Tweak - Show theme overrides that are done through the wc_get_template filter in the system status report.
|
||||
* Tweak - Added nofollow tags in layered nav to prevent duplicate indexed content.
|
||||
* Tweak - Hide "incl. VAT" when no rates are defined in "single total" display mode.
|
||||
* Tweak - Added replay protection for refunds.
|
||||
* Tweak - GeoDB empty file handling.
|
||||
* Tweak - Let wp_signon handle email to username conversion.
|
||||
* Tweak - Made email field wider on checkout.
|
||||
* Tweak - Post entire shipping selection when showing multiple packages.
|
||||
* Dev - REST API - Fixed default value of "dp" on orders and refunds endpoints.
|
||||
* Dev - Theming - Added theme support variables to declare image sizes used for products.
|
||||
* Dev - Theming - Added support for single-product-postname.php template files.
|
||||
* Dev - Added actions before calculations order totals and taxes and is_vat_excempt support.
|
||||
* Dev - Add filter 'woocommerce_coupon_get_apply_quantity'.
|
||||
* Dev - Grouped products; added filters to allow custom columns and changes to values.
|
||||
* Dev - Allow for cloning the WC_Cart object
|
||||
* Dev - Apply filters to registration-error-email-exists error.
|
||||
* Dev - Added `woocommerce_cross_sells_order` filter.
|
||||
* Dev - Add order-details `before` hooks to complement existing hooks.
|
||||
* Dev - WC_CHUNK_SIZE constant for controlling readfile.
|
||||
* Dev - Add short circuit to customer bought product function.
|
||||
* Dev - Added a `wc_caught_exception` method to aid with logging.
|
||||
* Dev - Added Data stores and CRUD for working with Webhooks.
|
||||
* Dev - Bumped minimum WP version requirement to 4.5 and removed legacy API files.
|
||||
* Dev - New actions - `woocommerce_order_details_before_order_table_items`, `woocommerce_order_details_after_order_table_items` and `woocommerce_order_details_before_order_table`
|
||||
* Dev - Passed `widget_id` to `content-widget-product.php` so actions can be ran conditionally, and added sanitisation to `woocommerce_before_widget_product_list` and `woocommerce_after_widget_product_list`.
|
||||
* Dev - Improved the `is_internal_meta_key` checks to consider getters and setters.
|
||||
* Dev - Cleaned up the Order Customer Details template.
|
||||
* Performance - Added cache when loading product variation attributes.
|
||||
* Dev - JavaScript payment_method_selected events on checkout.
|
||||
* Localization - Add direction character to currency output.
|
||||
* Localization - States for Tanzania.
|
||||
|
||||
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt).
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
|
|||
array(
|
||||
'method_id' => 'flat_rate',
|
||||
'method_title' => 'Flat rate',
|
||||
'total' => 10,
|
||||
'total' => '10',
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
|
|
@ -75,6 +75,8 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
),
|
||||
),
|
||||
), $product_reviews );
|
||||
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,6 +89,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$product = WC_Helper_Product::create_simple_product();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/reviews' ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,6 +127,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
), $data );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,6 +141,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$product_review_id = WC_Helper_Product::create_product_review( $product->get_id() );
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/reviews/' . $product_review_id ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,6 +154,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$product = WC_Helper_Product::create_simple_product();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() . '/reviews/0' ) );
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,6 +186,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
'email' => 'woo@woo.local',
|
||||
'verified' => false,
|
||||
), $data );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,6 +230,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 400, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,6 +263,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$this->assertEquals( 'Justin', $data['name'] );
|
||||
$this->assertEquals( 'woo2@woo.local', $data['email'] );
|
||||
$this->assertEquals( 3, $data['rating'] );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,6 +286,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,6 +308,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,6 +325,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$request->set_param( 'force', true );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -330,6 +342,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$response = $this->server->dispatch( $request );
|
||||
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -347,6 +360,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$response = $this->server->dispatch( $request );
|
||||
|
||||
$this->assertEquals( 404, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,6 +408,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 3, count( $data ) );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -418,5 +433,6 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
|
|||
$this->assertArrayHasKey( 'name', $properties );
|
||||
$this->assertArrayHasKey( 'email', $properties );
|
||||
$this->assertArrayHasKey( 'verified', $properties );
|
||||
$product->delete( true );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,11 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
$this->assertEquals( 'DUMMY SKU', $products[0]['sku'] );
|
||||
$this->assertEquals( 'Dummy External Product', $products[1]['name'] );
|
||||
$this->assertEquals( 'DUMMY EXTERNAL SKU', $products[1]['sku'] );
|
||||
|
||||
foreach ( $products as $key => $value ) {
|
||||
$product = wc_get_product( $value['id'] );
|
||||
$product->delete( true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +68,13 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
WC_Helper_Product::create_simple_product();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products' ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
|
||||
// Remove product.
|
||||
wp_set_current_user( $this->user );
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products' ) );
|
||||
$products = $response->get_data();
|
||||
$product = wc_get_product( $products[0]['id'] );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,6 +97,7 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
'sku' => 'DUMMY EXTERNAL SKU',
|
||||
'regular_price' => 10,
|
||||
), $product );
|
||||
$simple->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,6 +110,7 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
$product = WC_Helper_Product::create_simple_product();
|
||||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products/' . $product->get_id() ) );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,6 +130,7 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/products' ) );
|
||||
$variations = $response->get_data();
|
||||
$this->assertEquals( 0, count( $variations ) );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,6 +145,7 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
$request->set_param( 'force', true );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,6 +195,7 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
$this->assertEquals( 'FIXED-SKU', $data['sku'] );
|
||||
$this->assertContains( 'Dr1Bczxq4q', $data['images'][0]['src'] );
|
||||
$this->assertContains( 'test upload image', $data['images'][0]['alt'] );
|
||||
$product->delete( true );
|
||||
|
||||
// test variable product (variations are tested in product-variations.php)
|
||||
$product = WC_Helper_Product::create_variation_product();
|
||||
|
@ -463,6 +480,11 @@ class Products_API extends WC_REST_Unit_Test_Case {
|
|||
$products = $response->get_data();
|
||||
|
||||
$this->assertEquals( 8, count( $products ) );
|
||||
|
||||
foreach ( $products as $key => $value ) {
|
||||
$product = wc_get_product( $value['id'] );
|
||||
$product->delete( true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -137,6 +137,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
|
|||
$discounts = new WC_Discounts();
|
||||
$discounts->set_items_from_cart( false );
|
||||
$this->assertEquals( array(), $discounts->get_items() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,6 +174,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
|
|||
$discounts->set_items_from_cart( WC()->cart );
|
||||
$discounts->apply_coupon( $coupon );
|
||||
$this->assertEquals( 0, $discounts->get_discounted_price( current( $discounts->get_items() ) ), print_r( $discounts->get_discounts(), true ) );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,6 +187,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
|
|||
public function test_calculations( $test_data ) {
|
||||
$this->last_test_data = $test_data;
|
||||
$discounts = new WC_Discounts();
|
||||
$products = array();
|
||||
|
||||
if ( isset( $test_data['tax_rate'] ) ) {
|
||||
WC_Tax::_insert_tax_rate( $test_data['tax_rate'] );
|
||||
|
@ -196,13 +199,13 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
|
|||
}
|
||||
}
|
||||
|
||||
foreach ( $test_data['cart'] as $item ) {
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$product->set_regular_price( $item['price'] );
|
||||
$product->set_tax_status( 'taxable' );
|
||||
$product->save();
|
||||
$this->store_product( $product );
|
||||
WC()->cart->add_to_cart( $product->get_id(), $item['qty'] );
|
||||
foreach ( $test_data['cart'] as $key => $item ) {
|
||||
$products[ $key ] = WC_Helper_Product::create_simple_product();
|
||||
$products[ $key ]->set_regular_price( $item['price'] );
|
||||
$products[ $key ]->set_tax_status( 'taxable' );
|
||||
$products[ $key ]->save();
|
||||
$this->store_product( $products[ $key ] );
|
||||
WC()->cart->add_to_cart( $products[ $key ]->get_id(), $item['qty'] );
|
||||
}
|
||||
|
||||
$discounts->set_items_from_cart( WC()->cart );
|
||||
|
@ -222,6 +225,10 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
|
|||
}
|
||||
|
||||
$this->assertEquals( $test_data['expected_total_discount'], $discount_total, 'Failed (' . print_r( $test_data, true ) . ' - ' . print_r( $discounts->get_discounts(), true ) . ')' );
|
||||
|
||||
foreach ( $products as $product ) {
|
||||
$product->delete( true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -880,7 +880,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_wc_do_oembeds() {
|
||||
// In this case should only return the URL back, since oEmbed will run other actions on frontend.
|
||||
$this->assertEquals( 'https://wordpress.tv/2015/10/19/mike-jolley-user-onboarding-for-wordpress-plugins/', wc_do_oembeds( 'https://wordpress.tv/2015/10/19/mike-jolley-user-onboarding-for-wordpress-plugins/' ) );
|
||||
$this->assertEquals( "<iframe width='500' height='281' src='https://videopress.com/embed/9sRCUigm?hd=0' frameborder='0' allowfullscreen></iframe><script src='https://v0.wordpress.com/js/next/videopress-iframe.js?m=1435166243'></script>", wc_do_oembeds( 'https://wordpress.tv/2015/10/19/mike-jolley-user-onboarding-for-wordpress-plugins/' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $csv_file = string;
|
||||
protected $csv_file = '';
|
||||
|
||||
/**
|
||||
* Load up the importer classes since they aren't loaded by default.
|
||||
|
|
|
@ -73,10 +73,11 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( $product->get_date_on_sale_to()->getTimestamp(), 1477267200 );
|
||||
|
||||
$image_url = media_sideload_image( "https://cldup.com/Dr1Bczxq4q.png", $product->get_id(), '', 'src' );
|
||||
$image_id = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ) );
|
||||
$image_id = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid='%s';", $image_url ) );
|
||||
$product->set_image_id( $image_id[0] );
|
||||
$product->save();
|
||||
$this->assertEquals( $image_id[0], $product->get_image_id() );
|
||||
$product->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,6 +70,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'posts_per_page' => -1,
|
||||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'fields' => 'ids',
|
||||
);
|
||||
$this->assertEquals( $expected, $shortcode->get_query_args() );
|
||||
|
||||
|
@ -88,6 +89,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'posts_per_page' => -1,
|
||||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'fields' => 'ids',
|
||||
);
|
||||
$this->assertEquals( $expected2, $shortcode2->get_query_args() );
|
||||
|
||||
|
@ -106,6 +108,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'post__in' => array( '1', '2', '3' ),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
$expected3['meta_query'][] = array(
|
||||
'key' => '_sku',
|
||||
|
@ -135,6 +138,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'meta_key' => '',
|
||||
'fields' => 'ids',
|
||||
);
|
||||
$expected4['tax_query'][] = array(
|
||||
'taxonomy' => 'product_cat',
|
||||
|
@ -164,6 +168,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'posts_per_page' => 12,
|
||||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected5, $shortcode5->get_query_args() );
|
||||
|
@ -184,6 +189,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'p' => '1',
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected6, $shortcode6->get_query_args() );
|
||||
|
@ -208,6 +214,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'post__in' => array_merge( array( 0 ), wc_get_product_ids_on_sale() ),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected7, $shortcode7->get_query_args() );
|
||||
|
@ -230,6 +237,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'meta_key' => 'total_sales',
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected8, $shortcode8->get_query_args() );
|
||||
|
@ -253,6 +261,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'posts_per_page' => 12,
|
||||
'meta_query' => $meta_query,
|
||||
'tax_query' => $tax_query,
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected9, $shortcode9->get_query_args() );
|
||||
|
@ -285,6 +294,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'include_children' => false,
|
||||
),
|
||||
) ),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected10, $shortcode10->get_query_args() );
|
||||
|
@ -315,6 +325,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'operator' => 'IN',
|
||||
),
|
||||
) ),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected11, $shortcode11->get_query_args() );
|
||||
|
@ -341,6 +352,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'include_children' => false,
|
||||
),
|
||||
),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected12, $shortcode12->get_query_args() );
|
||||
|
@ -373,6 +385,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'include_children' => false,
|
||||
),
|
||||
),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected13, $shortcode13->get_query_args() );
|
||||
|
@ -405,6 +418,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
|
|||
'include_children' => false,
|
||||
),
|
||||
),
|
||||
'fields' => 'ids',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected14, $shortcode14->get_query_args() );
|
||||
|
|
Loading…
Reference in New Issue