Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Miva - INVC Create Account

Miva - INVC Create Account

Add a form to the INVC page to allow new customers to create an account by just providing a login & password. After the customer creates an account, there is some functionality to assign the customer to the order that they just placed too.

Screen shot of form on INVC page

Implimentation Steps:

  1. Create a ReadyTheme Content Section with a code of invc_create_account.
  2. Add the contents of the miva-invc-create-account.xml snippet to the ReadyTheme Content Section.
  3. Add the <mvt:item name="readytheme" param="contentsection( 'invc_create_account' )" /> item to the INVC page where you want the form to display.
  4. Add the <mvt:item name="readytheme" param="contentsection( 'invc_create_account' )" /> item to the LOGN page so that the customer can be assigned to the order.
<mvt:comment>
| ------------------------------------------------
| Display Create Account Inputs on INVC
| -------------------------------------------------
</mvt:comment>
<mvt:if expr="l.settings:page:code EQ 'INVC'">
<mvt:if expr="NOT l.settings:order:cust_id">
<div class="column whole">
<div class="well align-center">
<div class="row">
<div class="column medium-three-fourths centered">
<h2 class="well-heading">Checkout even faster next time!</h2>
<p class="well-lead">Create a password below to enjoy the member perks and even easier checkout next time.</p>
<form action="&mvt:global:secure_sessionurl;" method="post" id="js-order-create-account">
<input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;">
<input type="hidden" name="Action" value="ICST">
<input type="hidden" name="Screen" value="LOGN">
<input type="hidden" name="PrevPage" value="INVC">
<input type="hidden" name="NewAccount" value="yes">
<input type="hidden" name="Order_ID" value="&mvte:order:id;">
<mvt:comment>
<input type="hidden" name="Customer_LoginEmail" value="&mvte:order:ship_email;">
</mvt:comment>
<div class="row">
<div class="column whole medium-one-third">
<div class="floating-placeholder">
<input type="email" name="Customer_LoginEmail" id="js-customer-login-email" class="input" value="&mvte:order:ship_email;">
<label for="js-customer-login-email">Login Email</label>
</div>
</div>
<div class="column whole medium-one-third">
<div class="floating-placeholder">
<input type="password" name="Customer_Password" id="js-customer-password" class="input" oninput="document.getElementById('js-customer-verify-password').value = this.value">
<label for="js-customer-password">Password</label>
</div>
</div>
<input type="hidden" name="Customer_VerifyPassword" id="js-customer-verify-password">
<mvt:comment>
<div class="column whole medium-one-third">
<div class="floating-placeholder">
<input type="password" name="Customer_VerifyPassword" id="js-customer-verify-password" class="input">
<label for="js-customer-verify-password">Verify Password</label>
</div>
</div>
</mvt:comment>
<div class="column whole medium-one-third">
<button type="submit" class="button button-medium button-primary button-block">Create Account</button>
</div>
</div>
<input type="hidden" name="Customer_ShipFirstName" value="&mvte:order:ship_fname;">
<input type="hidden" name="Customer_ShipLastName" value="&mvte:order:ship_lname;">
<input type="hidden" name="Customer_ShipEmail" value="&mvte:order:ship_email;">
<input type="hidden" name="Customer_ShipPhone" value="&mvte:order:ship_phone;">
<input type="hidden" name="Customer_ShipAddress1" value="&mvte:order:ship_addr1;">
<input type="hidden" name="Customer_ShipAddress2" value="&mvte:order:ship_addr2;">
<input type="hidden" name="Customer_ShipCity" value="&mvte:order:ship_city;">
<input type="hidden" name="Customer_ShipState" value="&mvte:order:ship_state;">
<input type="hidden" name="Customer_ShipZip" value="&mvte:order:ship_zip;">
<input type="hidden" name="Customer_ShipCountry" value="&mvte:order:ship_cntry;">
<input type="hidden" name="Customer_BillFirstName" value="&mvte:order:bill_fname;">
<input type="hidden" name="Customer_BillLastName" value="&mvte:order:bill_lname;">
<input type="hidden" name="Customer_BillEmail" value="&mvte:order:bill_email;">
<input type="hidden" name="Customer_BillPhone" value="&mvte:order:bill_phone;">
<input type="hidden" name="Customer_BillAddress1" value="&mvte:order:bill_addr1;">
<input type="hidden" name="Customer_BillAddress2" value="&mvte:order:bill_addr2;">
<input type="hidden" name="Customer_BillCity" value="&mvte:order:bill_city;">
<input type="hidden" name="Customer_BillState" value="&mvte:order:bill_state;">
<input type="hidden" name="Customer_BillZip" value="&mvte:order:bill_zip;">
<input type="hidden" name="Customer_BillCountry" value="&mvte:order:bill_cntry;">
</form>
</div>
</div>
</div>
<br><br>
</div>
</mvt:if>
<br>
</mvt:if>
<mvt:comment>
| ---------------------------------------------------
| When they create an account,
| assign Customer to the order they just placed
| This runs on LOGN after the above form is submitted
| ----------------------------------------------------
</mvt:comment>
<mvt:if expr="g.Action EQ 'ICST' AND g.Order_ID AND g.Basket:cust_id">
<mvt:do file="g.Module_Library_DB" name="l.result" value="Order_Load_ID( g.Order_ID, l.order )" />
<mvt:if expr="NOT l.order:cust_id AND g.Customer_BillEmail EQ l.order:bill_email AND g.Customer_BillPhone EQ l.order:bill_phone">
<mvt:assign name="l.order:cust_id" value="g.Basket:cust_id" />
<mvt:do file="g.Module_Library_DB" name="l.result" value="Order_Update_Customer_Information( l.order )" />
</mvt:if>
</mvt:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment