Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Created March 7, 2019 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/dfde2dfc1f6f078c3abd3ee56061fa11 to your computer and use it in GitHub Desktop.
Save steveosoule/dfde2dfc1f6f078c3abd3ee56061fa11 to your computer and use it in GitHub Desktop.
Miva - Staging & Testing Changes

Overview

When developing a new feature for a mive-store. Ideally perform it in on a dev-store/environment until it is finalized & ready for implementation. Then once it is read for implementation, it may take updating several page-templates, global-templates, and other misc. places in order to activate the new feature.

To test the new-feature on the live-store in a seamless & safe manor we can prepare all the changes underneath a series of conditionals that will evaluate to true when a single-global variable is set. This is sometimes called Staging Changes Before Going Live.

This allows us to set the global variable by various methods, and it also allows us to launch the changes to the public across various page templates by setting a single variable value to a truthy value.

Approach

  1. Decide on a global-variable/code that you will use to hide all the new-feature’s code: g.enable_MY_NEW_FEATURE
  2. For all the new-feature code that needs to be changed, wrap them in conditionals & expressions that will reveal the new feature & hide the old-feature based on that global variable.
  3. In the HTML profile, add method(s) for setting the g.enable_MY_NEW_FEATURE global-variable based on the conditions that you’d like to let people preview the new feature (ex: Basket Custom Field, Customer Account, IP Address, Cookie, etc)
  4. Let the client test/preview the feature Once the feature has been tested/approved, to launch the new-feature, set the g.enable_MY_NEW_FEATURE variable to a truthy value in the HTML Profile.
  5. After the new feature is ready to be committed to the site indefinitely, remove the g.enable_MY_NEW_FEATURE conditionals and make the new-feature’s code remain

Methods for Previewing Features

Use one of the following method for detecting if the user/device/session should show the new feature or not:

Enabled Feature with Query-String & Basket Custom Fields*

Note: *This is my preferred method for letting clients preview new features. You can provide them two links: 1) to enable the new feature for their session 2) to stop previewing it and revert back to the public/default version.

<mvt:comment>
In HTML Profile:
</mvt:comment>
<mvt:if expr="g.enable_MY_NEW_FEATURE EQ 'true'">
  <mvt:item name="customfields" param="Write_Basket('enable_MY_NEW_FEATURE', 1)" />
<mvt:elseif expr="g.enable_MY_NEW_FEATURE EQ 'false'">
  <mvt:item name="customfields" param="Write_Basket('enable_MY_NEW_FEATURE', '')" />
<mvt:else>
  <mvt:item name="customfields" param="Read_Basket('enable_MY_NEW_FEATURE', g.enable_MY_NEW_FEATURE)" />
</mvt:if>

Enabled Feature by Query-String

No need to add anything to the HTML Profile, just wrap all the new-feature code in a

<mvt:if expr="g.enable_NEW_FEATURE_X">
<div>My New Feature Code</div>
</mvt:if>

conditional and then visit: https://www.example.com/page-to-test.html?enable_NEW_FEATURE_X=true

Enabled Feature by Customer Login

<mvt:comment>
In HTML Profile:
</mvt:comment>
<mvt:if expr="g.customer:login EQ 'miva_dev' OR g.customer:login EQ 'client_login' OR OR g.customer:login EQ 'joe_schmo' ">
  <mvt:assign name="g.enable_NEW_FEATURE_X" value="1" />
</mvt:if>

Enabled Feature by IP-Address

<mvt:comment>
In HTML Profile:
</mvt:comment>
<mvt:if expr="s.remote_addr EQ '207.114.171.26' OR s.remote_addr EQ '2001:4870:a28c:828:b5af:fd38:b076:2d1d' OR s.remote_addr CIN l.settings:store:mnt_ips">
 <mvt:assign name="g.enable_NEW_FEATURE_X" value="1" />
</mvt:if>

Enabled Feature by User-Agent

<mvt:comment>
In HTML Profile:
</mvt:comment>
<mvt:if expr="'miva_dev' CIN s.http_user_agent">
 <mvt:assign name="g.enable_NEW_FEATURE_X" value="1" />
</mvt:if>

Enabled Feature by Cookie

<mvt:comment>
In HTML Profile:
</mvt:comment>
<mvt:if expr="g.request_cookies:miva_dev">
 <mvt:assign name="g.enable_NEW_FEATURE_X" value="1" />
</mvt:if>

Example

HTML Profile

<mvt:if expr="g.enable_new_password_process EQ 'true'">
  <mvt:item name="customfields" param="Write_Basket('enable_new_password_process', 1)" />
<mvt:elseif expr="g.enable_new_password_process EQ 'false'">
  <mvt:item name="customfields" param="Write_Basket('enable_new_password_process', '')" />
<mvt:else>
  <mvt:item name="customfields" param="Read_Basket('enable_new_password_process', g.enable_new_password_process)" />
</mvt:if>

Customer Password Reset (ACRT)

<mvt:if expr="g.enable_new_password_process">
  <div>New Customer Password Reset</div>
<mvt:else>
  <div>Default/Current Customer Password Reset</div>
</mvt:if>

Forgot Password (FPWD)

<mvt:if expr="g.enable_new_password_process">
  <div>New Forgot Password code</div>
<mvt:else>
  <div>Default/Current Forgot Password Code</div>
</mvt:if>

Client Preview

Let them know they can preview the new feature for their session with this link: https://www.example.com/?enable_new_password_process=true and they can revert to the default/public functionality with: https://www.example.com/?enable_new_password_process=false

Launch

Replace (or add this right after) the HTML Profile Basket Custom Field lines of code with an mvt:assign that always sets enable_new_password_process to true:

<mvt:assign name="g.enable_new_password_process" value="1" />

Conclusion/Summary

Detect the various conditions for who should be able to preview the feature once in the HTML Profile, set a Global Variable, and then reference the Global Variable in all of the pages & templates that the new-feature needs to reference. By placing all of the new template code changes under a single global variable, you can easily, preview, launch, & revert template code changes that occur across various pages & templates. After enough time has passed to ensure the new feature will be kept, you can remove the conditionals in each page-template and make it always display.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment