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:


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!