Try our new AI assistant by clicking the chat icon in the lower right corner.

Price Groups Via Template Code

On this Page


Miva also has template level functions which can be used in any Miva page template to allow you to assign or unassign a shopper to/from a price group. When setting up a price group you have 4 customer assignment options: All shoppers, Logged in shoppers, Coupon only and Specific Customers (customers who are logged in). These new template level functions allow you override the default assignment set at the price group level with the individual shopper/basket.

For example, say you want to run a PPC campaign and offer a 10% discount to only the shoppers who come into your store via a Pay Per Click ad. This new function would allow you to setup the logic to do this in your Miva page template.

Other common use cases include:

The price group is assigned to the shopper at the basket level so once they have been assigned to the price group it will be valid until either it gets explicitly removed (via template code) or the basket expires and is deleted.


It's also important to note that the price group's start and end dates will still be used. If you assign a price group which is not valid because of the date range configured, these functions will not override those settings.

Setup and Configuration

There are two new functions available to use:

Assign Shopper to Price Group

Unassign Shopper to Price Group

Use Cases and Examples

Here we are cheking for the existence for a global variable named "ppc_campaign" and checking to see if has the value of "black_friday". This name/value pair would need to be passed in your PPC campaign url.

Here we are cheking for the http_refer variable which holds the URL the customer came from to land on your site.

Provisional Baskets

This feature will work as expected when using provisional baskets. If a price group is being assigned via template code and provisional baskets is in use, Miva will automatically convert the provisional basket to a real basket so that it can correctly assign the price group discount.

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 – 2021 Miva©, Miva Merchant©, MivaPay©, MivaCon© Miva, Inc. All Rights Reserved.