Scot's Scripts Miva Merchant Module Support

Scot's Scripts Miva Merchant Module Support

Support for our Miva Modules.
Find answers to your installation and usage questions.
This is the place to start if you have questions about our modules. Most of our Miva Modules are fully documented. Do not hesitate to contact us if you can't find the answer you're looking for!

Looking for something? Start typing here:

Scot's Blogger is used to created this support system.

Loyalty Plus

last updated

Loyalty Rewards Plus is a powerful and customizable points module for Miva Merchant. Your developer will be able to set it up so that your store points work exactly how you want them to.

There are three main ways to add points to a customer account.

  1. Manual point add/remove while editing a customer account
  2. Add a set number of points using a page item that uses the add_points(...)parameter.
  3. Add points based on sale
1. Manual Point Add

Open a customer account for editing and find the Loyalty Plus tab. Add or remove points and view customer point history.

2. Add Points Using Page Item

Use a page item to add a set number of points to a customer account. Customers must be logged in for this to work.

The basic structure of the page item is:

<mvt:item name="loyaltyplus" param="add_points(
action,
schedule_code,
g.customer:id,
number of points,
history_type,
history description,
message to load on successful operation,
debug_off/debug_on
)" />

The parameters can be one of three types:

  1. String: Literal value, such as for the description, "email signup points"
  2. Global variable: g.some_variable - this is from the URL or a form post.
  3. l.settings local variable: This is set manually using mvt:assign or mvt:capture and is recommended to keep the page item simple.

Parameter Descriptions

action The action parameter is used to filter when points are added. This parameter forces the system to add points only if the g.action variable matches this. For example, if someone adds something to the cart the miva actions is ADPR. Use ADPR as the action parameter to add points when someone puts something in their cart.

Important:
 Reserved action word: ALL - this is used to add points regardless of the value of g.action

Custom actions:
Use any g.action value. Send it via a form or on the URL, but be careful of using an action code that Miva Merchant already uses. To be safe, make any custom actions at least 5 letters long because Miva Merchant actions are 4 letters long.
schedule_code If a schedule has been set then put the code for the schedule here. If schedule is not being used, leave it blank (comma is still required.)
customer_id Points require a customer ID. Without a customer ID, the points routine will exit. Generally g.customer:id is used here.
number of points Put a number or a variable here.

In cases where you are giving the customer a set number of points for doing something, such as signing up to an email list, you can enter a number here.

For assigning variable number of points, such as after the sale is completed, you would put a variable here. See the Invoice Page example below.
history_type This is a code that will get saved to the points history. Maximum length is 32 characters. This is a way to group ways the customer gets and uses points when you view the points history.
history description This shows up in the history data and is where you describe why the points were added.
message This is a message that will be assigned to l.settings:loyaltyplus:message when points are added and can be displayed via mvt:eval or using &mvt:loyaltyplus:message;
debug_off/debug_on This is a way to turn debug on just for the page item. Quick and dirty debug. Add a comma after the message setting and enter debug_on

Example: Give 100 points for signing up to an email list.

Give people 100 points for signing up to an email list by adding a Loyalty Plus page item to the email signup "Thank You" page.

We'll set up the description and message as variables using mvt:capture to make it easier: We don't have to escape and do other cryptic stuff to use punctuation this way.

In this example we are going to only add the points if g.action is EMAIL_SIGNUP.

<mvt:capture variable="l.settings:points_description">
email signup
</mvt:capture>
<mvt:capture variable="l.settings:points_message"> Thank you for signing up! Your account has received 100 points. </mvt:capture>
<mvt:item name="loyaltyplus" param="add_points( EMAIL_SIGNUP, , g.customer:id, 100, EMAIL_SIGNUP, l.settings:points_description, l.settings:points_message, debug_off )" />

On the "thank you for signing up" page display the message like this: &mvt:loyaltyplus:message;

3. Points Based on Total Sale: Invoice Page

Give people 3 points for every dollar they spend by setting the points value dynamically based on the subtotal of the sale.

In this case, assign l.settings:points the order total multiplied by 3 and then use l.settings:points for the points option in Loyalty Plus page item.

Note that you can assign points on a variety of conditions, such as rolling through the order items, the order subtotal, among others. Your developer will be able set it up to work the way you want.

Invoice Page Settings:

1. Add the LOYALTYPLUS page item to the INVC page

2. Add the following code somewhere AFTER the <mvt:item name="order_contents" /> page item so the order system has a chance to populate the data we need.

Tip: use the &mvt:loyaltyplus:message; page entity after the code so the customer knows how many points they received.

In this example we are not using a schedule code so it's blank with just the comma. 

<section class="o-layout o-layout--wide">
<div class="o-layout__item u-width-12 u-width-8--l">
<mvt:item name="order_contents" />

<mvt:comment> # # LOYALTY PLUS: set the points based on order total, in this case they are getting $.05 per dollar spent # </mvt:comment>
<mvt:if expr="l.settings:loyaltyplus:active EQ 1"> <mvt:assign name="l.settings:sales_points" value="l.settings:order:subtotal * 3" />
<mvt:capture variable="l.settings:points_description"> points based on subtotal sale: $&mvt:order:subtotal; </mvt:capture>
<mvt:capture variable="l.settings:points_message"> Your order has earned you &mvt:sales_points; loyalty points, congratulations! </mvt:capture>
<mvt:item name="loyaltyplus" param="add_points( ALL, , l.settings:order:cust_id, l.settings:sales_points, SUBTOTAL_SALE, l.settings:points_description, l.settings:points_message, debug_off )" />
<h5>&mvt:points_message;</h5> </mvt:if>
<mvt:comment> # # END LOYALTY PLUS # </mvt:comment>

Note: Using mvt:capture to set variables for points, description, and message. This makes it easier to add them to the page item. Usingl.settings or g. means your developer doesn't have to mess with trying to escape various characters or try to do math in the page item (which doesn't work.)

Customer Points Redemption Form

Add the form below anywhere on your site. Make sure the LOYALTYPLUS page item is assigned to the page to load customer points data.

This code only displays the redemption form if a customer is logged in and if the system is active.

Redemption Form:

<mvt:if expr="l.settings:loyaltyplus:active EQ 1 AND g.customer:id GT 0">
    <form method="post" action="&mvte:urls:BASK:secure;">
    <input type="hidden" name="loyaltyplus_custid" value="&mvte:global:customer:id;">
    <div>Points available: &mvt:loyaltyplus:points:available;/&mvt:loyaltyplus:points:point;</div>
    <div>
        <label>Enter Points to Redeem</label>
        <input type="number" name="loyaltyplus_redeem" value="&mvte:loyaltyplus:points:redeem;">
    </div>
    <button type="submit" name="action" value="loyaltyplus_redeem">Redeem Points</button>
    </form>

<form method="post" action="&mvte:urls:BASK:secure;"> <input type="hidden" name="loyaltyplus_custid" value="&mvte:global:customer:id;"> <input type="hidden" name="loyaltyplus_redeem" value="0"> <button type="submit" name="action" value="loyaltyplus_redeem">Reset Points</button> </form> <mvt:elseif expr="g.customer:id LE 0"> <div>Log in to redeem points.</div> </mvt:if>

Note: This form is unstyled. You will need to fit it into whatever framework you are using.

Customer Account Page Points History

Step 1: Assign the Loyalty Plus page item from the ITEMS tab on the Customer Account ACLN page.

Step 2: Add the following code (styled for Bootstrap 5) to the ACLN page. Note the <mvt:item name="loyaltyplus" param="load_history()" /> page item.

<mvt:comment>
#
# LOYALTY PLUS ACCOUNT PAGE
#
</mvt:comment>
<mvt:if expr="l.settings:loyaltyplus:active EQ 1 AND g.customer:id GT 0">

<mvt:item name="loyaltyplus" param="load_history()" />
<div class="row"> <div class="col"> <h4 class="mt-3">Loyalty Points History</h4> <table class="table table-sm mt-2" id="customer-history"> <thead> <tr> <th>Date</th> <th>Points</th> <th>Running</th> <th>Type</th> <th>Description</th> <th>Order ID</th> </tr> </thead> <tbody> <mvt:if expr="miva_array_elements(l.settings:loyaltyplus:history) LE 0"> <tr> <td colspan="6">You have no loyalty points history to show.</td> </tr> </mvt:if> <mvt:foreach iterator="item" ARRAY="loyaltyplus:history"> <tr> <td>&mvt:item:settings:date_formatted;</td> <td class="text-end pe-4"> <mvt:if expr="l.settings:item:points LT 0"> <span class="text-danger">&mvt:item:points;</span> <mvt:else> <span class="text-success">&mvt:item:points;</span> </mvt:if> </td> <td>&mvt:item:settings:points_total;</td> <td>&mvt:item:type;</td> <td>&mvte:item:settings:description;</td> <td> <mvt:if expr="l.settings:item:order_id GT 0"> <a href="&mvte:urls:ORDS:auto_sep;Order_ID=&mvt:item:order_id;">&mvt:item:order_id;</a> </mvt:if> </td> </tr> </mvt:foreach> </tbody> </table> </div> </div> </mvt:if>