Advertisement
palsushobhan

Restrict-Store-List-To-Single-Country.php

Aug 27th, 2021
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. function get_cuba_provinces() {
  2.     return array(
  3.         'CU-01' => 'Pinar del Río',
  4.         'CU-15' => 'Artemisa',
  5.         'CU-03' => 'La Habana',
  6.         'CU-16' => 'Mayabeque',
  7.         'CU-04' => 'Matanzas',
  8.         'CU-06' => 'Cienfuegos',
  9.         'CU-05' => 'Villa Clara',
  10.         'CU-07' => 'Sancti Spíritus',
  11.         'CU-08' => 'Ciego de Ávila',
  12.         'CU-09' => 'Camagüey',
  13.         'CU-10' => 'Las Tunas',
  14.         'CU-12' => 'Granma',
  15.         'CU-11' => 'Holguín',
  16.         'CU-13' => 'Santiago de Cuba',
  17.         'CU-14' => 'Guantánamo',
  18.         'CU-99' => 'Isla de la Juventud',
  19.     );
  20. }
  21.  
  22. add_filter('woocommerce_states', function($states) {
  23.     $states['CU'] = get_cuba_provinces();
  24.     return $states;
  25. });
  26.  
  27. add_action('wcfmmp_store_lists_before_sidebar_location_filter', function(){
  28.     ?>
  29.     <style>
  30.         .wcfmmp-store-lists-location-filter #wcfmmp_store_country + .select2 {
  31.             display: none;
  32.         }
  33.     </style>
  34.     <?php
  35. });
  36.  
  37. add_action('before_wcfm_marketplace_settings', function() {
  38.     ?>
  39.     <style>
  40.         .wcfm_marketplace_store_location_settings p.country,
  41.         .wcfm_marketplace_store_location_settings select#country + .select2 {
  42.             display: none;
  43.         }
  44.     </style>
  45.     <?php
  46. });
  47. add_filter('wcfm_marketplace_settings_fields_address', function($fields, $vendor_id) {
  48.     if(isset($fields['country'])) {
  49.         $fields['country']['value'] = 'CU';
  50.     }
  51.     return $fields;
  52. }, 10, 2);
  53.  
  54. add_filter('wcfmmp_stores_search_data', function($data) {
  55.     $data['wcfmmp_store_country'] = 'CU';
  56.     $_GET['wcfmmp_store_country'] = 'CU';
  57.     return $data;
  58. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement