Hook in woocommerce_widget_shopping_cart_buttons for greater flexibility

This commit is contained in:
Mike Jolley 2016-07-28 15:06:51 +01:00
parent a5ba8a05ed
commit 4a23c41ab2
5 changed files with 36 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -1140,6 +1140,10 @@ p.demo_store {
.buttons {
@include clearfix();
a {
margin-right: 5px;
margin-bottom: 5px;
}
}
}

View File

@ -606,7 +606,7 @@ if ( ! function_exists( 'woocommerce_product_archive_description' ) ) {
if ( is_search() ) {
return;
}
if ( is_post_type_archive( 'product' ) && 0 === absint( get_query_var( 'paged' ) ) ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
@ -1364,7 +1364,29 @@ if ( ! function_exists( 'woocommerce_button_proceed_to_checkout' ) ) {
}
}
if ( ! function_exists( 'woocommerce_widget_shopping_cart_button_view_cart' ) ) {
/**
* Output the proceed to checkout button.
*
* @subpackage Cart
*/
function woocommerce_widget_shopping_cart_button_view_cart() {
echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . __( 'View Cart', 'woocommerce' ) . '</a>';
}
}
if ( ! function_exists( 'woocommerce_widget_shopping_cart_proceed_to_checkout' ) ) {
/**
* Output the proceed to checkout button.
*
* @subpackage Cart
*/
function woocommerce_widget_shopping_cart_proceed_to_checkout() {
echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="button checkout wc-forward">' . __( 'Checkout', 'woocommerce' ) . '</a>';
}
}
/** Mini-Cart *************************************************************/

View File

@ -204,6 +204,11 @@ add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_for
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
/**
* Cart widget
*/
add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_button_view_cart', 10 );
add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
/**
* Cart.

View File

@ -31,7 +31,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( ! WC()->cart->is_empty() ) : ?>
<?php do_action( 'woocommerce_before_mini_cart_contents' ); ?>
<?php
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
@ -70,7 +70,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<?php do_action( 'woocommerce_mini_cart_contents' ); ?>
<?php else : ?>
<li class="empty"><?php _e( 'No products in the cart.', 'woocommerce' ); ?></li>
@ -86,8 +86,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?>
<p class="buttons">
<a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="button wc-forward"><?php _e( 'View Cart', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="button checkout wc-forward"><?php _e( 'Checkout', 'woocommerce' ); ?></a>
<?php do_action( 'woocommerce_widget_shopping_cart_buttons' ); ?>
</p>
<?php endif; ?>