You might want to customize the URL that users get redirected to after a successful login in order to better integrate your login page with the MobiLoud app. To do this, you can modify your theme code as follows:
Access the Theme Code:
Online Store
> Themes
.Actions
> Edit Code
.Locate the Login Form Code:
Sections
or Templates
, and the file might be named customers/login.liquid
or something similar.Add a Form ID:
Locate the form tag for the customer login form. Add an id
attribute to the form tag for easy reference in JavaScript. Your form tag should look something like this:
{%- form 'customer_login', novalidate: 'novalidate', id: 'customer_login_form' -%}
Insert the JavaScript Snippet:
Add the following JavaScript code at the bottom of the same file. This script checks if the user's user agent contains the string "canvas" (case insensitive) and updates the form action URL accordingly:
<script>
document.addEventListener('DOMContentLoaded', function() {
var form = document.getElementById('customer_login_form');
if (navigator.userAgent.toLowerCase().includes('canvas')) {
form.action += '?app_login=true';
}
});
</script>
After adding the JavaScript code, save the changes by clicking the Save
button in the top-right corner of the theme editor.