order_tracking

Generate a query order form that allows customers to query order information without logging in through the account and order number.

Inputs

InputInput TypeNameRequiredRemarks
Order Numbertextorder_tracking[order_number]RequiredOrder number for querying order information
Emailemailorder_tracking[email]OptionalEmail for querying order information
Phone Numbertextorder_tracking[phone]OptionalPhone number for querying order

Example

Query orders using email

{{#form 'order_tracking' id="order-tracking-form"}}
<div class="email">
<label for="order_tracking[email]">Email</label>
<input type="email" name="order_tracking[email]" placeholder="Email" />
</div>
<div class="order-number">
<label for="order_tracking[order_number]">Order Number</label>
<input type="text" name="order_tracking[order_number]" placeholder="Order Number" />
</div>
<div class="submit">
<input type="submit" value="Post">
</div>
{{/form}}

Output

Query orders using phone number

{{#form 'order_tracking' id="order-tracking-form"}}
<div class="code">
<label for="order_tracking[phone_area_code]">Code</label>
<input type="text" name="order_tracking[phone_area_code]" placeholder="Code" />
</div>
<div class="phone">
<label for="order_tracking[phone]">Phone Number</label>
<input type="text" name="order_tracking[phone]" placeholder="Phone Number" />
</div>
<div class="order-number">
<label for="order_tracking[order_number]">Order Number</label>
<input type="text" name="order_tracking[order_number]" placeholder="Order Number" />
</div>
<div class="submit">
<input type="submit" value="Post">
</div>
{{/form}}

Output

Used in conjunction

The above code needs to be used in conjunction with the following script.

class OrderTracking {
constructor() {
this.form = document.querySelector('#order-tracking-form');
this.form.addEventListener('submit', this.onSubmitHandler.bind(this));
this.orderTracking = new window.Shopline.OrderTracking(this.form);
}
onSubmitHandler(e) {
e.preventDefault();
this.orderTracking.submit()
.then(response => {
if (response.data?.orderUrl) {
window.location.href = response.data.orderUrl;
} else {
// handle other situations without response.data.orderUrl
}
})
.catch(response => {
// handle other situations with response.error_fields
})
}
}
// Initializing the JS SDK
window.Shopline.loadFeatures(
[
{
name: 'order-tracking-api',
version: '0.1'
}
],
function(error) {
if (error) {
throw error;
}
new OrderTracking();
}
);
Was this article helpful to you?

Error loading component.

Error loading component.