Skip to content

Commit 834982c

Browse files
authored
Restricting shipping only to continental U.S. by removing certain states from default U.S. list in WooCommerce Add
1 parent 12ab7d3 commit 834982c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- This is a code snippets export file generated by the Code Snippets WordPress plugin. -->
3+
<!-- https://wordpress.org/plugins/code-snippets -->
4+
<!-- To import these snippets a WordPress site follow these steps: -->
5+
<!-- 1. Log in to that site as an administrator. -->
6+
<!-- 2. Install the Code Snippets plugin using the directions provided at the above link. -->
7+
<!-- 3. Go to 'Tools: Import' in the WordPress admin panel. -->
8+
<!-- 4. Click on the "Code Snippets" importer in the list -->
9+
<!-- 5. Upload this file using the form provided on that page. -->
10+
<!-- 6. Code Snippets will then import all of the snippets and associated information contained in this file into your site. -->
11+
<!-- 7. You will then have to visit the 'Snippets: All Snippets' admin menu and activate desired snippets. -->
12+
<!-- generator="Code Snippets/2.9.4" created="2017-11-08 03:48" -->
13+
<snippets>
14+
<snippet scope="0">
15+
<name>Restricting shipping only to continental U.S. by removing certain states from default U.S. list in WooCommerce</name>
16+
<desc></desc>
17+
<tags>woocommerce, continental, us, states, shipping</tags>
18+
<code>/* Restricting shipping only to continental U.S. by removing certain states from default U.S. list */&#13;
19+
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );&#13;
20+
&#13;
21+
function custom_woocommerce_states( $states ) {&#13;
22+
$excluded_states = array('AK', 'AA', 'AE', 'AP', 'AS', 'GU', 'MP', 'PR', 'UM', 'VI', 'HI');&#13;
23+
foreach($excluded_states as $no_state){&#13;
24+
unset($states['US'][$no_state]);&#13;
25+
}&#13;
26+
&#13;
27+
return $states;&#13;
28+
}&#13;
29+
</code>
30+
</snippet>
31+
</snippets>

0 commit comments

Comments
 (0)