Skip to content

Instantly share code, notes, and snippets.

@frankschrijvers
Last active July 17, 2021 04:11
Show Gist options
  • Save frankschrijvers/4b7bd3c273128a53c80d to your computer and use it in GitHub Desktop.
Save frankschrijvers/4b7bd3c273128a53c80d to your computer and use it in GitHub Desktop.
Add WooCommerce mini cart to primary nav Genesis
/**
* 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