Hi,

I was wondering if there's a token available for the seller's email? I'm assuming there must be as it's possible to send an order confirmation to sellers. If so, I would like to use this token to email the 'admin checkout notification' to sellers in addition to a 'stock threshold' email notification.

It's a pretty important issue so any help at all is appreciated!

Hope all is well!

Evelyn

CommentFileSizeAuthor
#14 mp_tokens.zip1.31 KBsyndicateStorm
#5 mp_tokens.tgz880 bytesshushu

Comments

syndicateStorm’s picture

Line 108 from mp_orders.ca.inc shows how to get the email from the user's ID:

$email_to = db_result(db_query("SELECT mail FROM {users} WHERE uid = %d", $uid));

I'm not sure that completely answers your question, so feel free to let me know how I can help further.

There is also a discussion of emailing when stock is low at http://drupal.org/node/411184.

nyleve101’s picture

Thanks for getting back to me syndicate i really appreciate it! I now only need to find a way to email the seller on their stock threshold. I’ve had a look at the thread you pointed to but I don’t think it’s possible to do this with c/a. There’s already an option in UC to send a notification on stock threshold to your chosen email address. In this case, would the code above need to be inserted into uc stock to enable it to email individual sellers for their specific products?

Thank you again for your help, I can’t express enough how appreciated it is!

syndicateStorm’s picture

I haven't looked at uc stock, so I can't say for sure. From your description that sounds reasonable. I would imagine UC Stock always sends email to the same place, but we want to send it to a variable email address based on the code above (assuming we know the user/seller ID). I wonder if you can hook into UC Stock? I'll try to take a look at the code sometime in the next couple days to give a more concrete answer.

nyleve101’s picture

