111 replies [Last post]
Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Was this information Helpful?

There has been many requests for marketplace type features. People have requested features such as multiple seller management. I had need for the same and have developed a working group of modules under the working title of Ubercart Marketplace.

Overview of the Five Current Ubercart Marketplace Modules:

  1. mp_products:
    • Adds "selling" tab to user accounts with certain permissions.
    • Adds a table of products created by seller.
    • Includes sample concept of edits to product node edit form appropriate for a marketplace seller. For example, it removes form elements sellers may find unnecessary and cryptic.
    • This module also sets up the "cost" price field to be used as the commission field and is calculated based on a set commission rate. These options are configurable under "Seller settings" in Ubercart configuration.
  2. mp_orders:
    • Adds "fulfill orders" tab to "selling" section of user accounts.
    • Adds a table of orders containing products created by seller. This module handles "dividing" up orders at checkout, so each seller only can fulfill and view the portion of a customer's order that contains the seller's products.
    • Handles seller order statuses, moving their "portion" of the order to complete when order is fulfilled.
    • Automatically completes orders when orders are nonshippable.
  3. mp_shipping:
    • Mimics functionality of uc_shipping, but allows sellers to only fulfill and ship the portion of a customer's order containing the seller's goods.
    • Adds in a packing slip feature that allows sellers to print a packing slip containing only the content of the specified package. This is for drop shipping support.
    • Adds a workflow-ng configuration that moves the whole customer order to completed when all sellers' order statuses for an order are complete.
    • This module currently only supports the "manual shipping" option (e.g. live quotes from ups and usps are not yet supported). However, this works well with the contributed order tracking module because sellers can select a carrier and tracking number for their packages that can then be tracked by the customer.
  4. mp_reports:
    • Adds reports to sellers' pages under their account. Seller reports included are: product sales, sales summary, and sales per year/month.
    • Seller reports only show the seller's products and sales and the commission they will be paid.
    • Seller reports only report sales that are from orders that the seller has completed. The seller will not get paid until they either ship the order, or the order is all nonshippable, in which case it will automatically be promoted to complete.
    • mp_reports adds two admin reports to the current uc_reports module. The first one is a seller order statuses report that lists the orders by seller that have not been completed so the store administrator can look out for slow sellers. The second lists the commission that the sellers should be paid. This is calculated from the "cost" price field mentioned above. This table is powerful in that it allows you to select the date range in which to show orders so you can pay sellers in whatever periods you wish. This report also supports exporting to a Paypal Mass Payments formatted txt file. Currently this is the envisioned method of seller payment.
  5. mp_notify:
    • This simple module allows sellers to be notified when they have an order.
    • Options for this module are configurable under "seller" tab of notification settings area in Ubercart configuration.

Concept:
Basically, this group of modules leverages current Ubercart core functionality, while limiting access so sellers can only deal with their orders and products. All seller functions are under a new "selling" tab of their user account page (user/x/selling). Seller order statuses have been created to allow management of payment--the idea is that only sellers' orders which are complete will show up in seller payment reports. This forces sellers to fulfill their orders if they want to be paid. Nonshippable orders are automatically promoted. The commission to be paid to the sellers is based on the preexisting "cost" field of the product node. This is the actual value a seller will be paid. The only method currently supported (aside from manual) to pay sellers is with the created Paypal Mass Payments file.

Usage Ideas:
Ubercart marketplace would work well with moderation modules (look on drupal.org), so sellers can not directly list products. A set of profile modules and a taxonomy setup may also be appropriate to allow sellers their own "about me" page and a view of all products by a certain seller. See how to setup roles/permissions under "Installation."

Wishlist:
Some of these features may be coming in the future. Feature requests are welcome, also.

  • "Glue" module for handling seller taxonomy and seller profiles. Think similar features to uc_manufacturers.
  • Better support for shipping fulfillment. Allow sellers to create their own accounts with shipping companies, so printing shipping labels (etc) is possible for each seller.
  • Quick menu for seller functions
  • Report graphs
  • Handle file downloads (feature for products) more intuitively due to lack of nonadmin support for product features - Added in BETA1!
  • Support for more seller payment methods, such as pay with check. Also allow sellers to choose method and/or select email address of their Paypal account. - Added in BETA2!

Installation:
See the README included in the attached .zip for additional details. Requires a small uc_shipping patch as well as a template file to be moved to the uc_orders template folder (included). To realize functionality, create a new role (and some users) and give this "seller" role the access permissions of the ubercart marketplace modules (view own reports, ship own products, etc.). Also give "seller" other permissions appropriate (such as edit own products, create products, etc. from Ubercart core).

IMPORTANT Notes:
It is important to keep in mind that this is a developer preview. Consider this BETA at best. Many Ubercart core module functions had to be ruthlessly overridden due to lack of fine-grained access control in Ubercart. I tried to alter (with hooks) what I could and the rest had to be overridden. Some of my database queries also got messy due to pulling information from many tables not set up for fine-grained seller access. If you can find a simpler way to do certain functions of Ubercart Marketplace, please help support it. I also have not gotten around to doing my own cleaning and full commenting of the code. Updates will be posted here when available. I tested these extensively, but there may still be plenty of bugs. I encourage all support, feature requests (although I am limited in time), and ideas. Also note, these modules may not satisfy everyone. I tried to make them suitable for a range of purposes, but they may not fit everyone's specific needs. Once this group of modules gets a little more underway, I will set up the appropriate projects and issue queues. Post with your thoughts.

Edit: To download, please check out the project page at drupal.org: http://drupal.org/project/ubercart_marketplace
Edit 2: Documentation: http://drupal.org/node/326102

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Ubercart Marketplace Developer Preview - Multiple Seller Sup

Don't have time to review this personally, but I will share a quick thought... unbelievable! Cool I'm highly impressed and wish you the best of luck on this project. Lots of folks have asked about just this sort of functionality, and it sounds like you've done quite a comprehensive job. I would encourage you to make a separate post that catalogs as much of the shortcomings in the core access control as possible so we can improve this in D6 and beyond. That would rock!

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Re: Re: Ubercart Marketplace Developer Preview - Multiple Seller

Absolutely amazing. I will review this in the coming week - since this sounds almost exactly how we're going to need our "Customer Products" setup. I'll be sure to give feedback and code contributions whenever I can Smiling

--
Help directly fund development: Donate via PayPal!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
Re: Re: Re: Ubercart Marketplace Developer Preview - Multiple Se

On that note... I'd recommend making this a project on Drupal.org ASAP so folks can more effectively give you feedback. Laughing out loud A project the size will quickly become unwieldy in a single forum thread. You can also make a contrib page here that links directly to your project page on Drupal.org so folks can find the project easier.

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Thanks.

Thanks for the support guys! I will make this a Drupal.org project within a few days.

I will also, as Ryan suggested, make sure I document ideas regarding the next version of Ubercart. As I look back over my code, I will write down the various access permissions and hooks I'd like to see in the future.

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Thanks.

Ubercart Marketplace is now a project at drupal.org.

Please check it out there for the latest code and to report bug reports or feature requests:
http://drupal.org/project/ubercart_marketplace

BiblioCurator's picture
Offline
Joined: 08/03/2008
Juice: 12
How to disable "Seller commission"

Hello,
Thank you very much for your module!
Tell me, please, how to disable "Seller commission". I have independent sellers on my site and I don't need this option.
Thank you.

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: How to disable "Seller commission"

While there is no direct way to remove it, you can choose a configuration like the following to get the same result.

Turn on "Automatically calculate commission" at admin/store/settings/seller. Also, set the Default Commission Rate to 1. This will in effect make the amount the seller should be paid equal to the sell price. This will hide the seller commission field and fill it with an appropriate amount.

sarmad's picture
Offline
Joined: 10/15/2008
Juice: 47
Wonderful job.. but still unhappy..

I really do appreciate the work you guys doing.. its priceless ! both ubercart and the market place modules are one of its kind. sorry if i sound offensive but this is what has wasted my 48 hours. just because the proper documentation wasn't available.. infact this issue dont even need a very sophisticated .doc file..

Quote:

-Make necessary backups.
-Extract Ubercart Marketplace in your sites/all/modules folder in Drupal directory.
-Place packingslip.itpl in sites/all/modules/ubercart/uc_order/templates directory.
-Patch uc_shipping module using included (non contextual) patch or adding the following two lines manually:
~line 1225 (last line of uc_shipping_package_save()): module_invoke_all('package', 'save', $package->package_id);
~line 1235 (last line of uc_shipping_package_delete()): module_invoke_all('package', 'delete', $package_id);

points 1 and 2 are absolutely clear.. the line 1225 of uc_shipping module is

Quote:

if (count($types)) {

and is no way the 'last line of uc_shipping_package_save().. the last line of the particular function is at 1229.. which states '}'

same is the case with the uc_shipping_package_delete().. if you wouldve spent just a lil 2..3 minutes more on this wonderful module you developed.. there will not be much difficulty to noobs like me. I dont know where to insert the two lines so i downloaded cygwin to patch it.. but the patch file you provided isnt working and it says.. missing header for unified diff at line 1.

please dont make web developers suicide on such minor issues.. ;(

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Wonderful job.. but still unhappy..

I apologize for your troubles. Unfortunately, I have not found time to write better documentation and Marketplace is still currently in BETA (although stable) state and therefore geared towards developers.

Depending on your editor, your line numbers may differ (that is why I wrote ~ approximate symbol by them).

At the very end of this function:

/**
* Save a package.
*/
function uc_shipping_package_save($package) {

place module_invoke_all('package', 'save', $package->package_id);

like so

    db_query("UPDATE {uc_packages} SET ". implode(',', $types) ." WHERE package_id = %d", $values);
  }
  module_invoke_all('package', 'save', $package->package_id);
}

Do similar for uc_shipping_package_delete() in uc_shipping.module

/**
* Delete a package.
*/
function uc_shipping_package_delete($package_id) {
  db_query("DELETE FROM {uc_packages} WHERE package_id = %d", $package_id);
  db_query("DELETE FROM {uc_packaged_products} WHERE package_id = %d", $package_id);
  drupal_set_message(t('Package @id has been deleted.', array('@id' => $package_id)));
  module_invoke_all('package', 'delete', $package_id);
}
sarmad's picture
Offline
Joined: 10/15/2008
Juice: 47
Thanks Alot !

copy/paste this to readme file.. I was using zend studio which is pretty much the standard for php. Anyways I find open source projects like these provide far better support as compared to the one i pay $5000. as i said this is priceless ! Thanks once again.

Sam
Sam's picture
Offline
Joined: 10/11/2008
Juice: 77
Random user account

I didnt notice it before. But I tried to create the home page link as user/% so users would be directed to there own profile.
But insted i get sent to this random page with files and orders headers tabs. nothing else on the page except user profile.
Anyone else got anything like this.

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: Ubercart Marketplace Developer Preview - Multiple Seller Sup

This is exactly what I am looking to do with an upcoming project. Thank you for your hard work. Should I decide to take it, expect some patches/bug fixes in the next coming month or two.

Thanks again,
Jordan

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Re: Ubercart Marketplace Developer Preview - Multiple Seller

Thanks Jordan. I am always looking for community input and modifications to improve Marketplace. I look forward to seeing what you accomplish.

sarmad's picture
Offline
Joined: 10/15/2008
Juice: 47
Re: Re: Re: Ubercart Marketplace Developer Preview - Multiple Se

I tell you what.. this module makes ubercart exceptional.. love the developers of marketplace Eye-wink

Is there any work around so that sellers can change stock, threshold of their products?

edit.. i found this --> http://drupal.org/node/279611 and it was really helpful..

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Re: Re: Re: Ubercart Marketplace Developer Preview - Multipl

Thank you for your compliments of Marketplace. I worked hard to bring such power to the already great Ubercart. The patch you found for Ubercart should help you out. Good luck.

decaye's picture
Offline
Joined: 10/29/2008
Juice: 15
Couple questions for Turgrid

hey, first of all, thanks for making an excellent module. I am using it right now for a client. I was just wondering if you were planning on updating this for drupal 6 and also...on the Tazetta site. I'm trying to figure out how to grab the "my products" view for user profiles (I am also using bio, panles, adv prof kit) and if it's possible to include the image of the product as well?

Thanks again.

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Couple questions for Turgrid

If I remember, that is a simple view with an argument to check the uid of the user's profile from url. Being a view, you could add a product image and in fact that's not a bad idea.

Marketplace will be updated to D6. When? I am not sure when I will get time at the moment. I am open to assistance.

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Warning: Call-time pass-by-reference has been deprecated

So far my experience with marketplace has been great. I've installed it, configured it a little and setup the structure of most of my website. So far so good.

I found a small issue on a server I installed it on which has PHP warnings enabled.

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of module_invoke_all(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in /home/eocean/dev/htdocs/sites/all/modules/ubercart_marketplace/mp_products/mp_products.module on line 219

Here's line 219

<?php
       
// invoke hook_list_product()
       
module_invoke_all('list_product', &$node);
?>

I believe it should be changed to

<?php
       
// invoke hook_list_product()
       
module_invoke_all('list_product', $node);
?>

This removes the pass by reference. I grepped all of market place's and ubercart's code to see if anything uses this list_product hook, but nothing turned up. Reason I'm posting this here is because I'm unsure if there's an intensional reason for doing this that I'm un-aware of....if not, it's a quick fix to resolve the warning.

Look forward to digging harder into it next week as I start to theme my site.

Thanks again,
Jordan

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Warning: Call-time pass-by-reference has been deprecated

Thanks. I actually just committed such a fix a day ago to BETA5 (along with a few other minor fixes). The hook is a new one provided by Marketplace for a potential use by modules extending its functionality.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4111
Turgrid, Thought I'd let you

Turgrid,

Thought I'd let you know that rifftrax.com now uses Marketplace. When you create an account you are given an option to signup for "iriffs" which is our customer riffing feature. From there you can create products and so far it's working pretty well Smiling You can see the ones that people have created at www.rifftrax.com/iriffs

Also, I wanted to say that my "find" from a couple weeks ago was wrong. Right now the SQL queries are looking for all nodes of type 'product' when that doesn't allow for Product Classes. Classes is actually where Marketplace can shine, because it allows you to keep separate your official, main site-based releases from the customer products.

For instance our nodes for customer products are "iriff" node types as opposed to the usual Ubercart "product" node type. So if you can find a way in there to get the module working with products and product classes I think it'll be huge.

Feel free to check out the site, and sign up for iRiffs, and let me know what you think.

--
Help directly fund development: Donate via PayPal!

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Turgrid, Thought I'd let you

I noticed that Rifftrax was updated. Nice new look! I will sign up and check it out in more depth and share my feedback. I can't wait.

I believe I caught the error when I did the very recent update to BETA5 (which fixes a few of the other bugs floating around too). The query in discussion should check if the node type is in the array of product classes and not just product.

Thanks.

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: Re: Turgrid, Thought I'd let you

I'm working on little patch to allow the sellers to each keep their own "Origin" shipping sources saved. It requires another database table unfortunately (essentially the same as uc_orders).

I'll polish it up and submit tomorrow hopefully once I get the bugs worked out.

This will allow for each user to keep a list of "product origins" each time they ship an item out and use a new address.

divinevette's picture
Offline
Joined: 01/30/2009
Juice: 11
How is it goin?

hi jord, I also need marketplace to save my sellers info. I'm in a rush to get things moving. I only have seller types though and not manufacturers. How is your patch going? Let me know if i can contribute. Thanks

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
@divinevette: Well...the

@divinevette:

Well...the products your sellers create will be attached to their user accounts. You can use an existing Drupal modules like Node Profile to extend said users "Profile Pages"...then you can link to this new "Profile Page" from the product page.

That should get you moving. Let me know if you have any other questions.

divinevette's picture
Offline
Joined: 01/30/2009
Juice: 11
Thanks j0rd. I have another

Thanks j0rd.

I have another question.

On my site, I would like to forgo mediating between byers and sellers and let the buyers pay the sellers directly. but have paypal notify me when payments are made, just for record keeping.

Thanks!

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
@divinevette: As far as I

@divinevette:

As far as I know, the buyers pay you and you dole out the cash to your vendors. I personally haven't played with this all that much, so I'm not 100% sure how it all works. Someone else can probably clarify better than I can, but I think you're going to have to write something custom for this.

danroth's picture
Offline
Joined: 10/29/2008
Juice: 22
product kit support?

Marketplace is amazing. Thank you so much for it!

As I less-than-impressively revealed in another thread, I'm having trouble getting it to work with Product Kits.

If I try creating a Product Kit, I get a "Commission must be greater than zero." error - unless I have a sitewide base price set, then I get a "Sell price must be greater than or equal to sitewide base price of $XXX".

Should it work, and I have it misconfigured?
or
Is it not yet compatible with Product Kits?

Thanks!

JasonFrank75's picture
Offline
Joined: 11/15/2008
Juice: 2
danroth wrote:Marketplace is
danroth wrote:

Marketplace is amazing.

Thanks!

yes thanks its beautiful!

kenorb's picture
Offline
Joined: 03/10/2011
Juice: 4
the same problem

The same error: Commission must be greater than zero.

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
MarketPlace, UC_Manufacturers and Default Shipping Location

I'm getting to the point where i need to deal with where the hell are my products going to ship from problem.

My marketplace project has Sellers & Manufacturers. Each Seller has it's own set of Manufacturers and I was doing this with a custom CCK type and node reference. Created a view for my node-reference, to only display the manufacturers for the current seller. Worked great, but doesn't help me with the where to ship from issue. My client requires I display where the product is shipping from and the shipping options directly on the product page....so I did some diggin' around.

Core-Ubercart uc_quote provides some hooks into a contrib module called uc_manufacturer to allow each product to ship directly from a particular manufacturer. Perfect!

Ubercart product page says this:

When delivering products to customers, the original location of the product must be known in order to accurately quote the shipping cost and set up a delivery. This form provides the default location for products, either individually or an entire manufacturer's line. If a product's individual pickup address is blank, Ãœbercart looks for the manufacturer's. If that is also blank, it uses the store's default pickup address, which can be set here.

I ended up finding the http://drupal.org/project/uc_manufacturer project, which I had no idea existed.

Now the problem with uc_manufacturers is it doesn't use CCK node types for these manufacturers out of the box, although the developer of the module suggest for more advanced users, they might want to do this.

I've put most of my thought on what to do about this issue in this feature request for uc_manufacturers. I simply want to make both projects aware of each other.

http://www.ubercart.org/issue/7617/uc_manufacturers

I feel the integration of Marketplace with a slightly more robust implementation uc_manufacturers would make for a great implementation into Ubercart 3.x and would almost fully complete the multi-seller environment.

Discuss Laughing out loud

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: MarketPlace, UC_Manufacturers and Default Shipping Location

I think one of the first steps to dealing with this issue is standardizing what "Shipping From" information is stored. uc_quote uses two tables, uc_quote_product_locations, uc_quote_manufacturer_locations...i'm going to create uc_quote_seller_locations and work from there.

ATTN: Ryan.

Did uc_manufacturers used to be in core? Seems like uc_quote is in love with it.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15459
j0rd wrote: ATTN: Ryan. Did
j0rd wrote:

ATTN: Ryan.

Did uc_manufacturers used to be in core? Seems like uc_quote is in love with it.

I'll redirect you to Lyle for the full answer, but the short answer is yes. Sticking out tongue

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: j0rd wrote: ATTN: Ryan. Did

Short answer is enough Laughing out loud Explains everything.

decaye's picture
Offline
Joined: 10/29/2008
Juice: 15
Price Sorting by Views or another way

Turgrid, I noticed on tazetta you have done EXACTLY...and I mean almost exactly what I need.

http://www.tazetta.com/taxonomy/term/12/2/1/0

You have the sort by desinger and sort by price high to low, etc...

I have custom views set up for my project...so using table view for sort is out.

It looks like you managed to expose sort criteria (views 1.x only allows exposed filters)

Exposed sort criteria is exactly what I'm looking to do. I was wondering how you went about that. Thanks!

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: Price Sorting by Views or another way

I need exposed sort too! I can't believe views doesn't easily support sorting. I was neglecting that features until I finished most everything up, then was going to get back to it.

Any tips/pointers/snippets would be appreciated.

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Re: Price Sorting by Views or another way

I was going to use Views until I realized the limitation. What you are seeing for the taxonomy pages is custom sql I wrote for the purpose that makes use of the arguments passed by the url (which come from the Drupal form with sort methods). I don't see any other way to do it efficiently. I can dig up some of my snippets, but I have provided the general outline of how to do it. Let me know if you have troubles at a point and I will try to provide an example.

decaye's picture
Offline
Joined: 10/29/2008
Juice: 15
thanks
Turgrid wrote:

I was going to use Views until I realized the limitation. What you are seeing for the taxonomy pages is custom sql I wrote for the purpose that makes use of the arguments passed by the url (which come from the Drupal form with sort methods). I don't see any other way to do it efficiently. I can dig up some of my snippets, but I have provided the general outline of how to do it. Let me know if you have troubles at a point and I will try to provide an example.

thanks for the response, turgrid. For me, checking out a snippet would be great. If you could dig one up for an example to go by...that would be really helpful.

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: Re: Price Sorting by Views or another way

As far as I can tell from a quick venture into views-2.0, it doesn't support sorting either =(

Supposedly in view-1.0 you can sort when you're using a table output, but I haven't played around with this yet, nor do I want a table output (but I assume you could use a table view and then re-write the output with the theme engine to steal the sorting feature).

Sometimes things in Drupal are too round about though and you need to get "lazy" and do stuff for yourself instead of relying on modules for everything. I think views make me waste more time than they ever save me anyways.

terry22's picture
Offline
Joined: 02/16/2009
Juice: 41
seller address

Hi,
Is there a way to declare seller's address as they will ship the products directly?
thanx

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: seller address

I don't believe there is a way to do this. BUT! you can set the shipping address for each individual item.

So what I did was installed uc_addresses and then overwrite the default address (and create a selectable drop down) with the default uc_address for the "seller" of that item.

I don't believe market place can deal with this out of the box.

terry22's picture
Offline
Joined: 02/16/2009
Juice: 41
Re: Re: seller address

thank you for your answer j0rd,

I' m new in Drupal so could you detail the process?

Quote:

overwrite the default address (and create a selectable drop down) with the default uc_address for the "seller" of that item.

I already installed uc_adresses and create default address for each seller but do not figure how to connect them to shipping.

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: Re: Re: seller address

This is more of an advanced topic, but I'll give you the overview. It's going to require for you to do some custom programming and reading some documentation.

uc_addresses allows you to associate multiple addresses with any particular user. Sellers in uc_marketplace are "users", so we can use uc_addresses to store multiple addresses for your sellers.

When you create a product in Ubercart there's an area which allows you to enter a different address where that item will ship from instead of your stores default shipping address. I personally only pull in their default address from uc_addresses.

What I've done, is use hook_form_alter (see drupal api docs) to modify the product add/edit form (form_id product_node_form) to include the additional addresses associated with the user from uc_addresses into the shipping addresses drop down.

Here's the snippet

<?php
function mymodule_form_alter($form_id, &$form) {
   switch(
$form_id) {
      case
'product_node_form':
        
$node = $form['#node'];
        
$vendor = user_load(array('uid' => $node->uid));
        
//dpm(array("VENDOR" => $vendor));
        
if(empty($node->nid)) {
           
# NEW Product
            //dpm(array("BEFORE" => $form['shipping']['default_address']));
           
$form['shipping']['default_address']['first_name']['#default_value'] = $vendor->default_address->first_name;
           
$form['shipping']['default_address']['last_name']['#default_value'] = $vendor->default_address->last_name;
           
$form['shipping']['default_address']['company']['#default_value'] = $vendor->default_address->company;
           
$form['shipping']['default_address']['street1']['#default_value'] = $vendor->default_address->street1;
           
$form['shipping']['default_address']['street2']['#default_value'] = $vendor->default_address->street2;
           
$form['shipping']['default_address']['city']['#default_value'] = $vendor->default_address->city;
           
$form['shipping']['default_address']['postal_code']['#default_value'] = $vendor->default_address->postal_code;
         }
         else {
           
# Editing a product
        
}
       
        
# I use this to require proper fields get entered, if they want to use a different address
        
foreach(array('first_name', 'last_name', 'phone', 'company', 'street1', 'street2', 'city', 'zone', 'postal_code', 'country') as $field) {
           
$form['shipping']['default_address'][$field]['#required'] = uc_address_field_required($field);
         }     
       }
       default:
        
//dpm(array("FORM_ID"  => $form_id));
        
break;
   }
}
?>

Can't confirm the code will work 100% because it's cut and paste, but should give you a general idea of the direction you should be heading.

fehin's picture
Offline
Joined: 12/17/2008
Juice: 154
Re: Re: Re: Re: seller address

Thank you j0rd for the code.
I got an error message when I enabled the module.

Parse error: syntax error, unexpected T_DEFAULT in /sites/all/modules/myaddress/myaddress.module on line 28.

What's on line 28 is "default:".

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: Re: Re: Re: Re: seller address

from a quick glance at the code "case 'product_node_form':" is missing a "break;" and there's one too many closing brackets.

Change

<?php
         
}
       }
       default:
       ...
?>

to

<?php

         

}
          break;
        default:
        ...
?>

I apologize for the poor cut & paste.

It also appears that since I'm a slacker I didn't post the rest of the code which populates $vendor->default_address. That's done in hook_user which I'll provide here.

<?php
function mymodule_user($op, &$edit, &$account, $category = NULL) {
  global
$base_url;

   switch(

$op) {
      case
'load':
         if(
user_access('act as seller', $account)) {
           
$aid = _uc_addresses_get_default_address_id($account->uid);
           
$address = _uc_addresses_db_get_address($account->uid, $aid);
           
$country_data = uc_get_country_data(array('country_id' => $address->country));
            if(
$country_data) {
               foreach(
$country_data as $cd) {
                 
$address->country_iso_code_2 = $cd['country_iso_code_2'];
                 
$address->country_name = $cd['country_name'];
               }
            }
            else {
              
$address->country_name = t('N/A');
            }
           
$account->default_address = $address;
         }
         break;
   }
}
?>

This hook takes the default address from uc_addresses and loads it into $user->default_address for your "act as seller" users. uc_addresses code there is written against the outdated 5.x-2.0 instead of the latest 5.x-2.1 code, but I assume it should still work.

fehin's picture
Offline
Joined: 12/17/2008
Juice: 154
Re: Re: Re: Re: Re: Re: seller address

Thank you for your reply.

I'm still getting the same error at line 29. "default:" is still causing an error.

Is this new code part of the module of the initial code that you posted above or I have to create a new module for it?

j0rd's picture
Offline
Getting busy with the Ubercode.
Joined: 07/16/2008
Juice: 453
Re: Re: Re: Re: Re: Re: Re: seller address

Since these are hooks I would recommend creating a new module for them instead of modifying ubercart_marketplace.

As for the default error. It's a simple PHP error probably having to do with too many (or not enough) closing brackets. You should be able to debug that yourself with minimal PHP knowledge.

fehin's picture
Offline
Joined: 12/17/2008
Juice: 154
Re: Re: Re: Re: Re: Re: Re: Re: seller address

Thanks JORd. I already created a seperate module, I was asking if the second code you posted should be added to that same module. I kind of figure that out.

I will look for the missing brackets when I get home tonight. I appreciate the help.

divinevette's picture
Offline
Joined: 01/30/2009
Juice: 11
Buyers paypal sellers

I have my site set up now where buyers can pay sellers directly and it is working pretty well. One thing I noticed though is that the payment type/amount is not listed in the order info, did I break this functionality, or did it never exist. I can't remember, thanks!

cristianmos's picture
Offline
Joined: 01/18/2010
Juice: 20
pay sellers directly

can you explain how did you solved the payment part. I couldn't find a way of doing it.

michael121's picture
Offline
Joined: 11/10/2012
Juice: 4
Looking for this

Hi, would you please post the code you used to make payments directly to seller paypal accout.

Thanks, michael