Creating custom seller account fields in MultiMerch

Since we don't have a feature in MultiMerch that would allow the store owner to define custom seller account fields, here's a quick tutorial on adding them manually in about 5 simple steps. A separate vQmod xml file is included in the end of the tutorial - use it instead of overwriting MultiMerch and OpenCart core files!

Let's say we want add a new text field called Phone to make it possible for our sellers to specify their phone number and display it in their profile.

1. Modifying the database

First we need to modify the database to include our new field. MultiMerch stores seller information in the ms_seller table, so we'll use phpMyAdmin to create the new field. Alternatively, we can also do it manually by using the following SQL command:

In case we ever want to reinstall MultiMerch and want this field to get created automatically during installation, we'll need to modify MultiMerch installation model and add our new field to the ms_seller CREATE statement:

admin/model/multiseller/install.php ~65

This will create the new phone field will be created when MultiMerch is installed.

2. Adding the new field to the seller model

We've modified the database, but MultiMerch doesn't know about it yet, so we need to modify the seller model to read and write information to our new field.

There are 4 functions we're interested in: getSeller, getSellers, createSeller & editSeller. We simply add the new field to all of the functions:

system/library/msseller.php

That's it! MultiMerch now knows about our new field and will store and retrieve the new data from the database.

3. Displaying the field in the account template

We can now proceed to modifying the seller account template to tell our sellers about the new phone field they can use. We'll add the new phone field before the company field.

catalog/view/theme/default/template/multiseller/account-profile.tpl ~60

As you can see, we're using language variables $ms_account_sellerinfo_phone and $ms_account_sellerinfo_phone_note to display field name and description. Let's add them to our language file:

catalog/language/english/multiseller/multiseller.php ~420

Try refreshing the seller profile account page now – the new field should be visible.

4. Adding some validation to the account controller

Now let's add just a little validation. OpenCart (and MultiMerch) follows the MVC pattern that uses controllers to pass data from template to models. MultiMerch uses the jxSaveSellerInfo function in the account-profile.php controller to perform things like form validation, so we'll modify it a little.

catalog/controller/seller/account-profile.php ~90

We'll also add the error message to the language file to make it translatable.

catalog/language/english/multiseller/multiseller.php ~237

This simple check will warn the seller if he tries to enter too much information in the phone field. You can use any of the phone number regular expressions available in the web instead for a more advanced validation.

5. Showing the new data in the public seller profile

Now our sellers can specify their phone number, so let's display it on their profile in store.

catalog/controller/seller/catalog-seller.php ~233

catalog/view/theme/default/template/multiseller/catalog-seller-profile.tpl ~71

catalog/language/english/multiseller/multiseller.php ~658

That's pretty much it! Your sellers can now specify their phone number and display it in their public profile.

You can use this guide to create all kinds of extra seller fields until we implement a separate feature to do this. Also, we strongly suggest you use vQmod to keep the changes out of Multimerch core files so that you don't lose them during upgrade. For this matter, we've created a ready-made vQmod file based on this tutorial for you to use – grab it here!

P.S. We also have our very own MultiMerch Community Forums - drop by and share your thoughts about this article and the rest of MultiMerch!

  • dhiraj

    It works fine, but how to show these fields at admin side?
    How to make fields that can be filled up only once by user like paypal email Id

    • Martin Boze

      Displaying them at admin side would require modifying the admin seller.php controller and seller-form.tpl template in the same way.

  • Rao

    Hi Martin,

    First let me say its great solution.
    Does MM recent version works with Journal 1 theme?

  • Argo Tali

    Hi! It´s a wonderful piece of work you have done (the MM module)! Thanks! I have a question, if i have added a custom field (withdrawal method via bank account) through vqmod and i would like to check (as Paypal field check), whether the required field (IBAN) is set, then which files should i modify to make it work? I can´t get it work modifying only the account-withdrawal.tpl file :(

  • Khadreal

    How can i show the custom field created in the admin

  • Hi,
    Nice Tutorial
    1. the vqmod link not working.
    2. is a tutorial for OC2.2 ( i cant find line catalog/view/theme/default/template/multiseller/catalog-seller-profile.tpl ~71)