Last active
July 17, 2021 04:11
-
-
Save frankschrijvers/4b7bd3c273128a53c80d to your computer and use it in GitHub Desktop.
Add WooCommerce mini cart to primary nav Genesis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add WooCommerce cart to primary navigation Genesis | |
* @author Frank Schrijvers | |
* @link https://www.wpstud.io/add-woocommerce-cart-to-genesis-navigation/ | |
*/ | |
if ( class_exists( 'WooCommerce' ) ) { | |
add_action( 'genesis_header_right', 'wpstudio_add_cart' ); | |
function wpstudio_add_cart() { | |
echo '<div class="mini-cart">'; | |
echo '<a href="' . WC()->cart->get_cart_url() .'"title="View your shopping cart">'. WC()->cart->get_cart_total(). '</a>'; | |
echo '<span class="cart-count">' . WC()->cart->cart_contents_count . '</span></div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment