Sales logic fix, clear cache on upgrade

This commit is contained in:
Mike Jolley 2011-11-18 00:38:46 +00:00
parent 00d838b312
commit 81b984d5b4
5 changed files with 17 additions and 10 deletions

View File

@ -25,7 +25,7 @@ function activate_woocommerce() {
* Install woocommerce
*/
function install_woocommerce() {
global $woocommerce_settings;
global $woocommerce_settings, $woocommerce;
// Do install
woocommerce_default_options();
@ -52,6 +52,9 @@ function install_woocommerce() {
endif;
endif;
// Clear cache
$woocommerce->clear_product_transients();
// Update version
update_option( "woocommerce_db_version", WOOCOMMERCE_VERSION );
}
@ -61,11 +64,10 @@ function install_woocommerce() {
*/
add_action('admin_init', 'install_woocommerce_redirect');
function install_woocommerce_redirect() {
global $pagenow, $woocommerce;
global $pagenow;
if ( is_admin() && isset( $_GET['activate'] ) && ($_GET['activate'] == true) && $pagenow == 'plugins.php' && get_option( "woocommerce_installed" ) == 1 ) :
$woocommerce->clear_product_transients();
update_option( "woocommerce_installed", 0 );
flush_rewrite_rules( false );
wp_redirect(admin_url('admin.php?page=woocommerce&installed=true'));

View File

@ -161,7 +161,7 @@ class woocommerce_product {
if ( false === ( $this->children = get_transient( $transient_name ) ) ) :
$this->children = get_posts( 'post_parent='.$this->id.'&post_type='.$child_post_type.'&orderby=menu_order&order=ASC&fields=ids&post_status=any&numberposts=-1' );
$this->children = get_posts( 'post_parent=' . $this->id . '&post_type=' . $child_post_type . '&orderby=menu_order&order=ASC&fields=ids&post_status=any&numberposts=-1' );
set_transient( $transient_name, $this->children );
@ -456,8 +456,9 @@ class woocommerce_product {
if ( $this->has_child() ) :
foreach ($this->get_children() as $child_id) :
$sale_price = get_post_meta( $child_id, 'sale_price', true);
if ( $sale_price > 0 && $sale_price == $this->price ) return true;
$sale_price = get_post_meta( $child_id, 'sale_price', true );
$regular_price = get_post_meta( $child_id, 'price', true );
if ( $sale_price > 0 && $sale_price < $regular_price ) return true;
endforeach;
else :

View File

@ -49,8 +49,8 @@ class woocommerce_product_variation extends woocommerce_product {
// Define the data we're going to load from the parent: Key => Default value
$load_data = array(
'sku' => $this->id,
'downloadable' => 'no',
'virtual' => 'no',
//'downloadable' => 'no',
//'virtual' => 'no',
'price' => 0,
'visibility' => 'hidden',
'stock' => 0,

View File

@ -326,7 +326,7 @@ class woocommerce {
/**
* Clear Product Transients
*/
function clear_product_transients( $post_id = null ) {
function clear_product_transients( $post_id = 0 ) {
global $wpdb;
delete_transient('woocommerce_products_onsale');

View File

@ -4,7 +4,7 @@ Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sh
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce
Requires at least: 3.1
Tested up to: 3.3
Stable tag: 1.2.2
Stable tag: 1.2.3
An e-commerce toolkit that helps you sell anything. Beautifully.
@ -82,6 +82,10 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
== Changelog ==
= 1.2.4 - 18/11/2011 =
* More sale price logic fixes for variations. Now correctly compares variation's prices.
* Clear cache on upgrade
= 1.2.3 - 17/11/2011 =
* Fix for sale price logic
* Related products array_diff fix