Thanks for your help Syndicate! I had a look a through the mp documentation again and it makes reference to notification settings "(if mp_notify enabled) can be found at admin/store/settings/notify/edit/seller." (http://drupal.org/node/326102) I would assume this was a feature that was available in mp 5x so maybe that may be a good lead.

Thanks again for your help!

shushu’s picture

Title: Seller email Token » Seller email Token - new module
Status: Active » Needs review
StatusFileSize
new880 bytes

Attached new module - mp_tokens, which adds the token [order-seller-email], the email addresses of the product's owners.

If other tokens are needed, it can be added by request.

What next with this module/features ?

syndicateStorm’s picture

Thanks shushu! I'll try to test it this weekend. Let me know how it works for you nyleve101?

nyleve101’s picture

Shushu, thanks so much for your token module. I've tested it and unforturnately uc_stock doesn't allow for the use of tokens in the 'notification recipeints' email box so the token doesn't work for stock threshold notification.

Syndicate do you think the module hook is a viable option?

Thank you so much for your help so far- it's really appreciated!

Evelyn

syndicateStorm’s picture

Shushu, worked for me. Thanks! I'll commit this or something like it to Marketplace when I get a chance.

Evelyn, here's a quick hack until someone comes up with something better:

After installing shushu's module add line 249 to uc_stock.module.

$to = variable_get('uc_stock_threshold_notification_recipients', variable_get('uc_store_email', ini_get('sendmail_from')));
$to = token_replace_multiple($to, $token_filters);
$to = explode(',', $to);
nyleve101’s picture

EDIT

Syndicate, what programme do you use to count your line numbers? I've tried adding the code but keep getting the error below:

Call to undefined function token_replace_multiple() in /home/ilivedto/public_html/sites/all/modules/ubercart/uc_stock/uc_stock.module

Thanks for your help!

syndicateStorm’s picture

Well, that was probably not clear on my part considering I didn't even give the version of Ubercart I was using :-) The top and bottom lines in post #8 should already exist in uc_stock. So I'm only adding:

$to = token_replace_multiple($to, $token_filters);

In the function _uc_stock_send_mail. For reference here it is in context:

function _uc_stock_send_mail($order, $stock) {
  $token_filters = array('global' => NULL, 'order' => $order, 'stock' => $stock);
  $account = user_load(array('uid' => $order));

  $to = variable_get('uc_stock_threshold_notification_recipients', variable_get('uc_store_email', ini_get('sendmail_from')));
  $to = token_replace_multiple($to, $token_filters);
  $to = explode(',', $to);

  $from = uc_store_email_from();

  $subject = variable_get('uc_stock_threshold_notification_subject', uc_get_message('uc_stock_threshold_notification_subject'));
  $subject = token_replace_multiple($subject, $token_filters);

  $body = variable_get('uc_stock_threshold_notification_message', uc_get_message('uc_stock_threshold_notification_message'));
  $body = token_replace_multiple($body, $token_filters);

  // Send to each recipient.
  foreach ($to as $email) {
    $sent = drupal_mail('uc_stock', 'threshold', $email, uc_store_mail_recipient_language($email), array('body' => $body, 'subject' => $subject), $from);

    if (!$sent['result']) {
      watchdog('uc_stock', 'Attempt to e-mail @email concerning stock level on sku @sku failed.', array('@email' => $email, '@sku' => $stock->sku), WATCHDOG_ERROR);
    }
  }
}

Hope that helps.

syndicateStorm’s picture

Category: support » feature
nyleve101’s picture

Thank you both so much Shushu and SyndicateStorm!! I don't know what i would have done without you!

Take care of yourselves and thanks again!

Evelyn

fehin’s picture

The file in #5 has some blocks [] like characters in it. It doesn't have an extension either, I changed mine to mp_tokens.module and put it in the ubercart_marketplace folder. When I uploaded it, I didn't see it under my modules, is this normal? Was this how it was for everyone else?

syndicateStorm’s picture

StatusFileSize
new1.31 KB

Here is a zipped version of what I have...

fehin’s picture

Thank you very much. I just uploaded that and applied the patch.
I don't see the tokens.

*ignore*
I found it. Didn't see the link at the bottom; I was expecting a colapse list.

syndicateStorm’s picture

Great. Cheers.

xxm’s picture

I found it. Didn't see the link at the bottom; I was expecting a colapse list.

Sorry, but where you found it?

fehin’s picture

Right below the input text box, there is this message "The message the user receives when the stock level reaches its threshold value (uses global, order, and stock tokens).", click on the link in the bracket.

xxm’s picture

count you tell me the link please?

domain/admin/..?

fehin’s picture

It's admin/store/help/tokens.

shushu’s picture

Hello,

I decided to make a decent module out of it.

http://drupal.org/project/mp_tokens

I do believe it should be integrated into the main module, but till then - it is available as an additional module.

In addition, in combination with another module - http://drupal.org/project/uc_ca_sms - it is possible to send SMS notifications for sellers.

Comments are welcome,
Shushu

davidw’s picture

Thanks for the work on this!
It's just what I was looking for.

rafinskipg’s picture

Thanks a lot, I'll try it now

hanoii’s picture

Hello, I am a new dev helping a little with this module. I have just added some support for this, not exactly this but what I did was support user tokens that work with the seller account, this would let you use any of the available user tokens on the email.

I've reviewed the module and although it's not exactly the same I would think this would serve its purpose without adding new tokens or any more functionality with the module. I am happy with a separate module as well, although if we agree would serve most purposes maybe doesn't worth duplicating things.

Any thoughts? This functionality is not yet committed, but soon will be.

hanoii’s picture

There seems to be some relationship between this issue and #411184: uc_stock notify seller instead of store owner on low stock threashold, just noting it here.

hanoii’s picture

Ok, the new feature that's commented on #24 is committed for anyone who wants to try it. You might have to wait for the -dev release to be made or checkout with git.

ledom’s picture

Just tried #10, it seems to send emails to all sellers which have products into the order.

Example:
Order 1
Product A from seller 1
Product B form seller 2

Prod A become out of stock, not product B.

Seller 1 & 2 recieve emails alerts.

Is it possible to notify only sellers with out of stock products?

zeezhao’s picture

Please did anyone create a module for mp_tokens and the actual sending of emails to each seller of a product in an order (see #10) for D7?

eboss’s picture

Issue summary: View changes

I really need this token on d7, is there someone help?