Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save WPDevHQ/0abd3e28313ab8f40622721393ada26f to your computer and use it in GitHub Desktop.
Save WPDevHQ/0abd3e28313ab8f40622721393ada26f to your computer and use it in GitHub Desktop.
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
add_action( 'woocommerce_proceed_to_checkout', 'change_url_to_checkout', 20 );
function change_url_to_checkout() {
$cart = WC()->cart->get_cart();
$url = '';
foreach ( $cart as $item ) {
if ( $item['product_id'] === 70 ) {
$url = 'put_your_extra_page_url_here';
break;
}
}
if ( empty( $url ) ) {
return;
}
?>
<a href="<?php echo esc_url( $url ); ?>" class="checkout-button button alt wc-forward">Your checkout</a>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment