Version Description
- Improved accessibility for screen readers (cart icon)
- Tested up to WC3.8
- Tested up to WP5.3
Download this release
Release Info
Developer | pomegranate |
Plugin | WooCommerce Menu Cart |
Version | 2.7.6 |
Comparing to | |
See all releases |
Code changes from version 2.7.5 to 2.7.6
- includes/wpmenucart-woocommerce.php +67 -27
- readme.txt +7 -2
- wp-menu-cart.php +5 -5
includes/wpmenucart-woocommerce.php
CHANGED
@@ -8,43 +8,32 @@ if ( ! class_exists( 'WPMenuCart_WooCommerce' ) ) {
|
|
8 |
}
|
9 |
|
10 |
public function menu_item() {
|
11 |
-
global $woocommerce;
|
12 |
-
|
13 |
// make sure cart is loaded! https://wordpress.org/support/topic/activation-breaks-customise?replies=10#post-7908988
|
14 |
-
|
15 |
-
$woocommerce->cart = new WC_Cart();
|
16 |
-
}
|
17 |
-
|
18 |
-
// $woocommerce->cart->get_cart_total() is not a display function,
|
19 |
-
// so we add tax if cart prices are set to display incl. tax
|
20 |
-
// see https://github.com/woothemes/woocommerce/issues/6701
|
21 |
-
$settings = get_option('wpmenucart');
|
22 |
-
if (isset($settings['total_price_type']) && $settings['total_price_type'] == 'subtotal') {
|
23 |
-
// Display varies depending on settings
|
24 |
-
if ( $woocommerce->cart->display_cart_ex_tax ) {
|
25 |
-
$cart_contents_total = wc_price( $woocommerce->cart->subtotal_ex_tax );
|
26 |
-
} else {
|
27 |
-
$cart_contents_total = wc_price( $woocommerce->cart->subtotal );
|
28 |
-
}
|
29 |
-
} else {
|
30 |
-
if ( $woocommerce->cart->display_cart_ex_tax ) {
|
31 |
-
$cart_contents_total = wc_price( $woocommerce->cart->cart_contents_total );
|
32 |
-
} else {
|
33 |
-
$cart_contents_total = wc_price( $woocommerce->cart->cart_contents_total + $woocommerce->cart->tax_total );
|
34 |
-
}
|
35 |
-
}
|
36 |
-
$cart_contents_total = apply_filters( 'woocommerce_cart_contents_total', $cart_contents_total );
|
37 |
|
38 |
$menu_item = array(
|
39 |
'cart_url' => $this->cart_url(),
|
40 |
'shop_page_url' => $this->shop_url(),
|
41 |
-
'
|
42 |
-
'
|
43 |
);
|
44 |
|
45 |
return $menu_item;
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
public function cart_url() {
|
49 |
if ( defined('WOOCOMMERCE_VERSION') && version_compare( WOOCOMMERCE_VERSION, '2.5.2', '>=' ) ) {
|
50 |
return wc_get_cart_url();
|
@@ -65,5 +54,56 @@ if ( ! class_exists( 'WPMenuCart_WooCommerce' ) ) {
|
|
65 |
return get_permalink( woocommerce_get_page_id( 'shop' ) );
|
66 |
}
|
67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
}
|
8 |
}
|
9 |
|
10 |
public function menu_item() {
|
|
|
|
|
11 |
// make sure cart is loaded! https://wordpress.org/support/topic/activation-breaks-customise?replies=10#post-7908988
|
12 |
+
$this->maybe_load_cart();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
$menu_item = array(
|
15 |
'cart_url' => $this->cart_url(),
|
16 |
'shop_page_url' => $this->shop_url(),
|
17 |
+
'cart_total' => strip_tags( $this->get_cart_total() ),
|
18 |
+
'cart_contents_count' => $this->get_cart_contents_count(),
|
19 |
);
|
20 |
|
21 |
return $menu_item;
|
22 |
}
|
23 |
|
24 |
+
public function maybe_load_cart() {
|
25 |
+
if ( function_exists( 'WC' ) ) {
|
26 |
+
if ( empty( WC()->cart ) ) {
|
27 |
+
WC()->cart = new WC_Cart();
|
28 |
+
}
|
29 |
+
} else {
|
30 |
+
global $woocommerce;
|
31 |
+
if ( empty( $woocommerce->cart ) ) {
|
32 |
+
$woocommerce->cart = new WC_Cart();
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
public function cart_url() {
|
38 |
if ( defined('WOOCOMMERCE_VERSION') && version_compare( WOOCOMMERCE_VERSION, '2.5.2', '>=' ) ) {
|
39 |
return wc_get_cart_url();
|
54 |
return get_permalink( woocommerce_get_page_id( 'shop' ) );
|
55 |
}
|
56 |
}
|
57 |
+
|
58 |
+
public function get_cart_contents_count() {
|
59 |
+
if ( function_exists( 'WC' ) ) {
|
60 |
+
return WC()->cart->get_cart_contents_count();
|
61 |
+
} else {
|
62 |
+
return $GLOBALS['woocommerce']->cart->get_cart_contents_count();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
public function get_cart_total() {
|
67 |
+
$settings = get_option('wpmenucart');
|
68 |
+
if ( defined('WC_VERSION') && version_compare( WC_VERSION, '3.2', '>=' ) ) {
|
69 |
+
if (isset($settings['total_price_type']) && $settings['total_price_type'] == 'subtotal') {
|
70 |
+
if ( WC()->cart->display_prices_including_tax() ) {
|
71 |
+
$cart_contents_total = wc_price( WC()->cart->get_subtotal() + WC()->cart->get_subtotal_tax() );
|
72 |
+
} else {
|
73 |
+
$cart_contents_total = wc_price( WC()->cart->get_subtotal() );
|
74 |
+
}
|
75 |
+
} else {
|
76 |
+
if ( WC()->cart->display_prices_including_tax() ) {
|
77 |
+
$cart_contents_total = wc_price( WC()->cart->get_cart_contents_total() + WC()->cart->get_fee_tax() + WC()->cart->get_cart_contents_tax() );
|
78 |
+
} else {
|
79 |
+
$cart_contents_total = wc_price( WC()->cart->get_cart_contents_total() );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
// Backwards compatibility
|
84 |
+
global $woocommerce;
|
85 |
+
|
86 |
+
// $woocommerce->cart->get_cart_total() is not a display function,
|
87 |
+
// so we add tax if cart prices are set to display incl. tax
|
88 |
+
// see https://github.com/woothemes/woocommerce/issues/6701
|
89 |
+
if (isset($settings['total_price_type']) && $settings['total_price_type'] == 'subtotal') {
|
90 |
+
// Display varies depending on settings
|
91 |
+
if ( $woocommerce->cart->display_cart_ex_tax ) {
|
92 |
+
$cart_contents_total = wc_price( $woocommerce->cart->subtotal_ex_tax );
|
93 |
+
} else {
|
94 |
+
$cart_contents_total = wc_price( $woocommerce->cart->subtotal );
|
95 |
+
}
|
96 |
+
} else {
|
97 |
+
if ( $woocommerce->cart->display_cart_ex_tax ) {
|
98 |
+
$cart_contents_total = wc_price( $woocommerce->cart->cart_contents_total );
|
99 |
+
} else {
|
100 |
+
$cart_contents_total = wc_price( $woocommerce->cart->cart_contents_total + $woocommerce->cart->tax_total );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
$cart_contents_total = apply_filters( 'woocommerce_cart_contents_total', $cart_contents_total );
|
104 |
+
}
|
105 |
+
|
106 |
+
return $cart_contents_total;
|
107 |
+
}
|
108 |
}
|
109 |
}
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: jprummer, pomegranate
|
|
3 |
Donate link: https://www.wpovernight.com/
|
4 |
Tags: woocommerce, menu, bar, cart, basket, header, shopping cart, navigation, edd, ecommerce, eshop, wp-ecommerce, jigoshop, wpec
|
5 |
Requires at least: 3.4
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.7.
|
9 |
|
10 |
Automatically displays a shopping cart in your menu bar. Works with WooCommerce, WP-Ecommerce, EDD, Eshop and Jigoshop
|
11 |
|
@@ -85,6 +85,11 @@ Once the plugin is activated navigate to Settings > Menu Cart Setup. Select your
|
|
85 |
|
86 |
== Changelog ==
|
87 |
|
|
|
|
|
|
|
|
|
|
|
88 |
= 2.7.5 =
|
89 |
* Fix: check if woocommerce version constant is defined
|
90 |
* Fix: Prevent fatal errors when switching eCommerce plugins
|
3 |
Donate link: https://www.wpovernight.com/
|
4 |
Tags: woocommerce, menu, bar, cart, basket, header, shopping cart, navigation, edd, ecommerce, eshop, wp-ecommerce, jigoshop, wpec
|
5 |
Requires at least: 3.4
|
6 |
+
Tested up to: 5.3
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.7.6
|
9 |
|
10 |
Automatically displays a shopping cart in your menu bar. Works with WooCommerce, WP-Ecommerce, EDD, Eshop and Jigoshop
|
11 |
|
85 |
|
86 |
== Changelog ==
|
87 |
|
88 |
+
= 2.7.6 =
|
89 |
+
* Improved accessibility for screen readers (cart icon)
|
90 |
+
* Tested up to WC3.8
|
91 |
+
* Tested up to WP5.3
|
92 |
+
|
93 |
= 2.7.5 =
|
94 |
* Fix: check if woocommerce version constant is defined
|
95 |
* Fix: Prevent fatal errors when switching eCommerce plugins
|
wp-menu-cart.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
* Plugin Name: WooCommerce Menu Cart
|
4 |
* Plugin URI: www.wpovernight.com/plugins
|
5 |
* Description: Extension for your e-commerce plugin (WooCommerce, WP-Ecommerce, Easy Digital Downloads, Eshop or Jigoshop) that places a cart icon with number of items and total cost in the menu bar. Activate the plugin, set your options and you're ready to go! Will automatically conform to your theme styles.
|
6 |
-
* Version: 2.7.
|
7 |
* Author: Jeremiah Prummer, Ewout Fernhout
|
8 |
* Author URI: www.wpovernight.com/
|
9 |
* License: GPL2
|
10 |
* Text Domain: wp-menu-cart
|
11 |
* WC requires at least: 2.0.0
|
12 |
-
* WC tested up to: 3.
|
13 |
*/
|
14 |
|
15 |
class WpMenuCart {
|
@@ -296,7 +296,7 @@ class WpMenuCart {
|
|
296 |
'wpmenucart',
|
297 |
plugins_url( '/javascript/wpmenucart.js' , __FILE__ ),
|
298 |
array( 'jquery' ),
|
299 |
-
'2.7.
|
300 |
true
|
301 |
);
|
302 |
|
@@ -326,7 +326,7 @@ class WpMenuCart {
|
|
326 |
'wpmenucart-edd-ajax',
|
327 |
plugins_url( '/javascript/wpmenucart-edd-ajax.js', __FILE__ ),
|
328 |
array( 'jquery' ),
|
329 |
-
'2.7.
|
330 |
);
|
331 |
|
332 |
wp_localize_script(
|
@@ -564,7 +564,7 @@ class WpMenuCart {
|
|
564 |
$menu_item_a_content = '';
|
565 |
if (isset($this->options['icon_display'])) {
|
566 |
$icon = isset($this->options['cart_icon']) ? $this->options['cart_icon'] : '0';
|
567 |
-
$menu_item_icon = '<i class="wpmenucart-icon-shopping-cart-'.$icon.'"></i>';
|
568 |
$menu_item_a_content .= $menu_item_icon;
|
569 |
} else {
|
570 |
$menu_item_icon = '';
|
3 |
* Plugin Name: WooCommerce Menu Cart
|
4 |
* Plugin URI: www.wpovernight.com/plugins
|
5 |
* Description: Extension for your e-commerce plugin (WooCommerce, WP-Ecommerce, Easy Digital Downloads, Eshop or Jigoshop) that places a cart icon with number of items and total cost in the menu bar. Activate the plugin, set your options and you're ready to go! Will automatically conform to your theme styles.
|
6 |
+
* Version: 2.7.6
|
7 |
* Author: Jeremiah Prummer, Ewout Fernhout
|
8 |
* Author URI: www.wpovernight.com/
|
9 |
* License: GPL2
|
10 |
* Text Domain: wp-menu-cart
|
11 |
* WC requires at least: 2.0.0
|
12 |
+
* WC tested up to: 3.8.0
|
13 |
*/
|
14 |
|
15 |
class WpMenuCart {
|
296 |
'wpmenucart',
|
297 |
plugins_url( '/javascript/wpmenucart.js' , __FILE__ ),
|
298 |
array( 'jquery' ),
|
299 |
+
'2.7.6',
|
300 |
true
|
301 |
);
|
302 |
|
326 |
'wpmenucart-edd-ajax',
|
327 |
plugins_url( '/javascript/wpmenucart-edd-ajax.js', __FILE__ ),
|
328 |
array( 'jquery' ),
|
329 |
+
'2.7.6'
|
330 |
);
|
331 |
|
332 |
wp_localize_script(
|
564 |
$menu_item_a_content = '';
|
565 |
if (isset($this->options['icon_display'])) {
|
566 |
$icon = isset($this->options['cart_icon']) ? $this->options['cart_icon'] : '0';
|
567 |
+
$menu_item_icon = '<i class="wpmenucart-icon-shopping-cart-'.$icon.'" role="img" aria-label="'.__( 'Cart','woocommerce' ).'"></i>';
|
568 |
$menu_item_a_content .= $menu_item_icon;
|
569 |
} else {
|
570 |
$menu_item_icon = '';
|