I seem to be answering a lot of my own posts recently... not that I'm bitter, just a little twisted. Here's the solution for anyone with a similar problem.
From the checkout_shipping page, the below will open the form with an instruction to call the check_form() function when the submit button is pressed. The key text that I've added is highlighted in red.
Code:
<?php echo zen_draw_form('checkout_address',zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'), 'post', 'onsubmit="return check_form(productsObj);"') . zen_draw_hidden_field('action', 'process'); ?>
The javascript check_form function is below and can be written to a jscript_main.php file in the /mywebsite.com/catalog/includes/modules/pages/checkout_shipping or wherever. If the value of user_quantity_total is less than that of productsObj[key]['qty'], false is returned and the submit fails. I've greyed out the parts that are only relevant to my site. The key text is the if statement.
Code:
function check_form(productsObj) {
for (key in productsObj) {
user_quantity_total = 0;
for (key2 in productsObj[key]['sellers']){
user_quantity_total += productsObj[key]['sellers'][key2]['user_selected_quantity'];
}
if (user_quantity_total < productsObj[key]['qty'])
{alert("<?php echo 'This has failed validation'; ?>");
return false; }
}
}
Drop me a pm if anyone needs further clarification on this.
Cheers, Steve