Title: Help finding syntax error
Last modified: February 2, 2022

---

# Help finding syntax error

 *  [teamgood](https://wordpress.org/support/users/teamgood/)
 * (@teamgood)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/help-finding-syntax-error/)
 * I was advised by theme developer to add this snippet to my theme’s function.php
   file to modify cart behavior. When I did I received a fatal error message due
   to a syntax error. Can someone please tell me what that error is:
 *     ```
       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;
       });
       ```
   
    -  This topic was modified 4 years, 3 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Developing with WordPress
      topic
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhelp-finding-syntax-error%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [4 years, 3 months ago](https://wordpress.org/support/topic/help-finding-syntax-error/#post-15319829)
 * Moved to Fixing WordPress, this is not an Developing with WordPress topic.
 * Please ask plugin specific questions in that plugin’s dedicated sub-forum instead.
 * [https://wordpress.org/support/plugin/woocommerce/](https://wordpress.org/support/plugin/woocommerce/)
 *  [Javier Arce](https://wordpress.org/support/users/javiarce/)
 * (@javiarce)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/help-finding-syntax-error/#post-15319833)
 * Hi, [@teamgood](https://wordpress.org/support/users/teamgood/)!
 * Could you ask the theme developer? Or, as [@jdembowski](https://wordpress.org/support/users/jdembowski/)
   mentioned, ask in the WooCommerce support forum?
 * Otherwise, you could try to debug the problem yourself activating the debug mode.
   Here’s how: [Debugging in WordPress](https://wordpress.org/support/article/debugging-in-wordpress/).
 * Also, just to make sure, there are some escaped quotes in your code. Maybe that
   was due to pasting the code here, but the code look like this:
 *     ```
       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;
         });
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Help finding syntax error’ is closed to new replies.

## Tags

 * [fatal error](https://wordpress.org/support/topic-tag/fatal-error/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Javier Arce](https://wordpress.org/support/users/javiarce/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/help-finding-syntax-error/#post-15319833)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
