From 71e67e97f44194cbd96cf58f802030fb79796b50 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 13 May 2013 14:18:05 +0100 Subject: [PATCH 1/4] Limit items sent to paypal to 9 Closes #3124. @coenjacobs --- classes/gateways/paypal/class-wc-gateway-paypal.php | 2 +- readme.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/gateways/paypal/class-wc-gateway-paypal.php b/classes/gateways/paypal/class-wc-gateway-paypal.php index 82669cb8fef..de7f5683f97 100644 --- a/classes/gateways/paypal/class-wc-gateway-paypal.php +++ b/classes/gateways/paypal/class-wc-gateway-paypal.php @@ -306,7 +306,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway { } // If prices include tax or have order discounts, send the whole order as a single item - if ( get_option( 'woocommerce_prices_include_tax' ) == 'yes' || $order->get_order_discount() > 0 ) { + if ( get_option( 'woocommerce_prices_include_tax' ) == 'yes' || $order->get_order_discount() > 0 || ( sizeof( $order->get_items() ) + sizeof( $order->get_fees() ) ) >= 9 ) { // Discount $paypal_args['discount_amount_cart'] = $order->get_order_discount(); diff --git a/readme.txt b/readme.txt index 95e14118ade..c4b5944dc0f 100644 --- a/readme.txt +++ b/readme.txt @@ -183,6 +183,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Fix - is_on_sale() method now returns true for products with a sale product of 0 * Fix - Changed MyException to Exception in Checkout class as MyException class does not exist in WooCommerce * Fix - For when get_the_terms() returns false inside woocommerce_get_product_terms() +* Fix - PayPal has a 9 item limit. * Refactor - Taken out Piwik integration, use http://wordpress.org/extend/plugins/woocommerce-piwik-integration/ from now on * Refactor - Taken out ShareYourCart integration, use http://wordpress.org/extend/plugins/shareyourcart/ from now on * Refactor - Moved woocommerce_get_formatted_product_name function into WC_Product class From bcfbbb3c13ca3dcf370ce2f73be544663a4c46cc Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 13 May 2013 14:35:49 +0100 Subject: [PATCH 2/4] Filter for forcing coutnry Closes #3117. --- classes/class-wc-countries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wc-countries.php b/classes/class-wc-countries.php index 1f41fb156a1..615d2f4fdfa 100644 --- a/classes/class-wc-countries.php +++ b/classes/class-wc-countries.php @@ -619,7 +619,7 @@ class WC_Countries { $full_country = ( isset( $this->countries[ $country ] ) ) ? $this->countries[ $country ] : $country; // Country is not needed if the same as base - if ( $country == $this->get_base_country() ) + if ( $country == $this->get_base_country() && ! apply_filters( 'woocommerce_formatted_address_force_country_display', false ) ) $format = str_replace( '{country}', '', $format ); // Handle full state name From cdcdbd79f7aa86dbae089725168f43b4099cd54e Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 13 May 2013 14:40:15 +0100 Subject: [PATCH 3/4] Remove expensive query. Closes #3116 --- admin/post-types/shop_order.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/admin/post-types/shop_order.php b/admin/post-types/shop_order.php index 85ca1f02fc5..802d57e48c1 100644 --- a/admin/post-types/shop_order.php +++ b/admin/post-types/shop_order.php @@ -466,28 +466,6 @@ function woocommerce_shop_order_search_custom_fields( $wp ) { esc_attr( $_GET['s'] ) ) ), - $wpdb->get_col( - $wpdb->prepare( " - SELECT posts.ID - FROM {$wpdb->posts} as posts - LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id - LEFT JOIN {$wpdb->users} as users ON postmeta.meta_value = users.ID - WHERE - post_excerpt LIKE '%%%1\$s%%' OR - post_title LIKE '%%%1\$s%%' OR - ( - meta_key = '_customer_user' AND - ( - user_login LIKE '%%%1\$s%%' OR - user_nicename LIKE '%%%1\$s%%' OR - user_email LIKE '%%%1\$s%%' OR - display_name LIKE '%%%1\$s%%' - ) - ) - ", - esc_attr( $_GET['s'] ) - ) - ), array( $search_order_id ) ); From 6fc0d27006e6529a9810b397d93a938725947a34 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 13 May 2013 15:12:12 +0100 Subject: [PATCH 4/4] content-widget-product.php template for product lists inside core widgets Closes #3133 --- .../widgets/class-wc-widget-best-sellers.php | 8 +--- .../class-wc-widget-featured-products.php | 27 ++++++------ classes/widgets/class-wc-widget-onsale.php | 8 +--- .../class-wc-widget-random-products.php | 41 ++++++++----------- .../class-wc-widget-recent-products.php | 8 +--- .../class-wc-widget-recent-reviews.php | 2 +- .../class-wc-widget-recently-viewed.php | 8 +--- .../class-wc-widget-top-rated-products.php | 29 +++++++------ readme.txt | 1 + templates/content-widget-product.php | 9 ++++ 10 files changed, 60 insertions(+), 81 deletions(-) create mode 100644 templates/content-widget-product.php diff --git a/classes/widgets/class-wc-widget-best-sellers.php b/classes/widgets/class-wc-widget-best-sellers.php index 31b81bf4cf3..3db06b77e0e 100644 --- a/classes/widgets/class-wc-widget-best-sellers.php +++ b/classes/widgets/class-wc-widget-best-sellers.php @@ -109,13 +109,7 @@ class WC_Widget_Best_Sellers extends WP_Widget { while ( $r->have_posts()) { $r->the_post(); - global $product; - - echo '
  • - - ' . ( has_post_thumbnail() ? get_the_post_thumbnail( $r->post->ID, 'shop_thumbnail' ) : woocommerce_placeholder_img( 'shop_thumbnail' ) ) . ' ' . get_the_title() . ' - ' . $product->get_price_html() . ' -
  • '; + woocommerce_get_template( 'content-widget-product.php' ); } echo ''; diff --git a/classes/widgets/class-wc-widget-featured-products.php b/classes/widgets/class-wc-widget-featured-products.php index 938ae2c30fe..09d98cb0269 100644 --- a/classes/widgets/class-wc-widget-featured-products.php +++ b/classes/widgets/class-wc-widget-featured-products.php @@ -91,23 +91,24 @@ class WC_Widget_Featured_Products extends WP_Widget { $r = new WP_Query($query_args); - if ($r->have_posts()) : ?> + if ( $r->have_posts() ) { - - - - + echo '
      '; - have_posts() ) { + $r->the_post(); + woocommerce_get_template( 'content-widget-product.php' ); + } + + echo '
    '; + + echo $after_widget; + } $content = ob_get_clean(); diff --git a/classes/widgets/class-wc-widget-onsale.php b/classes/widgets/class-wc-widget-onsale.php index 37d14bcff2d..1079da6863e 100644 --- a/classes/widgets/class-wc-widget-onsale.php +++ b/classes/widgets/class-wc-widget-onsale.php @@ -105,13 +105,7 @@ class WC_Widget_Onsale extends WP_Widget { while ( $r->have_posts() ) { $r->the_post(); - global $product; - - echo '
  • - - ' . ( has_post_thumbnail() ? get_the_post_thumbnail( $r->post->ID, 'shop_thumbnail' ) : woocommerce_placeholder_img( 'shop_thumbnail' ) ) . ' ' . get_the_title() . ' - ' . $product->get_price_html() . ' -
  • '; + woocommerce_get_template( 'content-widget-product.php' ); } echo ''; diff --git a/classes/widgets/class-wc-widget-random-products.php b/classes/widgets/class-wc-widget-random-products.php index 31d36a5c189..000fef3952e 100644 --- a/classes/widgets/class-wc-widget-random-products.php +++ b/classes/widgets/class-wc-widget-random-products.php @@ -42,6 +42,8 @@ class WC_Widget_Random_Products extends WP_Widget { function widget( $args, $instance ) { global $woocommerce; + extract( $args) ; + // Use default title as fallback $title = ( '' === $instance['title'] ) ? __('Random Products', 'woocommerce' ) : $instance['title']; $title = apply_filters('widget_title', $title, $instance, $this->id_base); @@ -65,34 +67,25 @@ class WC_Widget_Random_Products extends WP_Widget { $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $query_args['meta_query'] = array_filter( $query_args['meta_query'] ); - $query = new WP_Query( $query_args ); + $r = new WP_Query( $query_args ); - if ( $query->have_posts() ) { - echo $args['before_widget']; + if ( $r->have_posts() ) { - if ( '' !== $title ) { - echo $args['before_title'], $title, $args['after_title']; - } ?> + echo $before_widget; -
      - have_posts()) : $query->the_post(); global $product; ?> -
    • - - - - - get_price_html() ?> -
    • - -
    + if ( $title ) + echo $before_title . $title . $after_title; - '; + + while ( $r->have_posts() ) { + $r->the_post(); + woocommerce_get_template( 'content-widget-product.php' ); + } + + echo ''; + + echo $after_widget; } } diff --git a/classes/widgets/class-wc-widget-recent-products.php b/classes/widgets/class-wc-widget-recent-products.php index 8adc5c943cf..10b4a9ead3f 100644 --- a/classes/widgets/class-wc-widget-recent-products.php +++ b/classes/widgets/class-wc-widget-recent-products.php @@ -102,13 +102,7 @@ class WC_Widget_Recent_Products extends WP_Widget { while ( $r->have_posts()) { $r->the_post(); - global $product; - - echo '
  • - - ' . ( has_post_thumbnail() ? get_the_post_thumbnail( $r->post->ID, 'shop_thumbnail' ) : woocommerce_placeholder_img( 'shop_thumbnail' ) ) . ' ' . get_the_title() . ' - ' . $product->get_price_html() . ' -
  • '; + woocommerce_get_template( 'content-widget-product.php' ); } echo ''; diff --git a/classes/widgets/class-wc-widget-recent-reviews.php b/classes/widgets/class-wc-widget-recent-reviews.php index 6812439f5e8..ab76f32e7af 100644 --- a/classes/widgets/class-wc-widget-recent-reviews.php +++ b/classes/widgets/class-wc-widget-recent-reviews.php @@ -78,7 +78,7 @@ class WC_Widget_Recent_Reviews extends WP_Widget { if ( $title ) echo $before_title . $title . $after_title; echo ''; diff --git a/classes/widgets/class-wc-widget-top-rated-products.php b/classes/widgets/class-wc-widget-top-rated-products.php index a42a6c1f01c..55afb10f166 100644 --- a/classes/widgets/class-wc-widget-top-rated-products.php +++ b/classes/widgets/class-wc-widget-top-rated-products.php @@ -81,27 +81,26 @@ class WC_Widget_Top_Rated_Products extends WP_Widget { $query_args['meta_query'] = $woocommerce->query->get_meta_query(); - $top_rated_posts = new WP_Query( $query_args ); + $r = new WP_Query( $query_args ); - if ($top_rated_posts->have_posts()) : + if ( $r->have_posts() ) { echo $before_widget; - if ( $title ) echo $before_title . $title . $after_title; - ?> - - query, 'order_by_rating_post_clauses' ) ); diff --git a/readme.txt b/readme.txt index c4b5944dc0f..d41f5672889 100644 --- a/readme.txt +++ b/readme.txt @@ -173,6 +173,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Tweak - Update CPT parameters for 'product_variation' and 'shop_coupon' to be no longer public * Tweak - COD processing instead of on-hold * Tweak - Added filter to explicitly hide terms agreement checkbox +* Tweak - content-widget-product.php template for product lists inside core widgets * Fix - Cast term_id as int in product data write panel that will resolve issues with numerical attributes * Fix - Correct label for RUB symbol - added a dot after it * Fix - Javascript escapes to stop breaking scripts when used with translations diff --git a/templates/content-widget-product.php b/templates/content-widget-product.php new file mode 100644 index 00000000000..642273ab1e2 --- /dev/null +++ b/templates/content-widget-product.php @@ -0,0 +1,9 @@ + +
  • + + get_image(); ?> + get_title() ?> + + get_rating_html(); ?> + get_price_html(); ?> +
  • \ No newline at end of file