WooCommerce Cart Tab - Version 0.2

Version Description

  • 01/07/2013 =
  • Added option to hide cart tab if the cart is empty. Kudos azhkuro.
Download this release

Release Info

Developer jameskoster
Plugin Icon wp plugin WooCommerce Cart Tab
Version 0.2
Comparing to
See all releases

Code changes from version 0.1.1 to 0.2

Files changed (2) hide show
  1. cart-tab.php +34 -21
  2. readme.txt +4 -1
cart-tab.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: WooCommerce Cart Tab
4
  Plugin URI: http://jameskoster.co.uk/tag/cart-tab/
5
- Version: 0.1.1
6
  Description: Displays a sitewide link to the cart which reveals the cart contents on hover.
7
  Author: jameskoster
8
  Tested up to: 3.6
@@ -46,10 +46,16 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
46
  ),
47
  array(
48
  'name' => __( 'Cart Widget', 'woocommerce-cart-tab' ),
49
- 'desc' => __( 'Display the cart widget on hover', 'woocommerce-cart-tab' ),
50
  'id' => 'wc_ct_cart_widget',
51
  'type' => 'checkbox'
52
  ),
 
 
 
 
 
 
53
  array(
54
  'name' => __( 'Use the light or dark skin', 'woocommerce-cart-tab' ),
55
  'id' => 'wc_ct_skin',
@@ -74,6 +80,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
74
 
75
  // Default options
76
  add_option( 'wc_ct_cart_widget', 'yes' );
 
77
  add_option( 'wc_ct_skin', 'light' );
78
  add_option( 'wc_ct_horizontal_position', 'right' );
79
 
@@ -125,26 +132,32 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
125
  // Display the cart tab and widget
126
  function woocommerce_cart_tab() {
127
  global $woocommerce;
128
- $skin = get_option( 'wc_ct_skin' );
129
- $position = get_option( 'wc_ct_horizontal_position' );
130
- $widget = get_option( 'wc_ct_cart_widget' );
131
- if ( ! is_cart() && ! is_checkout() ) {
132
- if ( $widget == 'yes' ) {
133
- echo '<div class="' . $position . ' cart-tab ' . $skin . '">';
134
- } else {
135
- echo '<div class="' . $position . ' cart-tab no-animation ' . $skin . '">';
136
- }
137
- wcct_cart_button();
138
- // Display the widget if specified
139
  if ( $widget == 'yes' ) {
140
- // Check for WooCommerce 2.0 and display the cart widget
141
- if ( version_compare( WOOCOMMERCE_VERSION, "2.0.0" ) >= 0 ) {
142
- the_widget( 'WC_Widget_Cart', 'title=' );
143
- } else {
144
- the_widget( 'WooCommerce_Widget_Cart', 'title=' );
145
- }
146
  }
147
- echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
  }
150
  }
@@ -166,4 +179,4 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
166
 
167
  $WC_ct = new WC_ct();
168
  }
169
- }
2
  /*
3
  Plugin Name: WooCommerce Cart Tab
4
  Plugin URI: http://jameskoster.co.uk/tag/cart-tab/
5
+ Version: 0.2
6
  Description: Displays a sitewide link to the cart which reveals the cart contents on hover.
7
  Author: jameskoster
8
  Tested up to: 3.6
46
  ),
47
  array(
48
  'name' => __( 'Cart Widget', 'woocommerce-cart-tab' ),
49
+ 'desc' => __( 'Display the cart widget on hover', 'woocommerce-cart-tab' ),
50
  'id' => 'wc_ct_cart_widget',
51
  'type' => 'checkbox'
52
  ),
53
+ array(
54
+ 'name' => __( 'Hide Empty Cart', 'woocommerce-cart-tab' ),
55
+ 'desc' => __( 'Hide the cart tab if the cart is empty', 'woocommerce-cart-tab' ),
56
+ 'id' => 'wc_ct_hide_empty_cart',
57
+ 'type' => 'checkbox'
58
+ ),
59
  array(
60
  'name' => __( 'Use the light or dark skin', 'woocommerce-cart-tab' ),
61
  'id' => 'wc_ct_skin',
80
 
81
  // Default options
82
  add_option( 'wc_ct_cart_widget', 'yes' );
83
+ add_option( 'wc_ct_hide_empty_cart', 'no' );
84
  add_option( 'wc_ct_skin', 'light' );
85
  add_option( 'wc_ct_horizontal_position', 'right' );
86
 
132
  // Display the cart tab and widget
133
  function woocommerce_cart_tab() {
134
  global $woocommerce;
135
+ $skin = get_option( 'wc_ct_skin' );
136
+ $position = get_option( 'wc_ct_horizontal_position' );
137
+ $widget = get_option( 'wc_ct_cart_widget' );
138
+ $hide_widget = get_option( 'wc_ct_hide_empty_cart' );
139
+
140
+ if ( sizeof( $woocommerce->cart->cart_contents ) == 0 && $hide_widget == 'yes' ) {
141
+ // hide empty cart
142
+ } else {
143
+ if ( ! is_cart() && ! is_checkout() ) {
 
 
144
  if ( $widget == 'yes' ) {
145
+ echo '<div class="' . $position . ' cart-tab ' . $skin . '">';
146
+ } else {
147
+ echo '<div class="' . $position . ' cart-tab no-animation ' . $skin . '">';
 
 
 
148
  }
149
+ wcct_cart_button();
150
+ // Display the widget if specified
151
+ if ( $widget == 'yes' ) {
152
+ // Check for WooCommerce 2.0 and display the cart widget
153
+ if ( version_compare( WOOCOMMERCE_VERSION, "2.0.0" ) >= 0 ) {
154
+ the_widget( 'WC_Widget_Cart', 'title=' );
155
+ } else {
156
+ the_widget( 'WooCommerce_Widget_Cart', 'title=' );
157
+ }
158
+ }
159
+ echo '</div>';
160
+ }
161
  }
162
  }
163
  }
179
 
180
  $WC_ct = new WC_ct();
181
  }
182
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: jameskoster
3
  Tags: woocommerce, ecommerce, cart
4
  Requires at least: 3.5
5
  Tested up to: 3.6
6
- Stable tag: 0.1.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -46,6 +46,9 @@ Thanks! Please fork the repo on <a href="https://github.com/jameskoster/woocomme
46
 
47
  == Changelog ==
48
 
 
 
 
49
  = 0.1.1 - 30/05/2013 =
50
  * Improved i18n
51
  * added languages folder
3
  Tags: woocommerce, ecommerce, cart
4
  Requires at least: 3.5
5
  Tested up to: 3.6
6
+ Stable tag: 0.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
46
 
47
  == Changelog ==
48
 
49
+ = 0.2 - 01/07/2013 =
50
+ * Added option to hide cart tab if the cart is empty. Kudos azhkuro.
51
+
52
  = 0.1.1 - 30/05/2013 =
53
  * Improved i18n
54
  * added languages folder