| 1 |
<?php |
| 2 |
|
| 3 |
namespace Disco\App\DropDown; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class DropDown |
| 7 |
* |
| 8 |
* @package CTXFeed |
| 9 |
* @subpackage app\DropDown |
| 10 |
* @author Ohidul Islam <wahid0003@gmail.com> |
| 11 |
* @link https://webappick.com |
| 12 |
* @license https://opensource.org/licenses/gpl-license.php GNU Public License |
| 13 |
* @category MyCategory |
| 14 |
*/ |
| 15 |
class AttributeDropDown { |
| 16 |
|
| 17 |
/** |
| 18 |
* Get WooCommerce Attributes. |
| 19 |
* |
| 20 |
* @return array |
| 21 |
* @throws \Exception Exception. |
| 22 |
*/ |
| 23 |
public static function get_global_attributes() { |
| 24 |
$taxonomies = array(); |
| 25 |
$global_attributes = wc_get_attribute_taxonomy_labels(); |
| 26 |
|
| 27 |
if ( count( $global_attributes ) ) { |
| 28 |
foreach ( $global_attributes as $key => $value ) { |
| 29 |
$taxonomies[sprintf( 'global_attribute_pa_%s', $key )] = DropDown::prepare_filters( |
| 30 |
$value, |
| 31 |
'select', |
| 32 |
array( |
| 33 |
'type' => 'select', |
| 34 |
'option_type' => 'manual', |
| 35 |
'multiple' => true, |
| 36 |
'options' => get_terms( |
| 37 |
array( |
| 38 |
'taxonomy' => 'pa_' . $key, |
| 39 |
'fields' => 'id=>name', |
| 40 |
) |
| 41 |
), |
| 42 |
) |
| 43 |
); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
return array( |
| 48 |
'optionGroup' => esc_html__( 'Product Attributes', 'disco' ), |
| 49 |
'options' => $taxonomies, |
| 50 |
); |
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
|