Created
April 23, 2020 00:54
-
-
Save MarceloGlez/4436da9a9a8244d01d6da6669524a4f6 to your computer and use it in GitHub Desktop.
2 maneras de enviar al checkout directamente después de añadir al carrito
This file contains hidden or 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
/*OPCIÓN 1: Primero activar checkbox "Redirigir a la página del carrito tras añadir productos con éxito"*/ | |
function cod_redirect_checkout_add_cart( $url ) { | |
$url = wc_get_page_permalink( 'checkout' ); | |
return $url; | |
} | |
add_filter( 'woocommerce_add_to_cart_redirect', 'cod_redirect_checkout_add_cart' ); | |
/*OPCIÓN 2*/ | |
/* Enviar directamente al pago */ | |
add_filter ('add_to_cart_redirect', 'redirect_to_checkout'); | |
function redirect_to_checkout() { | |
global $woocommerce; | |
$checkout_url = $woocommerce->cart->get_checkout_url(); | |
return $checkout_url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment