For restricting entire countries, you can simply set up shipping rules in the Merchant Portal under Settings -> Shipping. The below script allows you to add restrictions on a state-by-state basis. This code will remove them from the dropdown menus on your checkout and the customer account page.

You have to use the code editor to add the custom Javascript below. After you add the below code, you should test both pages to ensure the options have successfully been removed.

In the Code Editor, navigate to components > Checkout > and click Add New. Name the new file `component.js`and click save. Now, add the following code to include/exclude states and countries as desired:

<script>
	{#
	Below is a list of countries and their states. For each country, you may 
    list the states and set it to delete all those states or set it to delete
    all states NOT listed.

	You can list as many countries as you'd like, or just one. In this example,
	I've included the US and Australia.

	For example, if I only serve Texas, I could list 'Texas' and set inclusive as
	true.

	If, however, I want to serve all states except for Texas, I would list 'Texas'
	and inclusive as false.
	#}

	var list = {
		'US': {
			'inclusive': false, {# "false" means only show other states #}
			'states': [
				'American Samoa',
				'Armed Forces Americas',
				'Armed Forces Europe',
				'Armed Forces Pacific',
			],
		},
		'AU': {
			'inclusive': true, {# "true" means only show the listed states. #}
			'states': [
				'Victoria',
				'Queensland',
			],
		},
	}

    {#
	All configuration is done above this line. The code below should not be
	modified unless you're into programming.
	#}
	var remove_states = function() {
		for(country in list) { // remove states from country selector
			var sel = "#country option[value='" + country + "']";
			if(list[country]['inclusive']) {
				console.log("Inclusive remove state data for " + country)
				var states = JSON.parse($(sel).attr("data-states"));
				states = $.grep(states, function(state) {
					return list[country]['states'].indexOf(state["display-state"]) > -1;
				});
				$(sel).attr("data-states", JSON.stringify(states));

				console.log("Inclusive remove state options for " + country)
				if($('select#country option:selected').val() == country || $('select.form-control.state-selector option:selected').val() == country) {
					$('select#state option,select.form-control.state-selector option').each(function(c, op) {
						if (list[country]['states'].indexOf($(op).html().trim()) < 0 ) $(op).remove();
					});
				}
			}
			else {
				console.log("Exclusive remove state data for " + country)
				var states = JSON.parse($(sel).attr("data-states"));
				states = $.grep(states, function(state) {
					return list[country]['states'].indexOf(state["display-state"]) == -1;
				});
				$("#country option[value='" + country + "']").attr("data-states", JSON.stringify(states));

				console.log("Exclusive remove state options for " + country)
				if($('select#country option:selected').val() == country) {
					$('select#state option,select.form-control.state-selector option').each(function(c, op) {
						if (list[country]['states'].indexOf($(op).html().trim()) > -1 ) $(op).remove();
					});
				}
			}
		}
	}

	$( document ).ready( function(){
		remove_states();
	});
</script>

If your theme does not have a `components` folder, this means you're using an old theme. To add the needed Javascript to an old theme, please refer to this doc: Adding Javascript. The Javascript you will use is the same as above, you will just need to add it to your `/html/checkout.html` file instead and include `{% block page_javascript %}` on the first line and `{% endblock %}` on the last line.

This will not restrict your state or country options for checkouts that occur on the Cratejoy Marketplace.