Rules integration with ubercart

Amitaibu - November 19, 2008 - 09:05
Project:Ubercart
Version:6.x-2.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Amitaibu
Status:needs work
Issue tags:CA, rules integration
Description

I keep it on CNR, until the predicate section is ready.

AttachmentSize
ubercart_cart_rules_1.patch2.54 KB

#1

rszrama - November 19, 2008 - 22:31

What I'm curious to see is if we can write code that instead of redefining everything simply passes on the parameters straight to the CA equivalent functions. In other words, we'd have function wrappers for the conditions that could translate between Rules and CA data structures. I was under the impression that we were pretty similar, so duplicating the code seems avoidable.

#2

rszrama - February 6, 2009 - 18:52

#3

opensanta - March 15, 2009 - 02:59
Issue tags:+rules integration

adding rules integration tag

#4

Amitaibu - May 25, 2009 - 16:35
Title:Rules integration with uc_cart» Rules integration with ubercart

I'm making it a central place for my work. I know there is still no agreement on the right path, but I think once there is some code we can discuss it's better than nothing.

This is an untested patch, mostly find & replace + a new action 'Load order by ID'. I was able to create an action, and I'll share it here (import uc_order.txt):
1) When a node is viewed as a page >>
2) Load order ID = 1 (you can change it to your own desired ID). >>
3) Add an order comment

AttachmentSize
uc-rules.patch 42 KB
uc_order.txt 2.64 KB

#5

cYu - June 8, 2009 - 16:10

I was under the impression that we were pretty similar, so duplicating the code seems avoidable.

Would that not be a good reason for running with this patch as is, as a replacement of CA with Rules integration? Why have two similar modules, one maintained solely for UC purposes when you could take advantage of a solid community supported/tested/integrated module? It is in the same realm as UC adding CCK and Views dependencies, both of which look to have solid support at http://www.ubercart.org/forum/development/11216/adding_dependencies_uc_3x

I'm familiar with how it was arrived at that CA exists, and I don't want to rehash all of http://www.ubercart.org/forum/development/5555/rules_vs_conditional_actions but it seems like the major stumbling block with replacing CA with Rules integration was that nobody had written it. Now that someone is willing to write it, would it be reasonable to expect that this could happen...perhaps in tandem with CA in the 2 branch and as a replacement in UC 3.x?

#6

torgosPizza - June 9, 2009 - 23:40

+1. Subscribing.

#7

fago - July 31, 2009 - 10:48

oh, haven't seen this issue yet. I also think the direction explained in #1 makes sense. I did a similar thing for supporting core-actions in rules - get the metadata available and transform it automatically. Custom per condition/action fixes for rules can be applied by using hook_rules_action_info_alter() easily.

Though of course I don't know whether there are some troubles. Anyway if any further questions regarding this come up, of course feel free to contact me.

#8

redben - October 22, 2009 - 18:25

Subscribing

#9

tmallen - November 7, 2009 - 08:25

I'm not sure what the confusion's about...by integrating with Rules, Ubercart will have many more available actions and better support for these triggers/actions. What discernible benefits do Conditional Actions have? Clearly the Rules maintainer is more than happy to help with integration.

#10

tmallen - November 18, 2009 - 05:36

For anyone who needs this quickly...here's the horribly hackish solution I settled on. If I have the time though I'll try and distill it into something more reusable. First create a small custom module with the event(s) you want available in Rules. I called my module 'uc_rules':

<?php
function uc_rules_rules_event_info() {
    return array(
       
'product_purchased' => array(
           
'label' => t('A user buys a product'),
           
'module' => 'Ubercart',
           
'arguments' => array(
               
'customer' => array(
                   
'label' => 'Customer',
                   
'type' => 'user'
               
)
            )
        )
    );
}
?>

I based that on what I read at http://drupal.org/node/298549 , and on the contents of the rules API file included with the module.

Then have your predicate execute a PHP code action invoking the rule, like this:

<?php
rules_invoke_event
('product_purchased', $account);
?>

I hope this helps others on tight deadlines.

#11

trupal218 - November 25, 2009 - 02:14

subscribing

 
 

Drupal is a registered trademark of Dries Buytaert.