Created
October 16, 2023 06:39
-
-
Save ahmedeshaan/68a48632312adb1de794934e52ddc866 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('wp', 'fs_prevent_fkcart_hook', -10); | |
function fs_prevent_fkcart_hook() { | |
global $post; | |
// The product ID you want a specific redirect for | |
$matched_id = 8627035; | |
if( isset($post->ID) && $post->ID == $matched_id ) { | |
if( class_exists('\FKCart\Includes\Front') ) { | |
$fk_cart_instance = \FKCart\Includes\Front::get_instance(); | |
remove_action( 'wp', [ $fk_cart_instance, 'init_hooks' ] ); | |
} | |
} | |
} | |
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' ); | |
function custom_add_to_cart_redirect( $url ) { | |
// The product ID you want a specific redirect for | |
$matched_id = 8627035; | |
// If product ID matches, modify redirect | |
if ( isset( $_POST['add-to-cart'] ) && $matched_id == (int) $_POST['add-to-cart'] ) { | |
$url = 'https://stg-vipcarmountcom-staging.kinsta.cloud/refunds-policy/'; | |
} | |
// always return a value | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment