Skip to content

Simple Module Example#


This example walks through creating a minimal currency formatting module using the Miva Agency Partners Docker container. We’ll reuse an LSK template, customize metadata and hooks, compile within the container, and activate the module in your store.

Module Preparation#

1. Copy example from LSK On your host machine, duplicate Miva’s US currency module into a working file and rename it to newmoney.mv.

2. Update Module Metadata Open newmoney.mv and modify the Module_Description function:

<MvFUNCTION NAME = "Module_Description" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
    <MvASSIGN NAME = "l.module:code"        VALUE = "newmoney">
    <MvASSIGN NAME = "l.module:name"        VALUE = "New Currency Formatting">
    <MvASSIGN NAME = "l.module:provider"    VALUE = "Your Company">
    <MvASSIGN NAME = "l.module:version"     VALUE = "1.0000">
    <MvASSIGN NAME = "l.module:api_ver"     VALUE = "9.07">
    <MvASSIGN NAME = "l.module:features"    VALUE = "currency">
</MvFUNCTION>

3. Implement Hook Functions Ensure the three required functions are present:

  • CurrencyModule_AddFormatPlainText
    <MvFUNCTION NAME = "CurrencyModule_AddFormatPlainText" PARAMETERS = "module var, value" STANDARDOUTPUTLEVEL = "">
        <MvFUNCTIONRETURN VALUE = "{ CurrencyModule_AddFormatting( l.module, l.value ) }">
    </MvFUNCTION>
    
  • CurrencyModule_AddFormatPlainTextShort
    <MvFUNCTION NAME = "CurrencyModule_AddFormatPlainTextShort" PARAMETERS = "module var, value" STANDARDOUTPUTLEVEL = "">
        <MvFUNCTIONRETURN VALUE = "{ CurrencyModule_AddFormatting( l.module, l.value ) }">
    </MvFUNCTION>
    
  • CurrencyModule_AddFormatting

The first two are exact copies from the LSK template. For CurrencyModule_AddFormatting, override it to wrap values in red, blinking HTML:

<MvFUNCTION NAME = "CurrencyModule_AddFormatting" PARAMETERS="module var, value">
  <MvASSIGN NAME = "l.retval"
    VALUE = "{ '<font color=\"red\"><blink>N$ ' $ l.value $ '</blink></font>' }">
  <MvFUNCTIONRETURN VALUE = "{ l.retval }">
</MvFUNCTION>

Compile & Deploy via Docker#

To compile your file within Docker first complete Setting Up Docker Environment Steps 1-6.

To compile your .mv file into .mvc inside the container:

  1. In Containers, select your Miva Merchant container
  2. Using the three dots more action menu select Open in terminal
  3. Run:
    cd /scripts
    mvc newmoney.mv
    

Then in the Miva Admin UI:

  1. Go to Settings > Domain Settings > Modules > Add Modules and upload newmoney.mvc.
  2. Under Settings > Store Settings, choose New Currency Formatting in the Currency Formatting dropdown and save.

Your store now shows currencies prefixed with N\$ in red, blinking text.