Native Parameters#
In Miva Merchant development, native parameters play a crucial role in controlling store functionality, defining page behavior, and passing data between pages. These parameters are automatically converted into global variables, allowing developers to retrieve and manipulate store data dynamically.
Common Parameters#
The default URL structure of Miva Merchant includes several key parameters that control store behavior:
Screen#
- Defines the page code to be rendered.
- Acts as a controller, directing the system to display a specific store page.
- Common values:
SFNT
– Storefront (home page).CTGY
– Category page.PROD
– Product page.BASK
– Shopping cart page.INVC
– Order invoice page.
- Example URL:
https://yourstore.com/mm5/merchant.mvc?Screen=PROD&Product_Code=PRODUCT123
- This URL instructs Miva to load the product page for
PRODUCT123
.
- This URL instructs Miva to load the product page for
Product_Code#
- Identifies the specific product to be displayed or manipulated.
- Used primarily on product pages but also in cart, checkout, and promotional links.
- Example Usage:
- Viewing a product:
https://yourstore.com/mm5/merchant.mvc?Screen=PROD&Product_Code=SHOES001
- Adding a product to the cart:
<form method="post" action="https://yourstore.com/mm5/merchant.mvc"> <input type="hidden" name="Screen" value="BASK"> <input type="hidden" name="Action" value="ADPR"> <input type="hidden" name="Product_Code" value="SHOES001"> <button type="submit">Add to Cart</button> </form>
- Viewing a product:
Category_Code#
- Specifies the category being displayed.
- Used primarily on category pages to retrieve and display products within a category.
- Example URL:
https://yourstore.com/mm5/merchant.mvc?Screen=CTGY&Category_Code=SUMMER_SHOES
- This URL loads the category page for
SUMMER_SHOES
, displaying all products assigned to that category.
Store_Code#
- Specifies which store’s data to retrieve.
- Primarily used in multi-store environments to differentiate between multiple stores running on the same Miva installation.
- Optional for single-store setups.
- Example Usage:
https://yourstore.com/mm5/merchant.mvc?Screen=SFNT&Store_Code=STORE2
- This URL loads the storefront page (
SFNT
) forSTORE2
.
Action#
- Specifies the action to be performed.
- Used for operations such as adding a product to the cart, logging in a customer, or checking out.
- Common Actions:
LOGN
– Log in.LOGO
– Log out.ADPR
– Add a product to the cart.ORDR
– Process an order.
- Example: Logging Out a Customer:
https://yourstore.com/mm5/merchant.mvc?Action=LOGO
- Example: Adding a Product to the Cart via URL:
https://yourstore.com/mm5/merchant.mvc?Action=ADPR&Product_Code=PRODUCT123&Quantity=1
Hidden Inputs and Actions in Forms#
In addition to URL parameters, hidden inputs within forms operate similarly by passing data to Miva Merchant when a form is submitted. These inputs allow developers to define store behaviors without relying solely on URL parameters.
Example: Adding a Product to the Cart via a Form#
<form method="post" action="https://yourstore.com/mm5/merchant.mvc">
<input type="hidden" name="Screen" value="BASK">
<input type="hidden" name="Action" value="ADPR">
<input type="hidden" name="Product_Code" value="PRODUCT123">
<input type="number" name="Quantity" value="1">
<button type="submit">Add to Cart</button>
</form>
ADPR
) tells Miva to add the specified product to the cart.
- The Screen (BASK
) ensures the customer is redirected to the cart page after adding the product.
Understanding How Miva Merchant Processes Parameters#
When a URL with parameters is loaded, or a form with hidden inputs is submitted, Miva Merchant:
- Parses the incoming parameters from the URL or form submission.
- Converts them into global variables within the store environment.
- Executes the corresponding action (if applicable).
- Renders the requested screen, populating it with data based on the provided parameters.
This process allows Miva Merchant to dynamically generate pages and execute operations based on user interactions.
Best Practices for Working with Native Parameters#
-
Use Meaningful Screen Codes:
- Ensure URLs reference valid screen codes to prevent navigation errors.
-
Validate User Input:
- When using form-based actions, validate input fields to prevent incorrect data submissions.
-
Chain Parameters When Needed:
- Combine multiple parameters in a single URL to improve efficiency (e.g., viewing a product and adding it to the cart simultaneously).
-
Test in a Staging Environment:
- Experiment with different parameters in a test environment before applying them to a live store.
-
Utilize Hidden Inputs for Secure Data Handling:
- Use hidden inputs within forms to pass secure data rather than exposing sensitive details in URLs.
Summary#
Understanding native parameters in Miva Merchant is essential for customizing store functionality and optimizing navigation. These parameters allow developers to control which pages are displayed, execute actions, and pass data dynamically between store components.