Skip to content

Instantly share code, notes, and snippets.

@alanef
Last active February 3, 2022 12:31
Show Gist options
  • Select an option

  • Save alanef/306d7a438a55ba9959267e6e4c0a1c27 to your computer and use it in GitHub Desktop.

Select an option

Save alanef/306d7a438a55ba9959267e6e4c0a1c27 to your computer and use it in GitHub Desktop.
<?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