Last active
February 3, 2022 12:31
-
-
Save alanef/306d7a438a55ba9959267e6e4c0a1c27 to your computer and use it in GitHub Desktop.
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
| <?php | |
| add_filter( 'woocommerce_return_to_shop_redirect', function ( $shop_url ) { | |
| if ( is_cart() && wc()->cart->cart_contents_count == 0 ) { | |
| $deleted_items = wc()->cart->get_removed_cart_contents(); | |
| $deleted_items = array_reverse( $deleted_items ); | |
| foreach ( $deleted_items as $deleted_item ) { | |
| $deleted_id = (int) $deleted_item['product_id']; | |
| $vendor_id = wcfm_get_vendor_id_by_post( $deleted_id ); | |
| if ( $vendor_id ) { | |
| return wcfmmp_get_store_url( $vendor_id ); | |
| } | |
| } | |
| } | |
| return $shop_url; | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment