Skip to content

Instantly share code, notes, and snippets.

@ibndawood
Created May 18, 2020 18:55
Show Gist options
  • Save ibndawood/b9be9ac4e32d84da84154e40fc5e587d to your computer and use it in GitHub Desktop.
Save ibndawood/b9be9ac4e32d84da84154e40fc5e587d to your computer and use it in GitHub Desktop.
Electro v2 - Off-Canvas menu should redirect to Cart page in Checkout
function electro_header_mini_cart_icon() {
if( true === electro_get_shop_catalog_mode() ) {
return;
}
$header_cart_icon = apply_filters( 'electro_header_cart_icon', 'ec ec-shopping-bag' );
$disable_header_cart_dropdown = apply_filters( 'electro_header_cart_dropdown_disable', false );
$cart_link = '';
if( apply_filters( 'electro_off_canvas_cart', true ) ) {
$cart_link = '#off-canvas-cart-summary';
$disable_header_cart_dropdown = true;
if ( is_checkout() || is_cart() ) {
$cart_link = wc_get_cart_url();
}
} else {
$cart_link = wc_get_cart_url();
}
$header_tooltip_placement = apply_filters( 'electro_header_tooltip_placement', 'bottom' );
?><div class="header-icon header-icon__cart <?php if ( ! $disable_header_cart_dropdown ): ?>animate-dropdown dropdown<?php endif; ?>"<?php if ( $header_tooltip_placement ) : ?>data-toggle="tooltip" data-placement="<?php echo esc_attr( $header_tooltip_placement ); ?>" data-title="<?php echo esc_attr( esc_html__( 'Cart', 'electro' ) ); ?>"<?php endif; ?>>
<a href="<?php echo esc_url( $cart_link ); ?>" <?php if ( ! $disable_header_cart_dropdown ): ?>data-toggle="dropdown"<?php endif; ?>>
<i class="<?php echo esc_attr( $header_cart_icon ); ?>"></i>
<span class="cart-items-count count header-icon-counter"><?php $cart_count = WC()->cart->get_cart_contents_count(); echo $cart_count > 10 ? '*': $cart_count; ?></span>
<span class="cart-items-total-price total-price"><?php echo WC()->cart->get_cart_subtotal(); ?></span>
</a>
<?php if ( ! $disable_header_cart_dropdown ) {
if ( is_wc_gateway_ppec() ) {
if ( is_cart() == false && is_checkout() == false ) {
?>
<ul class="dropdown-menu dropdown-menu-mini-cart">
<li>
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
<?php }
} else { ?>
<ul class="dropdown-menu dropdown-menu-mini-cart">
<li>
<div class="widget_shopping_cart_content">
<?php woocommerce_mini_cart();?>
</div>
</li>
</ul><?php
}
} ?>
</div><?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment