// Get the product ID of the product you want to auto-fulfill
var productId = 123456789;
// Listen for the checkout.order.completed event
$(document).on('checkout.order.completed', function(event, data) {
// Get the array of items in the order
var items = data.items;
// Loop through the items in the order
for (var i = 0; i < items.length; i++) {
// Check if the item is the product you want to auto-fulfill
if (items[i].product_id == productId) {
// Fulfill the item
var itemId = items[i].id;
var fulfillUrl = '/admin/orders/' + data.order_id + '/fulfillments/new?fulfillment[line_items][]=' + itemId;
window.location.href = fulfillUrl;
}
}
});
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter