Skip to content

Instantly share code, notes, and snippets.

@edtoken
Created February 7, 2014 21:08
Show Gist options
  • Save edtoken/8871877 to your computer and use it in GitHub Desktop.
Save edtoken/8871877 to your computer and use it in GitHub Desktop.
$url = apply_filters( 'add_to_cart_redirect', $url, $product_id );
// If has custom URL redirect there
if ( $url ) {
wp_safe_redirect( $url );
exit;
}
// Redirect to cart option
elseif ( get_option('woocommerce_cart_redirect_after_add') == 'yes' && $woocommerce->error_count() == 0 ) {
wp_safe_redirect( $woocommerce->cart->get_cart_url() );
exit;
}
// Redirect to page without querystring args
elseif ( wp_get_referer() ) {
wp_safe_redirect( add_query_arg( 'added-to-cart', implode( ',', $added_to_cart ), remove_query_arg( array( 'add-to-cart', 'quantity', 'product_id' ), wp_get_referer() ) ) );
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment