Skip to content

Instantly share code, notes, and snippets.

@omniacode
Created December 9, 2016 02:37
Show Gist options
  • Save omniacode/abab87b6771a928d89736ca971ae7f9f to your computer and use it in GitHub Desktop.
Save omniacode/abab87b6771a928d89736ca971ae7f9f to your computer and use it in GitHub Desktop.
// -- WooCommmerce Mods
// Bypass View Cart Page in WooCommerce
function ultimate_redirect_to_checkout() {
global $woocommerce;
// Remove the default `Added to cart` message
wc_clear_notices();
return $woocommerce->cart->get_checkout_url();
}
add_filter ( 'add_to_cart_redirect', 'ultimate_redirect_to_checkout' );
// Global redirect to check out when hitting cart page
function ultimate_redirect_to_checkout_if_cart() {
if ( !is_cart() ) return;
global $woocommerce;
// Redirect to check out url
wp_redirect( $woocommerce->cart->get_checkout_url(), '301' );
exit;
}
add_action( 'template_redirect', 'ultimate_redirect_to_checkout_if_cart' );
// Empty cart each time you click on add cart to avoid multiple element selected
function ultimate_clear_cart () {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
add_action( 'woocommerce_add_cart_item_data', 'ultimate_clear_cart', 0 );
// Change Add to Cart Text
function custom_cart_button_text() {
return __( 'Sign Up Now', 'woocommerce' );
}
add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' );
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_cart_button_text' );
// Unset all options related to the cart
update_option( 'woocommerce_cart_redirect_after_add', 'no' );
update_option( 'woocommerce_enable_ajax_add_to_cart', 'no' );
// Remove WooCommerce Product Page Breadcrumbs
function child_remove_woo_breadcrumbs() {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_breadcrumb', 3 );
}
add_action( 'init', 'child_remove_woo_breadcrumbs' );
// Remove Product Image on Single Product Page
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
//
// -- End WooCommmerce Mods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment