Dropship Plugin - your thoughts wanted

Discussion in 'Customization & add-ons' started by olliejames, Jan 13, 2009.

  1. olliejames

    olliejames aMember Pro Customer

    Joined:
    Mar 19, 2007
    Messages:
    26
    I would like to see a proper dropship plugin developed and am willing to pay for that, so I invite others to think along.

    What do you want in a dropship plugin?

    I want this:
    - plugin where I can add/edit/delete details of dropshipper
    - where I can customise the details that will be sent in the email to the dropshipper
    - option to receive copy of email to address that can also be specified in plugin
    - on the product page I need an extra field per product for the productcode as used by the dropshipper
    - admin section where I can set the status of the dropshipped order
    - member page code where the status of the dropshipped order is shown to the customer when he/she logs in.
    - the plugin should only start the dropship process after completion of the payment

    I am aware of the cdf plugin, I even got it, but I think I need more.

    So please add your thoughts and I will combine everything and ask Alex to build when he has time.
  2. kengary

    kengary aMember Pro Customer

    Joined:
    Nov 13, 2008
    Messages:
    231
    What is the CDF Plugin and where would I get that.

    I'm interested in developing this sort of plugin for my own client and potentially for you as well if you do not want Alex to build it when he has time. I'm building one this week.
  3. olliejames

    olliejames aMember Pro Customer

    Joined:
    Mar 19, 2007
    Messages:
    26
  4. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    i need this EXACT same functionality, and ASAP. I will pm for the CDF plugin to see if that does it for me, but I also need the following, as outlined by rffeddes above:

    - plugin where I can add/edit/delete details of dropshipper
    - where I can customise the details that will be sent in the email to the dropshipper
    - option to receive copy of email to address that can also be specified in plugin
    - on the product page I need an extra field per product for the productcode as used by the dropshipper
    - the plugin should only start the dropship process after completion of the payment

    I don't need the other functionality necessarily.

    Where are things at with this? Can someone post here? I'llsubscribe to the thread.
  5. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    actually, I do have another request for this plugin. If the product is set to auto-renew, the dropshipper should also receive an additional email to let them know the subscription has been renewed; if the user cancels they should perhaps be made aware of that as well.
  6. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Just to be clear, the "CDF Plugin" is for integrating with on demand CD/DVD publisher http://cd-fulfillment.com, not a generic "drop ship" plugin by any means.
  7. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    yes, i know. i'd like to try it out. also, is anyone going to pick up the project as described above? kengary? skippybosco?
  8. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    Hello,

    I created a plugin called Drop Ship Lite. Lite because its lite on your requested features :)

    It provides the following 3 things:
    • Provides email template to customize drop ship email message.
    • Provides per product sku id.
    • Provides per product drop ship email address list.

    You can find it here:

    http://www.cowasoft.com/free_plugins/dropship_lite.zip

    Use as follows:
    1. Create folder on your server /amember/plugins/protect/dropship_lite
    2. copy files in zip to that folder.
    3. Enable plugin
    4. Configure email template.
    5. You can use {product.sku_id} in template to reference sku id.
    6. Now go to a product and you should have 2 additional fields.
    7. Enter product sku id for product.
    8. Enter dropship email address list, 1 email per line.
    9. Now when someone completes payment on product the drop ship email template will be emailed to each user in your per product email address list.

    I know this is not a complete list of requested features but hey I only worked on it for 2 hours. So hopefully this will get people started and they can add the rest of the features.

    If you want all the email tags to be available in the template for simple insertion then you will have to customize /amember/admin/email_templates.php with following code:

    PHP:
    ==EMAIL TAGS user,config,payment,product==
    send_payment_dropshipper:admin/mail_payment.txt E-Mail payment receipt to drop shipper.
    A small clip of the file if inserted correctly will look like following:

    PHP:
    ==EMAIL TAGS user,config==
    send_pass:sendpass.txt Send lost password to customer
    ==EMAIL TAGS user,config,payment,product==
    send_payment_dropshipper:admin/mail_payment.txt E-Mail payment receipt to drop shipper.
    ==
    EMAIL TAGS user,config==
    send_security_code:sendsecuritycode.txt Send security code to customer to restore password
    code 
    Security Code
    hours 
    Hours to click link';
    Be sure to back up file first before modification. I warrant nothing :)

    One more thing, currently the product sku_id is being validated when you save product form. It assumes sku is decimal. If you require alphanumeric characters for your sku then change the validate_sku_id() routine to match your sku or else take out the validation check all together.

    While testing you should probably just use some additional email addresses of your own to see that your receiving the email and it contains SKU and rest of your customized template. After installing the plugin and enabling it I just created a dummy product and filled in the sku and email address list. Then I manually created a new user from CP and assigned the dummy product to the new user from CP. This will test all of the functionality of the plugin without having to go thru your payment gateway. You should receive emails at least I did. Hope this helps.

    Jimmy
  9. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    jimmy, once again you are rocking my world! I can't wait to try this!
  10. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Jimmy, great addition to the community.
  11. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    Well, Jimmy, I've got it installed and it almost works perfectly. The only part that isn't working as you described above is that the email to the dropshipper does not include any of the user fields, even though they did come up after making the template alteration as described above, and I had included them in the edited dropship template. The email goes out, everything is formatted as I put in the template, the product and payment fields are there, but the user fields are blank (the product fields all come through).
    any ideas on how to get it working? there must be some error in how it's calling the user tables.

    Other than that, it works like a charm, and is a real lifesaver...
  12. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    Hello,

    That is weird it worked for me. Here is the email I received.
    PHP:
    New payment completed:
        
    Product:    Test Drop Ship Product
        Sku
    :        12345678
        Amount
    :     $0.00
        Period
    :     01/22/2009 01/22/2010

      User details
    :
        
    Username:   test2
        Email
    :      test2@cowasoft.com
        Name
    :       Joe Smith

    --
    Best Regards,
    cowasoft.com
    This is what my template looks like:

    PHP:
    New payment completed:
        
    Product:    {$product.title}
        
    Sku:        {$product.sku_id}
        
    Amount:     {$config.currency|default:"$"}{$payment.amount}
        
    Period:     {$payment.begin_date|date_format:$config.date_format} - {$payment.expire_date|date_format:$config.date_format}

      
    User details:
        
    Username:   {$user.login}
        
    Email:      {$user.email}
        
    Name:       {$user.name_f} {$user.name_l}

    --
    Best Regards,
    {
    $config.site_title}
    As you can see all the tags (i.e. user, config, payment, product) were correctly substituted/aliased in the email.

    I tested against 3.1.2. I wouldn't think that would make a difference.

    This is the relevant routine in dropship_lite.inc.php

    PHP:
    function ds_fwp($payment_id$member_id)
    {
      global 
    $db$t;

      
    //
      // Determine payment, product, user from payment_id and member_id
      //

      
    $payment $db->get_payment($payment_id);
      
    $product $db->get_product($payment['product_id']);
      
    $member  $db->get_user($member_id);

      
    //
      // Email the dropshipper address list the templated email
      //

      
    $emails = (array)preg_split('/\r\n/'$product['dropshipper_email_address_list']);

      foreach (
    $emails as $e)
      {
        if (
    strlen($e) && check_email($e))
        {
          
    // $db->log_error("ds DEBUG: trying to email $e\n<br>");

          
    if(!$t)
            
    $t =& new_smarty();

          
    $t->assign('user'$member);
          
    $t->assign('payment'$payment);
          
    $t->assign('product'$product);
          
    $et = & new aMemberEmailTemplate();
          
    $et->name "send_payment_dropshipper";
          
    mail_template_dropshipper($t$et$e);
        }
      }
    }
    Maybe for some reason $member_id is not being passed to routine. If that is case you can try and pull the $member_id from the payment record instead.

    So modify routine to look as follows to see if it resolves the problem. If it does I will change dropship_lite to use this method instead.

    PHP:
    function ds_fwp($payment_id)
    {
      global 
    $db$t;

      
    //
      // Determine payment, product, user from payment_id and member_id
      //

      
    $payment $db->get_payment($payment_id);
      
    $product $db->get_product($payment['product_id']);
      
    $m_id    $payment['member_id'];
      
    $member  $db->get_user($m_id);

      
    //
      // Email the dropshipper address list the templated email
      //

      
    $emails = (array)preg_split('/\r\n/'$product['dropshipper_email_address_list']);

      foreach (
    $emails as $e)
      {
        if (
    strlen($e) && check_email($e))
        {
          
    // $db->log_error("ds DEBUG: trying to email $e\n<br>");

          
    if(!$t)
            
    $t =& new_smarty();

          
    $t->assign('user'$member);
          
    $t->assign('payment'$payment);
          
    $t->assign('product'$product);
          
    $et = & new aMemberEmailTemplate();
          
    $et->name "send_payment_dropshipper";
          
    mail_template_dropshipper($t$et$e);
        }
      }
    }
    Jimmy
  13. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    This was the initial request.

    I want this:
    - plugin where I can add/edit/delete details of dropshipper
    - where I can customise the details that will be sent in the email to the dropshipper
    - option to receive copy of email to address that can also be specified in plugin
    - on the product page I need an extra field per product for the productcode as used by the dropshipper
    - admin section where I can set the status of the dropshipped order
    - member page code where the status of the dropshipped order is shown to the customer when he/she logs in.
    - the plugin should only start the dropship process after completion of the payment

    When ds_fwp() is called I can call add_payment_field() to add a custom dropship status to the payment record and set it to a default value such as pending. What would be all the states? ORDER_RECEIVED, ..., ORDER_SHIPPED

    I could then add something to the CP sidebar (i.e. DropShip Payments) that would allow you to query all payment records that had a particular DropShip status so that you could manually update the payment record to a new status.

    Or I could just make the Reports/Payment display the DropShip status and make sure the query mechanism will work on the DropShip status field that I add.

    Let me know. You need to list all the DropShip states, and initial value. I could add these more mods this weekend when I had more time.

    Jimmy
  14. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    that fixed it, Jimmy! thanks! For my purposes, I don't need any of the above, but I know that rffeddes does. What I do need, however, is for the dropshipper to be notified when the auto renewal has gone through, just as the admin does now (or should , anyway).
    Also,where can i make a beer donation for you? Your plugin just saved my @$$!
  15. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    Hello,

    Glad to hear it worked for you, I changed the version to 0.0.2 to refect this change and new code can be gotten from same place.

    I don't think you need to any more modifications if your talking about rebilling of a recurring product. When the payment system is rebilled the following code is executed in cc_core.inc.php

    PHP:
            switch ($res){
            case 
    CC_RESULT_SUCCESS:
                
    $err $db->finish_waiting_payment(
                    
    $payment['payment_id'], $payment['paysys_id'], 
                        
    $receipt_id$payment['amount'], ''cc_core_get_payer_id($vars$member));
                if (
    $err) {
                    
    $db->log_error($err ": payment_id = $payment[payment_id] (rebilling)");
                }
                if (
    $config['cc_rebill_success'])
                    
    mail_rebill_success_member($member$payment_id$product);
    The call to db->finish_waiting_payment() should cause ds_fwp() in dropship_lite plugin to also be called. At least it should work this way for payment processors that aMember does the rebilling for.

    For other payment systems such as paypal, ccbill that do the rebilling themselves, and notifies aMember via IPN mechanism then the IPN code for the payment plugin should also call db->finish_waiting_payment() which will cause ds_fwp() to also be called.

    In short anytime a payment occurs db->finish_waiting_payment() should always be called so that payment record can be updated.

    To notify dropshipper of cancelling of recurring product would be a little trickier and would have to probably be done outside of the plugin in cc.php. It depends on what payment processor your using.

    Jimmy
  16. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    Okay, I'll test it out. The dropshipper does not need to know that the member cancelled (cause they only cancel their recurring subscriptions). They will still be a subscriber for the year. And I'm removing the cancel button from the basic member page. The template for the email that goes to users that tells them that their subscription is about to auto-renew, however, will contain a link to some other version of a member page that does include the cancel link so they can cancel at that point (haven't figured out how to work this yet but haven't tried yet, either). But the dropshipper does need to know that the subscription renewed, as they then need to update their database to show that a new year's payment was received.

    thanks!
  17. celina

    celina Member

    Joined:
    Sep 9, 2008
    Messages:
    86
    help!

    um, the dropship plugin was working great....but is there any chance it could be messing up the functionality of my incremental plugin? Cause they no longer show up on the product info page, and I can't add any new ones (although they do still seem to work for the members, just fine). I had to stop working on this project for a while and now that i'm back on it, i really can't remember if this was working fine after i installed the drop ship plugin or not. screenshot attached so you can see the weirdness
  18. codeispoetry

    codeispoetry aMember Pro Customer

    Joined:
    Jan 12, 2009
    Messages:
    336
    Hey celina,

    I see you found a clue what might be messing with your incremental content plugin.

    This is best answered by the coders themselves. I hope you get it fixed soon :)

    Lee
  19. codeispoetry

    codeispoetry aMember Pro Customer

    Joined:
    Jan 12, 2009
    Messages:
    336
    Hey celina,

    I see you found a clue what might be messing with your incremental content plugin.

    This is best answered by the coders themselves. I hope you get it fixed soon :)

    Lee
  20. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Hey Celina,

    I'm troubleshooting a similar issue on one of my sites.

    I can take a look to see if that is what is causing your problem. Drop me an email at my username here @ hotmail.com and I'll do what I can to help.

Share This Page