Skip to content

Instantly share code, notes, and snippets.

@sudopower
Last active November 16, 2018 13:12
Show Gist options
  • Save sudopower/a1ac46dba12c0afabe021fadeeb3c4eb to your computer and use it in GitHub Desktop.
Save sudopower/a1ac46dba12c0afabe021fadeeb3c4eb to your computer and use it in GitHub Desktop.
replace add to cart with something else
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_cart_button_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_cart_button_text' );
function custom_cart_button_text($text) {
global $woocommerce;
global $post;
$post_id = $post->ID;
if($post_id == 287){
$text = __( 'View Catalog', 'woocommerce' );
}
return $text;
}
add_filter ('woocommerce_add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout($url) {
global $woocommerce;
if ( isset( $_POST['add-to-cart'] ) ) {
unset($_POST['add-to-cart']);
if($product_id == 287){
$url = 'https://prettywild.co.in/product/aleeza/';
}
}
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment