Merge remote branch 'upstream/master'

This commit is contained in:
Ramon van Belzen 2012-03-04 14:06:43 +01:00
commit adeda9cc47
8 changed files with 57 additions and 10 deletions

View File

@ -573,7 +573,7 @@ jQuery( function($){
if (product_type!='variable') enable_variation = 'style="display:none;"'; else enable_variation = ''; if (product_type!='variable') enable_variation = 'style="display:none;"'; else enable_variation = '';
// Add custom attribute row // Add custom attribute row
$('.woocommerce_attributes').append('<div class="woocommerce_attribute">\ $('.woocommerce_attributes').append('<div class="woocommerce_attribute wc-metabox">\
<h3>\ <h3>\
<button type="button" class="remove_row button">' + woocommerce_writepanel_params.remove_label + '</button>\ <button type="button" class="remove_row button">' + woocommerce_writepanel_params.remove_label + '</button>\
<div class="handlediv" title="' + woocommerce_writepanel_params.click_to_toggle + '"></div>\ <div class="handlediv" title="' + woocommerce_writepanel_params.click_to_toggle + '"></div>\

File diff suppressed because one or more lines are too long

View File

@ -45,8 +45,7 @@ class WC_Cart {
$this->display_totals_ex_tax = (get_option('woocommerce_display_totals_excluding_tax')=='yes') ? true : false; $this->display_totals_ex_tax = (get_option('woocommerce_display_totals_excluding_tax')=='yes') ? true : false;
$this->display_cart_ex_tax = (get_option('woocommerce_display_cart_prices_excluding_tax')=='yes') ? true : false; $this->display_cart_ex_tax = (get_option('woocommerce_display_cart_prices_excluding_tax')=='yes') ? true : false;
add_action('init', array(&$this, 'init'), 1); // Get cart on init add_action('init', array(&$this, 'init'), 5); // Get cart on init
//add_action('wp', array(&$this, 'calculate_totals'), 1); // Defer calculate totals so we can detect page
} }
/** /**
@ -159,17 +158,47 @@ class WC_Cart {
$_SESSION['shipping_total'] = $this->shipping_total; $_SESSION['shipping_total'] = $this->shipping_total;
$_SESSION['shipping_tax_total'] = $this->shipping_tax_total; $_SESSION['shipping_tax_total'] = $this->shipping_tax_total;
$_SESSION['shipping_label'] = $this->shipping_label; $_SESSION['shipping_label'] = $this->shipping_label;
if (get_current_user_id()) $this->persistent_cart_update();
do_action('woocommerce_cart_updated');
} }
/** /**
* Empty the cart data and destroy the session * Empty the cart data and destroy the session
*/ */
function empty_cart() { function empty_cart( $clear_persistent_cart = true ) {
$this->cart_contents = array(); $this->cart_contents = array();
$this->reset(); $this->reset();
unset( $_SESSION['cart_contents_total'], $_SESSION['cart_contents_weight'], $_SESSION['cart_contents_count'], $_SESSION['cart_contents_tax'], $_SESSION['total'], $_SESSION['subtotal'], $_SESSION['subtotal_ex_tax'], $_SESSION['tax_total'], $_SESSION['taxes'], $_SESSION['shipping_taxes'], $_SESSION['discount_cart'], $_SESSION['discount_total'], $_SESSION['shipping_total'], $_SESSION['shipping_tax_total'], $_SESSION['shipping_label'], $_SESSION['coupons'], $_SESSION['cart'] ); unset( $_SESSION['cart_contents_total'], $_SESSION['cart_contents_weight'], $_SESSION['cart_contents_count'], $_SESSION['cart_contents_tax'], $_SESSION['total'], $_SESSION['subtotal'], $_SESSION['subtotal_ex_tax'], $_SESSION['tax_total'], $_SESSION['taxes'], $_SESSION['shipping_taxes'], $_SESSION['discount_cart'], $_SESSION['discount_total'], $_SESSION['shipping_total'], $_SESSION['shipping_tax_total'], $_SESSION['shipping_label'], $_SESSION['coupons'], $_SESSION['cart'] );
if ($clear_persistent_cart && get_current_user_id()) $this->persistent_cart_destroy();
do_action('woocommerce_cart_emptied');
} }
/*-----------------------------------------------------------------------------------*/
/* Persistent cart handling */
/*-----------------------------------------------------------------------------------*/
/**
* Save the persistent cart when updated
*/
function persistent_cart_update() {
update_user_meta( get_current_user_id(), '_woocommerce_persistent_cart', array(
'cart' => $_SESSION['cart'],
));
}
/**
* Delete the persistent cart
*/
function persistent_cart_destroy() {
delete_user_meta( get_current_user_id(), '_woocommerce_persistent_cart' );
}
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Cart Data Functions */ /* Cart Data Functions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -351,7 +380,7 @@ class WC_Cart {
return $merged_taxes; return $merged_taxes;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Add to cart handling */ /* Add to cart handling */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -241,8 +241,7 @@ class WC_Customer {
endif; endif;
return apply_filters('woocommerce_customer_get_downloadable_products', $downloads); return apply_filters('woocommerce_customer_get_downloadable_products', $downloads);
}
}
} }
/** Depreciated */ /** Depreciated */

