Skip to content

Instantly share code, notes, and snippets.

@sarangs07
Last active July 22, 2020 08:48
Show Gist options
  • Save sarangs07/21c4efc3ccb1b42ebee5801008a09e13 to your computer and use it in GitHub Desktop.
Save sarangs07/21c4efc3ccb1b42ebee5801008a09e13 to your computer and use it in GitHub Desktop.
Change the add-to-cat button URL
/*
* How to add the custome code.
*
* Please follow below instructions:
* 1. Copy the below code.
* 2. Open your child theme's functions.php file.
* 3. Paste the copied code at the very bottom of it & save the file OR upload it on your server/hosting.
*/
/* Change the add-to-cat button URL */
add_filter( 'woocommerce_add_to_cart_form_action', 'pp_change_butn_url' );
function pp_change_butn_url( $url ){
global $post;
if( your_product_id === $post->ID ){
$url = "add_your_landing_page_url";
}
return $url;
}
/* Change the add-to-cat button URL */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment