Can't find what you're looking for? Try our AI Chat Bot in the bottom right corner!

Articles in this section

Price Groups Via Template Code

Price Groups Via Template Code

Overview

Miva includes template level functions which can be utilized on any Miva page template. These are designed to allow the assignment or unassignment of shoppers to/from particular price groups. 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 template functions give you the ability override the default assignment set at the price group level for the individual shopper/basket.

For example, if one wants to run a PPC campaign and offer a 10% discount only to shoppers who visit your store via a Pay Per Click ad, this function can be set up to achieve that. Other use cases include:

  • Offering discounts to specific shoppers based on their origin (URL parameter or page referer).
  • Offering discount based on the specific country of the customer (geoip).
  • Excluding free shipping price groups by geography (customers in Alaska and Hawaii don't get free shipping).
  • Providing a discount/free gift to a customer for completing a specific action.

Price group assignment happens at the basket level. Once assigned to the price group, the assignment is valid until it gets explicitly removed (via template code) or the basket expires and is deleted.

Please keep in mind that the price group's start and end dates are still considered. If you assign a price group, which is not valid due to the configured date range, these functions will not override those settings.

Setup and Configuration

Two new functions are available:

Assign Shopper to Price Group

Copy
<mvt:do file="g.Module_Feature_PGR_UT" name="l.result" value="Basket_Assign_Persistent_PriceGroup( basket_id, pricegroup_name )" />

Unassign Shopper to Price Group

Copy
<mvt:do file="g.Module_Feature_PGR_UT" name="l.result" value="Basket_Remove_Persistent_PriceGroup( basket_id, pricegroup_name )" />

Use Cases and Examples

The following example checks for a global variable named "ppc_campaign" and verifies if it has the value of "black_friday". This name/value pair would need to be passed in your PPC campaign URL.

Copy
<mvt:if expr="g.ppc_campaign EQ 'black_friday'">
    <mvt:do file="g.Module_Feature_PGR_UT" name="l.result" value="Basket_Assign_Persistent_PriceGroup(g.Basket:basket_id,'20Off')" />
</mvt:if>

The second example checks for the http_refer variable which holds the URL the customer came from to visit your site.

Copy
<mvt:if expr="'google' CIN s.http_referer'">
    <mvt:do file="g.Module_Feature_PGR_UT" name="l.result" value="Basket_Assign_Persistent_PriceGroup(g.Basket:basket_id,'Welcome10')" />
</mvt:if>

Provisional Baskets

This feature works as expected with 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 one so that the price group discount can be correctly assigned.

Was this article helpful?
0 out of 0 found this helpful