user empties cart how do I redirect that user to originating page I have a rule


  Redirect to cart after adding a registration


this rule works exactly as planned. 



New scenario and new rule, If the user empties their cart of all products, I want to redirect to previous page (the sending page).

New rule


  Redirect user to originating page after removing all items from cart


I have the Event and the Conditions but I don't see how to massage the originating address that was used to get to the cart. The originating form action is &lt;input type="submit" id="edit-submit" name="op" value="Add to cart" class="form-submit"&gt;.

{ "rules_redirect_user_to_originating_page_after_removing_all_items" : {
    "LABEL" : "Redirect user to originating page after removing all items from cart",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Cart" ],
    "REQUIRES" : [ "rules", "commerce_cart" ],
    "ON" : { "commerce_cart_product_remove" : [] },
    "IF" : [ { "data_is_empty" : { "data" : [ "quantity" ] } } ],
    "DO" : []
  }
}


Can anyone help?
In your first rule "Redirect to cart after adding a registration" you probably are using a "Page redirect" action. If so you can do the following.

Edit this action and set "APPEND DESTINATION PARAMETER" to true (see screenshot). 
This will add the referring page as a query parameter to your url e.g. example.com/cart?destination=node/3 

Then in your second rule you can retrieve this destination parameter by using the function drupal_get_destination. Use the return value of that function in the drupal_goto function and the user will be redirected to the url they were coming from.

{ "rules_redirect_user_to_originating_page_after_removing_all_items" : {
    "LABEL" : "Redirect user to originating page after removing all items from cart",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Cart" ],
    "REQUIRES" : [ "php", "rules", "commerce_cart" ],
    "ON" : { "commerce_cart_product_remove" : [] },
    "DO" : [
      { "php_eval" : { "code" : "drupal_goto (drupal_get_destination());" } }
    ]
  }
}