| 1 |
<?php |
| 2 |
|
| 3 |
namespace Disco\App\DropDown; |
| 4 |
|
| 5 |
use WC_Countries; |
| 6 |
use WC_Payment_Gateways; |
| 7 |
|
| 8 |
/** |
| 9 |
* Class DropDown |
| 10 |
* |
| 11 |
* @package Disco |
| 12 |
* @subpackage app\DropDown |
| 13 |
* @author Ohidul Islam <wahid0003@gmail.com> |
| 14 |
* @link https://webappick.com |
| 15 |
* @license https://opensource.org/licenses/gpl-license.php GNU Public License |
| 16 |
* @category Disco |
| 17 |
*/ |
| 18 |
class StoreDropDown { |
| 19 |
|
| 20 |
/** |
| 21 |
* Order Statuses List |
| 22 |
* |
| 23 |
* @return array |
| 24 |
*/ |
| 25 |
public static function order_status() { |
| 26 |
return wc_get_order_statuses(); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Payment Methods List |
| 31 |
* |
| 32 |
* @return array |
| 33 |
*/ |
| 34 |
public static function payment_methods() { |
| 35 |
$wc_gateways = new WC_Payment_Gateways; |
| 36 |
$payment_gateways = $wc_gateways->get_available_payment_gateways(); |
| 37 |
$payment_methods = array(); |
| 38 |
|
| 39 |
// Loop through Woocommerce available payment gateways |
| 40 |
if ( !empty( $payment_gateways ) ) { |
| 41 |
foreach ( $payment_gateways as $gateway_id => $gateway ) { |
| 42 |
$payment_methods[$gateway_id] = $gateway->get_title(); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
return $payment_methods; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* User Roles List |
| 51 |
* |
| 52 |
* @return array |
| 53 |
*/ |
| 54 |
public static function user_roles() { |
| 55 |
global $wp_roles; |
| 56 |
|
| 57 |
return $wp_roles->get_names(); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Countries List |
| 62 |
* |
| 63 |
* @param bool $with_states Whether to include states or not. |
| 64 |
* @return array |
| 65 |
*/ |
| 66 |
public static function countries( $with_states = false ) { |
| 67 |
global $woocommerce; |
| 68 |
|
| 69 |
$counties = ( new WC_Countries )->get_countries(); |
| 70 |
|
| 71 |
if ( $with_states ) { |
| 72 |
foreach ( $counties as $key => $country ) { |
| 73 |
$counties[$key] = $country; |
| 74 |
$states = ( new WC_Countries )->get_states( $key ); |
| 75 |
|
| 76 |
if ( empty( $states ) ) { |
| 77 |
continue; |
| 78 |
} |
| 79 |
|
| 80 |
foreach ( $states as $state_key => $state ) { |
| 81 |
$counties[$key . ':' . $state_key] = $country . ' : ' . $state; |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
return $counties; |
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
|