Merge branch 'master' of github.com:woothemes/woocommerce

This commit is contained in:
Barry Kooij 2015-03-09 13:19:10 +01:00
commit ca6e9a7371
6 changed files with 45 additions and 34 deletions

View File

@ -243,6 +243,8 @@ class WC_Product {
// Clear caches // Clear caches
wp_cache_delete( $this->id, 'post_meta' ); wp_cache_delete( $this->id, 'post_meta' );
delete_transient( 'wc_low_stock_count' );
delete_transient( 'wc_outofstock_count' );
unset( $this->stock ); unset( $this->stock );
// Stock status // Stock status

View File

@ -93,33 +93,40 @@ class WC_Admin_Dashboard {
} }
// Get products using a query - this is too advanced for get_posts :( // Get products using a query - this is too advanced for get_posts :(
$stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) ); $stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) );
$nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) ); $nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) );
$transient_name = 'wc_low_stock_count';
$query_from = apply_filters( 'woocommerce_report_low_in_stock_query_from', "FROM {$wpdb->posts} as posts if ( false === ( $lowinstock_count = get_transient( $transient_name ) ) ) {
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id $query_from = apply_filters( 'woocommerce_report_low_in_stock_query_from', "FROM {$wpdb->posts} as posts
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
WHERE 1=1 INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
AND posts.post_type IN ( 'product', 'product_variation' ) WHERE 1=1
AND posts.post_status = 'publish' AND posts.post_type IN ( 'product', 'product_variation' )
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' AND posts.post_status = 'publish'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}' AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}' AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}'
" ); AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}'
" );
$lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 );
}
$lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) ); $transient_name = 'wc_outofstock_count';
$query_from = apply_filters( 'woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts if ( false === ( $outofstock_count = get_transient( $transient_name ) ) ) {
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id $query_from = apply_filters( 'woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
WHERE 1=1 INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
AND posts.post_type IN ( 'product', 'product_variation' ) WHERE 1=1
AND posts.post_status = 'publish' AND posts.post_type IN ( 'product', 'product_variation' )
AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' AND posts.post_status = 'publish'
AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}' AND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'
" ); AND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}'
" );
$outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) ); $outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 );
}
?> ?>
<ul class="wc_status_list"> <ul class="wc_status_list">
<li class="sales-this-month"> <li class="sales-this-month">

View File

@ -30,8 +30,8 @@ class WC_Admin_Taxonomies {
// Add form // Add form
add_action( 'product_cat_add_form_fields', array( $this, 'add_category_fields' ) ); add_action( 'product_cat_add_form_fields', array( $this, 'add_category_fields' ) );
add_action( 'product_cat_edit_form_fields', array( $this, 'edit_category_fields' ), 10 ); add_action( 'product_cat_edit_form_fields', array( $this, 'edit_category_fields' ), 10 );
add_action( 'created_term', array( $this, 'save_category_fields' ), 10 ); add_action( 'created_term', array( $this, 'save_category_fields' ), 10, 3 );
add_action( 'edit_term', array( $this, 'save_category_fields' ), 10 ); add_action( 'edit_term', array( $this, 'save_category_fields' ), 10, 3 );
// Add columns // Add columns
add_filter( 'manage_edit-product_cat_columns', array( $this, 'product_cat_columns' ) ); add_filter( 'manage_edit-product_cat_columns', array( $this, 'product_cat_columns' ) );
@ -249,12 +249,11 @@ class WC_Admin_Taxonomies {
* *
* @param mixed $term_id Term ID being saved * @param mixed $term_id Term ID being saved
*/ */
public function save_category_fields( $term_id ) { public function save_category_fields( $term_id, $tt_id = '', $taxonomy = '' ) {
if ( isset( $_POST['display_type'] ) ) { if ( isset( $_POST['display_type'] ) && 'product_cat' === $taxonomy ) {
update_woocommerce_term_meta( $term_id, 'display_type', esc_attr( $_POST['display_type'] ) ); update_woocommerce_term_meta( $term_id, 'display_type', esc_attr( $_POST['display_type'] ) );
} }
if ( isset( $_POST['product_cat_thumbnail_id'] ) && 'product_cat' === $taxonomy ) {
if ( isset( $_POST['product_cat_thumbnail_id'] ) ) {
update_woocommerce_term_meta( $term_id, 'thumbnail_id', absint( $_POST['product_cat_thumbnail_id'] ) ); update_woocommerce_term_meta( $term_id, 'thumbnail_id', absint( $_POST['product_cat_thumbnail_id'] ) );
} }
} }

View File

@ -647,9 +647,9 @@ function wc_trim_string( $string, $chars = 200, $suffix = '...' ) {
* Format content to display shortcodes * Format content to display shortcodes
* *
* @since 2.3.0 * @since 2.3.0
* @param string $string * @param string $raw_string
* @return string * @return string
*/ */
function wc_format_content( $string ) { function wc_format_content( $raw_string ) {
return do_shortcode( shortcode_unautop( wpautop( $string ) ) ); return apply_filters( 'woocommerce_format_content', do_shortcode( shortcode_unautop( wpautop( $raw_string ) ) ), $raw_string );
} }

View File

@ -79,7 +79,9 @@ function wc_delete_product_transients( $post_id = 0 ) {
// Core transients // Core transients
$transients_to_clear = array( $transients_to_clear = array(
'wc_products_onsale', 'wc_products_onsale',
'wc_featured_products' 'wc_featured_products',
'wc_outofstock_count',
'wc_low_stock_count'
); );
// Transients that include an ID // Transients that include an ID

View File

@ -151,6 +151,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Tweak - Prevent cart being cleared when accessing the login page. * Tweak - Prevent cart being cleared when accessing the login page.
* Tweak - Shipping calculator - Made state/postcode respect country locale like checkout. * Tweak - Shipping calculator - Made state/postcode respect country locale like checkout.
* Tweak - Move default customer location to general settings tab. * Tweak - Move default customer location to general settings tab.
* Tweak - Only run save_category_fields for product_cat taxonomy.
= 2.3.5 - 20/02/2015 = = 2.3.5 - 20/02/2015 =
* Fix - Plain text address formatting. * Fix - Plain text address formatting.