View File

@ -144,12 +144,14 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog == == Changelog ==
= 1.5.1 = = 1.5.1 =
* Persistent (logged-in) customer carts (thanks dominic-p)
* Error suppression on set_time_out * Error suppression on set_time_out
* Order-details removed shipping when disabled * Order-details removed shipping when disabled
* Updated Turkish translation * Updated Turkish translation
* Layered nav for attribute pages (thanks helgatheviking) * Layered nav for attribute pages (thanks helgatheviking)
* Fixed dates in dashboard stats * Fixed dates in dashboard stats
* Download expiry was backwards * Download expiry was backwards
* Fix styling of new attribute
= 1.5 - 01/03/2012 = = 1.5 - 01/03/2012 =
* Quick edit products * Quick edit products

View File

@ -54,7 +54,24 @@ if (!function_exists('woocommerce_empty_cart')) {
if (!isset($woocommerce->cart) || $woocommerce->cart == '' ) $woocommerce->cart = new WC_Cart(); if (!isset($woocommerce->cart) || $woocommerce->cart == '' ) $woocommerce->cart = new WC_Cart();
$woocommerce->cart->empty_cart(); $woocommerce->cart->empty_cart( false );
}
}
/**
* Load the cart upon login
**/
function woocommerce_load_persistent_cart( $user_login, $user ) {
global $woocommerce;
$saved_cart = get_user_meta( $user->ID, '_woocommerce_persistent_cart', true );
if ($saved_cart) {
if (!isset($_SESSION['cart']) || !is_array($_SESSION['cart']) || sizeof($_SESSION['cart'])==0) {
$_SESSION['cart'] = $saved_cart['cart'];
}
} }
} }

View File

@ -462,7 +462,6 @@ function woocommerce_clear_cart_after_payment() {
endif; endif;
} }
/** /**
* Process the checkout form * Process the checkout form
**/ **/

View File

@ -119,6 +119,7 @@ add_action( 'init', 'woocommerce_update_catalog_ordering' );
/* Cart Actions */ /* Cart Actions */
add_action( 'init', 'woocommerce_update_cart_action' ); add_action( 'init', 'woocommerce_update_cart_action' );
add_action( 'init', 'woocommerce_add_to_cart_action' ); add_action( 'init', 'woocommerce_add_to_cart_action' );
add_action( 'wp_login', 'woocommerce_load_persistent_cart', 1, 2);
/* Checkout Actions */ /* Checkout Actions */
add_action( 'init', 'woocommerce_checkout_action' ); add_action( 'init', 'woocommerce_checkout_action' );