File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,21 @@ protected static function create_checkout_session_params( $redirect_url = null )
142
142
),
143
143
);
144
144
145
+ $ countries = WC ()->countries ->get_shipping_countries ();
146
+ $ all_countries = WC ()->countries ->get_countries ();
147
+ if ( count ( $ countries ) !== count ( $ all_countries ) ) {
148
+ $ restrictions = array ();
149
+ foreach ( $ countries as $ country => $ name ) {
150
+ $ restrictions [ $ country ] = new stdClass (); // If we use an empty array it'll be treated as an array in JSON
151
+ }
152
+ $ payload ['deliverySpecifications ' ] = array (
153
+ 'addressRestrictions ' => array (
154
+ 'type ' => 'Allowed ' ,
155
+ 'restrictions ' => $ restrictions ,
156
+ ),
157
+ );
158
+ }
159
+
145
160
$ payload = wp_json_encode ( $ payload , JSON_UNESCAPED_SLASHES );
146
161
147
162
return $ payload ;
You can’t perform that action at this time.
0 commit comments