I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
I have not used it yet but I certainly plan to. Have you looked at the rules module? http://drupal.org/project/rules
:ryan
bayousoft.com http://www.bayousoft.com twitter.com/bayousoft http://www.twitter.com/bayousoft
On Tue, Nov 30, 2010 at 7:29 PM, Marty Landman mlandman@face2interface.comwrote:
I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
-- Open first 10 Google results in 10 new tabs https://addons.mozilla.org/af/firefox/addon/181910/
-- [ Drupal support list | http://lists.drupal.org/ ]
If you can't use the rules module, you might be able to turn off automatic emails and then put some code in a hook_nodeapi on save. You would send email on insert of a new product type node.
-Don-
On 11/30/2010 8:29 PM, Marty Landman wrote:
I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
Thanks Ryan and Don for explaining my options. Now I can report back to my client and explain to them. :)
Marty
At 08:47 PM 11/30/2010, Don wrote:
If you can't use the rules module, you might be able to turn off automatic emails and then put some code in a hook_nodeapi on save. You would send email on insert of a new product type node.
-Don-
On 11/30/2010 8:29 PM, Marty Landman wrote:
I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
-- [ Drupal support list | http://lists.drupal.org/ ]
I may not understand the problem completely, but it seems that what you need are conditions attached to the existing events.
With Rules, you would hook onto the 'new node' event and set up conditions to test for, e.g., the type of the node created, the status of the user, and so on. You can even test for the value of a cck field. So your options are pretty granular for restricting your action to fire only under certain conditions.
UC conditional actions is a bit more work, and in my experience a little less flexible. You would need to find an event that suits your purpose, or implement a new one. Then you would probably need to write your own conditions, since UC doesn't provide many useful ones out of the box.
On 11/30/2010 08:47 PM, Don wrote:
If you can't use the rules module, you might be able to turn off automatic emails and then put some code in a hook_nodeapi on save. You would send email on insert of a new product type node.
-Don-
On 11/30/2010 8:29 PM, Marty Landman wrote:
I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
Yep, rules does look like it'll do what I need.
At 09:32 AM 12/1/2010, Christopher M. Jones wrote:
I may not understand the problem completely, but it seems that what you need are conditions attached to the existing events.
With Rules, you would hook onto the 'new node' event and set up conditions to test for, e.g., the type of the node created, the status of the user, and so on. You can even test for the value of a cck field. So your options are pretty granular for restricting your action to fire only under certain conditions.
UC conditional actions is a bit more work, and in my experience a little less flexible. You would need to find an event that suits your purpose, or implement a new one. Then you would probably need to write your own conditions, since UC doesn't provide many useful ones out of the box.
On 11/30/2010 08:47 PM, Don wrote:
If you can't use the rules module, you might be able to turn off automatic emails and then put some code in a hook_nodeapi on save. You would send email on insert of a new product type node.
-Don-
On 11/30/2010 8:29 PM, Marty Landman wrote:
I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
-- [ Drupal support list | http://lists.drupal.org/ ]
It's not that hard to write your own conditions for CA. I was using uc_fees and needed to apply a fee if the card was AMEX, but the only condition that was close was if payment was by credit card. The following two functions did it for me, just change your conditions. Once the module was enabled the condition was available to CA.
Anthony.
/** * Implementation of hook_ca_condition(). */ function uc_amex_fee_ca_condition() { $order_arg = array( '#entity' => 'uc_order', );
$fee_arg = array( '#entity' => 'fee', );
$conditions['uc_order_condition_uses_amex'] = array( '#title' => t("Check an order's payment method is AMEX"), '#category' => t('Order'), '#description' => t('Returns TRUE if the order uses AMEX.'), '#callback' => 'uc_order_condition_uses_amex', '#arguments' => array( 'order' => $order_arg, 'fee' => $fee_arg, ), ); return $conditions; }
/****************************************************************************** * Condition Callbacks and Forms * ******************************************************************************/
function uc_order_condition_uses_amex($order, $fee, $settings) { if(!empty($order->payment_details)) { if($order->payment_details['cc_type'] == 'American Express') { return TRUE; } } return FALSE; }
On 6:59 AM, Marty Landman wrote:
I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
Thank you Anthony, that looks very helpful. -- Marty
At 05:57 PM 12/1/2010, Anth wrote:
It's not that hard to write your own conditions for CA. I was using uc_fees and needed to apply a fee if the card was AMEX, but the only condition that was close was if payment was by credit card. The following two functions did it for me, just change your conditions. Once the module was enabled the condition was available to CA.
Anthony.
/**
- Implementation of hook_ca_condition().
*/ function uc_amex_fee_ca_condition() { $order_arg = array( '#entity' => 'uc_order', );
$fee_arg = array( '#entity' => 'fee', );
$conditions['uc_order_condition_uses_amex'] = array( '#title' => t("Check an order's payment method is AMEX"), '#category' => t('Order'), '#description' => t('Returns TRUE if the order uses AMEX.'), '#callback' => 'uc_order_condition_uses_amex', '#arguments' => array( 'order' => $order_arg, 'fee' => $fee_arg, ), ); return $conditions; }
/******************************************************************************
- Condition Callbacks and
Forms *
******************************************************************************/
function uc_order_condition_uses_amex($order, $fee, $settings) { if(!empty($order->payment_details)) { if($order->payment_details['cc_type'] == 'American Express') { return TRUE; } } return FALSE; }
On 6:59 AM, Marty Landman wrote:
I'm working on a site using Ubercart. Users register and then may list an item for sale - after creating the item as a new node.
There's a requirement that the user be sent an email when their item is created on the site but the only trigger - either Drupal or UC I can find that will help me here is "After saving a new post". This works well because the only nodes these users can save are their for sale items; the only problem is that they also create a node - their user profile - when they register for the site. Which generates what turns out to be an ugly looking email to each new user, because it's tailored for a new item listing.
Ideally if I could insert a bit of PHP code into the action it'd be easy to tease out the triggers I want to act on and those I don't. But at this point I'm totally stuck as to how I can proceed.
Marty
-- [ Drupal support list | http://lists.drupal.org/ ]