I've been trying to setup a rule for about a week, to send me an email when a customers Ubercart shopping cart is abandoned. I want to know if the customer has entered any info so we can determine if a customer called sales or not. http://drupal.org/project/uc_abandoned_msg is not what I'm looking for.

Below you will find the export of my rule. I can get it to work when I manually change the order status through store -> orders but when the system automatically updates the status from "check out" to "abandoned" it won't fire off an email. None of the other data selectors seem to make any sense outside of "order status". Thoughts?

{ "rules_abandoned_cart_admin_email" : {
    "LABEL" : "Abandoned Cart Admin Email",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "ubercart" ],
    "REQUIRES" : [ "rules", "mimemail", "uc_order" ],
    "ON" : [ "uc_order_status_update" ],
    "IF" : [
      { "data_is" : { "data" : [ "order:order-status" ], "value" : "abandoned" } }
    ],
    "DO" : [
      { "mimemail" : {
          "to" : "my@email.com",
          "subject" : "Order #: [order:order-number] [order:order-status]",
          "body" : "Order abandoned on [order:created]: [order:admin-link]\r\n\r\nName on Order: [order:first-name] [order:last-name]\r\nEmail of Order: [order:email]\r\nNew User: [order:new-username]\r\nExisting User: [order:customer]\r\nShipping Phone Number: [order:shipping-phone]\r\nBilling Phone Number: [order:billing-phone]\r\n\r\nSubtotal: [order:subtotal]\r\nOrder Total: [order:order-total]\r\n\r\nComments left by customer:\r\n[order:comments]"
        }
      }
    ]
  }
}

Comments

MakeOnlineShop’s picture

Hello,

I am also looking for a solution but for Drupal 6 Ubercart 2, any idea ?

Thanks.

DanZ’s picture

You are testing on the pre-change order status (which will be "In checkout"). You need to test on the updated order status (which will be "Abandoned").

{ "rules_test_order_update" : {
    "LABEL" : "Test order update",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "uc_order" ],
    "ON" : [ "uc_order_status_update" ],
    "IF" : [
      { "data_is" : { "data" : [ "updated-order:order-status" ], "value" : "abandoned" } }
    ],
    "DO" : []
  }
}

I had a look at the code for Ubercart 3:

The abandonment of orders appears to be handled by uc_cart_cron(), which eventually calls

    uc_order_update_status($order_id, 'abandoned');

uc_order_update_status() invokes the Rules event you need, as such:

    rules_invoke_event('uc_order_status_update', $order, $updated);

So, you should be able to create a Rule that will catch an order moving into Abandoned status.

If you're sure that you're doing everything right, but it's still not working, post your results here as a bug report.

DanZ’s picture

Status: Active » Fixed

For Drupal 6 / Ubercart 2, check the Conditional Actions configuration. You should be able to do something similar.

philsward’s picture

Status: Fixed » Closed (fixed)

Thanks @DanZ.

I ended up setting this up right (updated-order:order-status) on a sandbox and since it's a sandbox, I didn't play around with any checkout's to know that I had it set right... (Only at the order itself)

When I added it to my live site, I ended up with the (order:order-status) which obviously is wrong. Doing some testing tonight on the sandbox, I realized that it was working there, leaving me scratching my head. That's when I finally started looking at the sandbox vs live and noticed my mistake. (So many selectors to choose from!!) Anywho, I was getting ready to post the update to my dilemma and noticed you posted a fix.

Thanks for the additional info too! I wasn't able to find anywhere that explains how to do this task, so hopefully this issue will get some good page rank.