add_action('woocommerce_cart_actions', function() {
?>
<a class="button wc-backward" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> <?php _e( 'Return to shop', 'woocommerce' ) ?> </a>
<?php
});
woocommerce
woo products per page
//woo Change number of products that are displayed per page (shop page)
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options –> Reading
// Return the number of products you wanna show per page.
$cols = 12;
return $cols;
}
woo clear cart button
//Add clear cart button on checkout page
// check for empty-cart get param to clear the cart
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
global $woocommerce;
if ( isset( $_GET['empty-cart'] ) ) {
$woocommerce->cart->empty_cart();
}
}
add_action( 'woocommerce_cart_actions', 'patricks_add_clear_cart_button', 20 );
function patricks_add_clear_cart_button() {
echo "<a class='button' href='?empty-cart=true'>" . __( 'Empty Cart', 'woocommerce' ) . "</a>";
}
woo breadcrumb replace home link url
// Replace the home link URL
add_filter( 'woocommerce_breadcrumb_home_url', 'woo_custom_breadrumb_home_url' );
function woo_custom_breadrumb_home_url() {
return 'http://woocommerce.com';
}
woo change order status on payment
add_action( 'sliced_payment_made', 'sliced_woocommerce_set_order_status_2018_08_17', 10, 3 );
function sliced_woocommerce_set_order_status_2018_08_17( $id, $gateway, $status ) {
if( $status === 'success' ) {
$order_id = get_post_meta( $id, '_sliced_invoice_woocommerce_order', true );
if( $order_id ) {
// update woocommerce order status to 'completed'
$order = new WC_Order($order_id);
$order->update_status('completed');
} else {
return; // not tied to woocommerce order
}
}
}
woo change number of products per page
// Display 2 products per page. Goes in functions.php
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 2;' ), 20 );
woo change products per row
// Change number of products per row
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 4; // 4 products per row
}
}
remove woo ads
// Fix woo ads: add_filter('woocommerce_allow_marketplace_suggestions', '__return_false');
// Fix Jetpack ads: add_filter( 'jetpack_show_promotions', '__return_false', 20 );