Merge pull request #22123 from helgatheviking/additional-args-for-woocommerce_add_to_cart_redirect

Add param for woommerce_add_to_cart_redirect filter
This commit is contained in:
Mike Jolley 2019-01-09 11:53:26 +00:00 committed by GitHub
commit 8edadae4df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -731,7 +731,7 @@ class WC_Form_Handler {
// If we added the product to the cart we can now optionally do a redirect. // If we added the product to the cart we can now optionally do a redirect.
if ( $was_added_to_cart && 0 === wc_notice_count( 'error' ) ) { if ( $was_added_to_cart && 0 === wc_notice_count( 'error' ) ) {
if ( $url = apply_filters( 'woocommerce_add_to_cart_redirect', $url ) ) { if ( $url = apply_filters( 'woocommerce_add_to_cart_redirect', $url, $adding_to_cart ) ) {
wp_safe_redirect( $url ); wp_safe_redirect( $url );
exit; exit;
} elseif ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { } elseif ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {

View File

@ -544,7 +544,7 @@ class WC_Frontend_Scripts {
'ajax_url' => WC()->ajax_url(), 'ajax_url' => WC()->ajax_url(),
'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
'i18n_view_cart' => esc_attr__( 'View cart', 'woocommerce' ), 'i18n_view_cart' => esc_attr__( 'View cart', 'woocommerce' ),
'cart_url' => apply_filters( 'woocommerce_add_to_cart_redirect', wc_get_cart_url() ), 'cart_url' => apply_filters( 'woocommerce_add_to_cart_redirect', wc_get_cart_url(), null ),
'is_cart' => is_cart(), 'is_cart' => is_cart(),
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' ), 'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' ),
); );