Add Checkbox Next To Every Item In The Approval Screen - xmpie-users/uStore-js GitHub Wiki

If you want to force the approver of an order to check a box next to each line item in the order before he can approve the order, add the following script:

Alt

<script type="text/javascript">
  $(document).ready(function(){
	if ($(".approvalButton").length > 0)
	{
	
		$(".rgMasterTable>thead>tr").each (function (ind, obj) {
			$(obj).prepend ('<th scope="col" class="OrderDetailsGrid_Column_Thumbnail rgHeader" style="white-space:nowrap;">Approve</th>');
		});
		$(".rgMasterTable>tbody>tr").each (function (ind, obj) {
		  if ($(obj).attr ("id") != null )
	  		$(obj).prepend ('<td class="OrderDetailsGrid_Column_approve"><input type="checkbox" name="approveLink" class="approvedCheckbox" value=approve' + ind + '" /></td>');
		});
		validateApproveClicked ();
	    	$(".approvedCheckbox").change (validateApproveClicked);
	}
    
  })
function validateApproveClicked ()
{
	var isAllChecked = true;
	$(".approvedCheckbox").each (function (ind, obj) {
		if (!$(obj).is(':checked'))
			isAllChecked = false;
	});

	if (isAllChecked)
	{
		// disable approval button.
		$("#ctl00_cphMainContent_btnApprove").attr("disabled", false).unbind('click');
	}
	else
	{
		// disable approval button.
		$("#ctl00_cphMainContent_btnApprove").attr("disabled", "disabled").click(function(e) {
			e.preventDefault();
			//do other stuff when a click happens
		});
	}

}
</script>

For information on how to add JavaScript to your store: How to add JavaScript to a storefront.

⚠️ **GitHub.com Fallback** ⚠️