Guest User

Untitled

a guest
Apr 15th, 2019
2,731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. //* Skip Cart Function by Sorin Marta @ MemberFix
  2.  
  3. add_filter ('woocommerce_add_to_cart_redirect', 'sorinmarta_redirect_to_checkout');
  4. function sorinmarta_redirect_to_checkout() {
  5.     $checkout_url = WC()->cart->get_checkout_url();
  6.     return $checkout_url;
  7. }
  8.  
  9. add_action( 'wp_head', 'sorinmarta_clear_cart' );
  10. function sorinmarta_clear_cart() {
  11.     if ( wc_get_page_id( 'cart' ) == get_the_ID() || wc_get_page_id( 'checkout' ) == get_the_ID() ) {
  12.         return;
  13.     }
  14.     WC()->cart->empty_cart( true );
  15. }
Advertisement
Add Comment
Please, Sign In to add comment