Merge pull request #6258 from shivapoudel/patch-2

Some changes in WC_Cart
This commit is contained in:
Mike Jolley 2014-09-15 09:46:20 +01:00
commit d2fc731d4e
1 changed files with 97 additions and 92 deletions

View File

@ -88,7 +88,7 @@ class WC_Cart {
public function __construct() { public function __construct() {
$this->tax = new WC_Tax(); $this->tax = new WC_Tax();
$this->prices_include_tax = get_option( 'woocommerce_prices_include_tax' ) == 'yes'; $this->prices_include_tax = get_option( 'woocommerce_prices_include_tax' ) == 'yes';
$this->round_at_subtotal = get_option('woocommerce_tax_round_at_subtotal') == 'yes'; $this->round_at_subtotal = get_option( 'woocommerce_tax_round_at_subtotal' ) == 'yes';
$this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' ); $this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' );
$this->dp = absint( get_option( 'woocommerce_price_num_decimals' ) ); $this->dp = absint( get_option( 'woocommerce_price_num_decimals' ) );
$this->display_totals_ex_tax = $this->tax_display_cart == 'excl'; $this->display_totals_ex_tax = $this->tax_display_cart == 'excl';
@ -136,6 +136,9 @@ class WC_Cart {
/** /**
* Will set cart cookies if needed, once, during WP hook * Will set cart cookies if needed, once, during WP hook
*
* @access public
* @return void
*/ */
public function maybe_set_cart_cookies() { public function maybe_set_cart_cookies() {
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
@ -159,8 +162,8 @@ class WC_Cart {
wc_setcookie( 'woocommerce_items_in_cart', 1 ); wc_setcookie( 'woocommerce_items_in_cart', 1 );
wc_setcookie( 'woocommerce_cart_hash', md5( json_encode( $this->get_cart() ) ) ); wc_setcookie( 'woocommerce_cart_hash', md5( json_encode( $this->get_cart() ) ) );
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) { } elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) {
wc_setcookie( 'woocommerce_items_in_cart', 0, time() - 3600 ); wc_setcookie( 'woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS );
wc_setcookie( 'woocommerce_cart_hash', '', time() - 3600 ); wc_setcookie( 'woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS );
} }
do_action( 'woocommerce_set_cart_cookies', $set ); do_action( 'woocommerce_set_cart_cookies', $set );
} }
@ -233,6 +236,9 @@ class WC_Cart {
/** /**
* Sets the php session data for the cart and coupons. * Sets the php session data for the cart and coupons.
*
* @access public
* @return void
*/ */
public function set_session() { public function set_session() {
// Set cart and coupon session data // Set cart and coupon session data
@ -392,6 +398,8 @@ class WC_Cart {
/** /**
* Looks through cart items and checks the posts are not trashed or deleted. * Looks through cart items and checks the posts are not trashed or deleted.
*
* @access public
* @return bool|WP_Error * @return bool|WP_Error
*/ */
public function check_cart_item_validity() { public function check_cart_item_validity() {
@ -944,8 +952,6 @@ class WC_Cart {
/** /**
* Calculate totals for the items in the cart. * Calculate totals for the items in the cart.
*
* @access public
*/ */
public function calculate_totals() { public function calculate_totals() {
@ -1245,7 +1251,6 @@ class WC_Cart {
/** /**
* remove_taxes function. * remove_taxes function.
* *
* @access public
* @return void * @return void
*/ */
public function remove_taxes() { public function remove_taxes() {