PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.14
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.14
1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 1.3.47 1.3.46 1.3.45 All 177 releases
disco / app / DropDown / AttributeDropDown.php

AttributeDropDown.php in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.14, at app/DropDown/AttributeDropDown.php

107 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Disco\App\DropDown;
4
5 use Disco\App\Disco;
6
7 /**
8 * Class DropDown
9 *
10 * @package CTXFeed
11 * @subpackage app\DropDown
12 * @author Ohidul Islam <wahid0003@gmail.com>
13 * @link https://webappick.com
14 * @license https://opensource.org/licenses/gpl-license.php GNU Public License
15 * @category MyCategory
16 */
17 class AttributeDropDown {
18
19 /**
20 * Get WooCommerce Attributes.
21 *
22 * @return array
23 * @throws \Exception Exception.
24 */
25 public static function get_global_attributes() {
26 $taxonomies = array();
27 $global_attributes = wc_get_attribute_taxonomy_labels();
28
29 if ( count( $global_attributes ) ) {
30 foreach ( $global_attributes as $key => $value ) {
31 $taxonomies[sprintf( 'global_attribute_pa_%s', $key )] = DropDown::prepare_filters(
32 $value,
33 'select',
34 array(
35 'type' => 'select',
36 'option_type' => 'manual',
37 'multiple' => true,
38 'options' => get_terms(
39 array(
40 'taxonomy' => 'pa_' . $key,
41 'fields' => 'id=>name',
42 )
43 ),
44 )
45 );
46 }
47 }
48
49 return array(
50 'optionGroup' => esc_html__( 'Product Attributes', 'disco' ),
51 'options' => $taxonomies,
52 );
53 }
54
55 /**
56 * Get Advance Custom Field (ACF) field list
57 *
58 * @return array ACF Fields
59 * @throws \Exception If setting is not found.
60 */
61 public static function get_acf_attributes(): array {// phpcs:ignore
62 $options = array();
63
64 if ( class_exists( 'ACF' ) && function_exists( 'acf_get_field_groups' ) ) {
65 // DO NOT USE here: $fields = acf_get_fields($group['key']);
66 // because it causes repeater field bugs and returns "trashed" fields
67 $field_groups = acf_get_field_groups();
68
69 foreach ( $field_groups as $group ) {
70 $fields = get_posts(
71 array(
72 'posts_per_page' => -1,
73 'post_type' => 'acf-field',
74 'orderby' => 'menu_order',
75 'order' => 'ASC',
76 'suppress_filters' => false, // DO NOT allow WPML to modify the query
77 'post_parent' => $group['ID'],
78 'post_status' => 'any',
79 'update_post_meta_cache' => false,
80 )
81 );
82
83 foreach ( $fields as $field ) {
84 // old code
85 // $options['acf_fields_' . $field->post_name] = DropDown::prepare_filters( $field->post_title );
86 // new code
87 $options['acf_fields_' . $field->post_excerpt] = DropDown::prepare_filters( $field->post_title );
88 }
89 }
90 }
91
92 if ( empty( $options ) ) {
93 return array(
94 'optionGroup' => '',
95 'options' => array(),
96 );
97 }
98
99 return array(
100 'optionGroup' => esc_html__( 'Advance Custom Fields (ACF)', 'disco' ),
101 'options' => $options,
102 'disabled' => !Disco::is_pro(), // Disable if not pro.
103 );
104 }
105
106 }
107