24/7 Support: 800.608.6482


Developer Videos

Videos | Miva Actions

ver. 9.0 and later

Video Transcript

In Miva Merchant, Actions are what tell Miva Merchant what to do. We touched briefly on actions in the last video. An action is simply a url parameter, or a hidden input and there’s a certain action code which is a four letter code that tells Miva “do this” when this form is submitted. Examples of actions are “add product to cart,” “remove product to cart,” “update quantity,” “login,” “logout” and there’s actions that Miva uses for the checkout process such as calculating tax, calculating shipping, authorizing a transaction, all these actions are built into Miva Merchant so you don’t have to worry about them. All the heavy lifting is done for you and you just tell Miva what actions to perform and when.

Now, most the time all the actions are already set up in Miva. You usually won’t build a custom form and add your own actions. You can if you want to, but you usually don’t need to. All the actions are already there.. The apc action (add product to cart) is already part of the product submit form. Let’s take a look at signin here. I’m going to inspect the login button here so I can see the form. So here we can see the action is LOGN. This is the action to log a customer in. So behind the scenes Miva Merchant will take that action and tie it to a function and it will do all the heavy lifting. It will set the right cookies, it will do the right validation, you don’t have to worry about any of that. It’s all done by Miva. You’re just telling Miva to perform this action when this form is submitted. So what that means is I can take this form and I can put it anywhere on the site. It doesn’t have to be on the LOGN page. I can create a whole new page say for wholesale. I can put the login form there. As long as I pass this action of LOGN, Miva will do all of the heavy lifting behind the scenes which makes it very nice.

So this is an example of an action that’s passed in a hidden input in the form. Most the time this is how you’ll see actions being used. But you can also pass an action as a url parameter. So let me login. So here I’m logged in to my account and here the logout link has an action in it. You see down here in the bottom left of my screen it says “Action=LOGO&Scren=SFNT.” So what this is saying is the LOGO actions is the “Logout” action. It’s going to log the customer out, which will clear it’s cookies and clear its session and then the screen is saying where you want it to go. So right now it’s going to go to the storefront page. But this can go anywhere. You can have it go to a custom logout page or anything you want. So when I click Logout, you’ll see I’m no longer logged in - this now got changed to Sign In, the action, LOGO was performed and now I’m back at the storefront screen because this is where I told it to go. So that’s an example of an action being used as a url parameter as opposed to a hidden input with no form. At the end of the day it all does the same thing.

One nice part about actions is that they can be chained. So you can do multiple actions within a single form submit. You’ll see this quite a bit during the checkout process. Let me add something to my cart, so here I’m on OCST which is the first page of checkout and I’m going to inspect this form. So here we see we actually have four actions. We have ORDR, SHIP, CTAX and AUTH. All these actions are paths in single hidden input with the name of an action and it’s just a comma separated list. Miva will go through these actions in order and perform each one. You may be asking yourself, how do I find out what these actions do? I’m going to show you a little bit of code, This code is actually from merchant.mvc, which is the core controller from Miva Merchant. It’s the default page that you see in the url right here, merchant.mvc and then you pass in some parameters to it. Well that page has some logic to parse out the action and make a callout to some function to perform that action.

So here’s a little code snippet and this code can actually be found in the miva Merchant Limited Source Kit “LSK.” It’s a free download from our web site. It contains most of the source code to Miva Merchant. You’ll usually use this if you’re going to be building modules, or just to dig more into the code base of Miva to see what’s going on. Now you’ll see the syntax is not the template language. This is Miva script. This is the language of what Miva Merchant is written in. You’ll want to ignore the syntax for now and I just want to show you this so we can see at a high level what’s going on. So here there’s an if l statement saying if the current action LOGN, LOGO and you’ll see there’s about 30 other actions here, if it finds one of these then it’s going to execute one of these functions. The function Action_Customer_Login, Action_Customer_Logout or ADPR, which you’ll see quite a bit which is “Add product to cart.” Action Add Product to basket. These are functions that are built into Miva Merchant and that do all of the heavy lifting behind the scenes. But I wanted to show you this so you can actually see what’s happening in the source code when an action is submitted via form. An action is just tied to a function. That function gets run and the results get returned back to you.

The important thing to remember with actions is that they tell Miva Merchant what to do. You can always look in the url or the form that’s being submitted to see what action is being run and what Miva’s going to do when that form is submitted.

Looking for Developer Docs?

We have a whole section for that, including: Developer Training Series, Template Language docs, Module Development tutorials and much, much more.

Head to the Developer Section

This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.


Copyright © 1997 – 2024 Miva®, Miva Merchant®, MivaPay®, MivaCon®, Camp Miva®, Miva Connect®, Miva, Inc. All Rights Reserved.