API access

To be able to verify MinMaxify limits outside of the standard Shopify online stores you need to activate access to them via this option located at the bottom of "Preferences" section in our app's admin interface:

Once this it is turned on and the limits are re-published, our backend would start providing access to the limits under https://shopifyorderlimits.s3.amazonaws.com/limits/<account-id>.myshopify.com.jsonp URL in a form of a standard JavaScript module.

To make use of the limits you have to define minMaxify.initCartValidator() in your global JS scope. Once our script is loaded it would make a call to that function and pass our cartValidator object as it's only parameter.

Here's an example of a typical initCartValidator implementation:

<!-- This is your interface code required to accept MinMaxify's limits validator -->
<script  type="text/javascript">
var cartValidator;
var minMaxify {
    initCartValidator: function(v) {
        validator = v;
        console.log('MinMaxify limits loaded');
    }
};
</script>

<!-- And this is how you get our API loaded -->
<script src="https://shopifyorderlimits.s3.amazonaws.com/limits/<account-id>.myshopify.com.jsonp?timestamp=20220913201153"></script>

After that you can start making calls to cartValidator object obtained above. It would expose the following two methods:

// the following Validator object's methods are accepting "context" parameter
// which has to be a JS object containing two fields:
//
// * "cart" representing an extended version of the standard Shopify cart.js record
// {
//     "token": "7e3354cad82b9174f0cbf45aea2cf4e6",
//     "note": null,
//     "attributes": {},
//     "original_total_price": 400,
//     "total_price": 400,
//     "total_discount": 0,
//     "total_weight": 798.3226,
//     "item_count": 2,
//     "items": [
//         {
//             "id": 20349995269,
//             "properties": {},
//             "quantity": 2,
//             "variant_id": 20349995269,
//             "key": "20349995269:b96ed849c4c091ce3bd82e8f84441240",
//             "title": "Acana Adult Large Breed - 400 gr",
//             "price": 200,
//             "original_price": 200,
//             "discounted_price": 200,
//             "line_price": 400,
//             "original_line_price": 400,
//             "total_discount": 0,
//             "discounts": [],
//             "sku": "54993531400",
//             "grams": 399,
//             "vendor": "Acana",
//             "taxable": true,
//             "product_id": 6223572549,
//             "product_has_only_default_variant": false,
//             "gift_card": false,
//             "final_price": 200,
//             "final_line_price": 400,
//             "url": "/products/acana-adult-large-breed?variant=20349995269",
//             "featured_image": { ... },
//             "image": "https://cdn.shopify.com/s/files/1/1490/9996/products/acana-adult-large-breed.jpg?v=1473937526",
//             "handle": "acana-adult-large-breed",
//             "requires_shipping": true,
//             "product_type": "Dog food",
//             "product_title": "Acana Adult Large Breed",
//             "product_description": "Pienso para Dogs - Telepienso",
//             "variant_title": "400 gr",
//             "variant_options": ["400 gr"],
//             "options_with_values": [{ "name": "Title", "value": "400 gr" }],
//             "line_level_discount_allocations": [],
//             "line_level_total_discount": 0,
//             "coll": [222678021],
//             "ptag": ["Adult", "Dog", "Giant Breed", "Grain Free", "Large Breed"]
//         }
//     ],
//     "requires_shipping": true,
//     "currency": "EUR",
//     "items_subtotal_price": 400,
//     "cart_level_discount_applications": []
// }
// The only difference from the standard are these two fields expected in each cart item by MinMaxify
//    "coll": [222678021],
//    "ptag": ["Adult", "Dog", "Giant Breed", "Grain Free", "Large Breed"]
// They can be skipped by the caller if they're certain the per-account settings set
// doesn't contain any limitation requiring those two fields.
//
// * "customer" is the second, optional context field.
// It is supposed to contain { "tags": [...] } string list for the current customer
// should customer tag-based conditioning is defined for the context Shopify account.

var validator = {

    validateCart: function (context) {
        // returns "CheckState" object with "isOk" property and "messages" list containg the errors 
    },

    getItemLimits: function (context, item) {
        // returns a computed limit record for this variant. Something like { min: 1, max: 10 }
    },

};

A working example of MinMaxify's API client will be provided inside our Hydrogen plugin which is planned to be released by the end of 2022.