/**
 * Wrapper for wp_get_post_terms which supports ordering by parent.
 *
 * NOTE: At this point in time, ordering by menu_order for example isn't possible with this function. wp_get_post_terms has no
 *   filters which we can utilise to modify it's query. https://core.trac.wordpress.org/ticket/19094
 * 
 * @param  int $product_id
 * @param  string $taxonomy
 * @param  array  $args
 * @return array
 */
function wc_get_product_terms($product_id, $taxonomy, $args = array())
{
    if (!taxonomy_exists($taxonomy)) {
        return array();
    }
    if (empty($args['orderby']) && taxonomy_is_product_attribute($taxonomy)) {
        $args['orderby'] = wc_attribute_orderby($taxonomy);
    }
    // Support ordering by parent
    if (!empty($args['orderby']) && $args['orderby'] == 'parent') {
        $fields = isset($args['fields']) ? $args['fields'] : 'all';
        // Unset for wp_get_post_terms
        unset($args['orderby']);
        unset($args['fields']);
        $terms = wp_get_post_terms($product_id, $taxonomy, $args);
        usort($terms, '_wc_get_product_terms_parent_usort_callback');
        switch ($fields) {
            case 'names':
                $terms = wp_list_pluck($terms, 'name');
                break;
            case 'ids':
                $terms = wp_list_pluck($terms, 'term_id');
                break;
            case 'slugs':
                $terms = wp_list_pluck($terms, 'slug');
                break;
        }
    } else {
        $terms = wp_get_post_terms($product_id, $taxonomy, $args);
    }
    return $terms;
}
/**
 * Wrapper for wp_get_post_terms which supports ordering by parent.
 *
 * NOTE: At this point in time, ordering by menu_order for example isn't possible with this function. wp_get_post_terms has no.
 *   filters which we can utilise to modify it's query. https://core.trac.wordpress.org/ticket/19094.
 *
 * @param  int $product_id
 * @param  string $taxonomy
 * @param  array  $args
 * @return array
 */
function wc_get_product_terms($product_id, $taxonomy, $args = array())
{
    if (!taxonomy_exists($taxonomy)) {
        return array();
    }
    if (empty($args['orderby']) && taxonomy_is_product_attribute($taxonomy)) {
        $args['orderby'] = wc_attribute_orderby($taxonomy);
    }
    // Support ordering by parent
    if (!empty($args['orderby']) && in_array($args['orderby'], array('name_num', 'parent'))) {
        $fields = isset($args['fields']) ? $args['fields'] : 'all';
        $orderby = $args['orderby'];
        // Unset for wp_get_post_terms
        unset($args['orderby']);
        unset($args['fields']);
        $terms = wp_get_post_terms($product_id, $taxonomy, $args);
        switch ($orderby) {
            case 'name_num':
                usort($terms, '_wc_get_product_terms_name_num_usort_callback');
                break;
            case 'parent':
                usort($terms, '_wc_get_product_terms_parent_usort_callback');
                break;
        }
        switch ($fields) {
            case 'names':
                $terms = wp_list_pluck($terms, 'name');
                break;
            case 'ids':
                $terms = wp_list_pluck($terms, 'term_id');
                break;
            case 'slugs':
                $terms = wp_list_pluck($terms, 'slug');
                break;
        }
    } elseif (!empty($args['orderby']) && 'menu_order' === $args['orderby']) {
        // wp_get_post_terms doesn't let us use custom sort order
        $args['include'] = wp_get_post_terms($product_id, $taxonomy, array('fields' => 'ids'));
        if (empty($args['include'])) {
            $terms = array();
        } else {
            // This isn't needed for get_terms
            unset($args['orderby']);
            // Set args for get_terms
            $args['menu_order'] = isset($args['order']) ? $args['order'] : 'ASC';
            $args['hide_empty'] = isset($args['hide_empty']) ? $args['hide_empty'] : 0;
            $args['fields'] = isset($args['fields']) ? $args['fields'] : 'names';
            // Ensure slugs is valid for get_terms - slugs isn't supported
            $args['fields'] = 'slugs' === $args['fields'] ? 'id=>slug' : $args['fields'];
            $terms = get_terms($taxonomy, $args);
        }
    } else {
        $terms = wp_get_post_terms($product_id, $taxonomy, $args);
    }
    return apply_filters('woocommerce_get_product_terms', $terms, $product_id, $taxonomy, $args);
}
示例#3
0
        function wcva_load_dropdown_select($name, $options, $selected_value)
        {
            wcva_load_radio_select($name, $options, $selected_value, $hidden = true);
            ?>
 <select id="<?php 
            echo esc_attr(sanitize_title($name));
            ?>
" name="attribute_<?php 
            echo sanitize_title($name);
            ?>
">
        <option value=""><?php 
            echo __('Choose an option', 'woocommerce');
            ?>
&hellip;</option>
        <?php 
            // Get terms if this is a taxonomy - ordered
            if (taxonomy_exists(sanitize_title($name))) {
                $orderby = wc_attribute_orderby(sanitize_title($name));
                switch ($orderby) {
                    case 'name':
                        $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                        break;
                    case 'id':
                        $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
                        break;
                    case 'menu_order':
                        $args = array('menu_order' => 'ASC', 'hide_empty' => false);
                        break;
                }
                $terms = get_terms(sanitize_title($name), $args);
                foreach ($terms as $term) {
                    if (!in_array($term->slug, $options)) {
                        continue;
                    }
                    echo '<option value="' . esc_attr($term->slug) . '" ' . selected(sanitize_title($selected_value), sanitize_title($term->slug), false) . '>' . apply_filters('woocommerce_variation_option_name', $term->name) . '</option>';
                }
            } else {
                foreach ($options as $option) {
                    echo '<option value="' . esc_attr(sanitize_title($option)) . '" ' . selected(sanitize_title($selected_value), sanitize_title($option), false) . '>' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . '</option>';
                }
            }
            ?>
    </select>

<?php 
        }
示例#4
0
function wc_bundles_get_product_terms($product_id, $attribute_name, $args)
{
    if (WC_PB_Core_Compatibility::is_wc_version_gte_2_3()) {
        return wc_get_product_terms($product_id, $attribute_name, $args);
    } else {
        $orderby = wc_attribute_orderby(sanitize_title($attribute_name));
        switch ($orderby) {
            case 'name':
                $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                break;
            case 'id':
                $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false);
                break;
            case 'menu_order':
                $args = array('menu_order' => 'ASC');
                break;
        }
        $terms = get_terms(sanitize_title($attribute_name), $args);
        return $terms;
    }
}
        private function get_variation_items($attribute_name, $options, $grid_item_layout = 'vertical', $columns = 3)
        {
            $orderby = wc_attribute_orderby($attribute_name);
            switch ($orderby) {
                case 'name':
                    $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                    break;
                case 'id':
                    $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
                    break;
                case 'menu_order':
                    $args = array('menu_order' => 'ASC', 'hide_empty' => false);
                    break;
            }
            $terms = get_terms($attribute_name, $args);
            ob_start();
            if (isset($terms->errors)) {
                ?>
				<div class="column"><?php 
                printf(__('No attributes found for this taxonomy. Be sure that they are visible on the product page and you created them via the <a href="%s" target="_blank">Attributes admin page</a>.'), admin_url() . 'edit.php?post_type=product&page=product_attributes');
                ?>
</div>
				<?php 
                return false;
            }
            foreach ($terms as $term) {
                if (!in_array($term->slug, $options)) {
                    continue;
                }
                $fpd_params = '';
                $fpd_thumbnail = '';
                if (class_exists('FPD_Parameters')) {
                    $fpd_params = get_option('mspc_variation_fpd_params_' . $term->term_id, '');
                    $fpd_params_array = array();
                    if (!empty($fpd_params)) {
                        if (strpos($fpd_params, 'enabled') !== false) {
                            //convert string to array
                            parse_str($fpd_params, $fpd_params_array);
                            $fpd_params = FPD_Parameters::convert_parameters_to_string($fpd_params_array);
                        }
                    }
                    $fpd_thumbnail = get_option('mspc_variation_fpd_thumbnail_' . $term->term_id, '');
                }
                $image_html = '';
                $image_url = get_option('mspc_variation_image_' . $term->term_id);
                if ($image_url !== false && !empty($image_url)) {
                    $image_id = $this->get_image_id($image_url);
                    $stage_image = wp_get_attachment_image_src($image_id, empty($fpd_params) ? 'shop_single' : 'full');
                    $image_thumb = empty($fpd_thumbnail) ? $stage_image[0] : $fpd_thumbnail;
                    $image_html = '<img src="' . $image_thumb . '" alt="' . $term->name . '" class="mspc-attribute-image rounded ui image" />';
                }
                $description_html = '';
                if (!empty($term->description)) {
                    $description_html = '<p>' . $term->description . '</p>';
                }
                if ($grid_item_layout == 'vertical') {
                    ?>

				<div class="mspc-variation mspc-vertical column" data-parameters='<?php 
                    echo $fpd_params;
                    ?>
' data-image='<?php 
                    echo $stage_image[0];
                    ?>
'>
					<div class="mspc-clearfix">
						<div class="mspc-radio ui radio checkbox">
							<input type="radio" name="<?php 
                    echo $attribute_name;
                    ?>
" value="<?php 
                    echo esc_attr($term->slug);
                    ?>
">
							<label></label>
						</div>
						<?php 
                    echo $image_html;
                    ?>
						<div class="mspc-text-wrapper">
							<strong class="mspc-attribute-title"><?php 
                    echo $term->name;
                    ?>
</strong>
							<?php 
                    echo $description_html;
                    ?>
						</div>
					</div>
				</div>

				<?php 
                } else {
                    ?>

				<div class="mspc-variation mspc-horizontal column" data-parameters='<?php 
                    echo $fpd_params;
                    ?>
' data-image='<?php 
                    echo $stage_image[0];
                    ?>
'>
					<div class="mspc-clearfix">
						<?php 
                    echo $image_html;
                    ?>
						<div class="mspc-text-wrapper">
							<strong class="mspc-attribute-title"><?php 
                    echo $term->name;
                    ?>
</strong>
							<?php 
                    echo $description_html;
                    ?>
							<div class="mspc-radio ui radio checkbox">
								<input type="radio" name="<?php 
                    echo $attribute_name;
                    ?>
" value="<?php 
                    echo esc_attr($term->slug);
                    ?>
">
								<label></label>
							</div>
						</div>
					</div>
				</div>

				<?php 
                }
            }
            $output = ob_get_contents();
            ob_end_clean();
            return $output;
        }
示例#6
0
 /**
  * @deprecated 2.1.0
  * @param $name
  * @return string
  */
 public function attribute_orderby($name)
 {
     _deprecated_function('Woocommerce->attribute_orderby', '2.1', 'wc_attribute_orderby');
     return wc_attribute_orderby($name);
 }
 /**
  * Output widget.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     global $_chosen_attributes;
     if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
         return;
     }
     $current_term = is_tax() ? get_queried_object()->term_id : '';
     $current_tax = is_tax() ? get_queried_object()->taxonomy : '';
     $taxonomy = isset($instance['attribute']) ? wc_attribute_taxonomy_name($instance['attribute']) : $this->settings['attribute']['std'];
     $query_type = isset($instance['query_type']) ? $instance['query_type'] : $this->settings['query_type']['std'];
     $display_type = isset($instance['display_type']) ? $instance['display_type'] : $this->settings['display_type']['std'];
     if (!taxonomy_exists($taxonomy)) {
         return;
     }
     $get_terms_args = array('hide_empty' => '1');
     $orderby = wc_attribute_orderby($taxonomy);
     switch ($orderby) {
         case 'name':
             $get_terms_args['orderby'] = 'name';
             $get_terms_args['menu_order'] = false;
             break;
         case 'id':
             $get_terms_args['orderby'] = 'id';
             $get_terms_args['order'] = 'ASC';
             $get_terms_args['menu_order'] = false;
             break;
         case 'menu_order':
             $get_terms_args['menu_order'] = 'ASC';
             break;
     }
     $terms = get_terms($taxonomy, $get_terms_args);
     if (0 < count($terms)) {
         ob_start();
         $found = false;
         $this->widget_start($args, $instance);
         // Force found when option is selected - do not force found on taxonomy attributes
         if (!is_tax() && is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) {
             $found = true;
         }
         if ('dropdown' == $display_type) {
             // skip when viewing the taxonomy
             if ($current_tax && $taxonomy == $current_tax) {
                 $found = false;
             } else {
                 $taxonomy_filter = str_replace('pa_', '', $taxonomy);
                 $found = false;
                 echo '<select class="dropdown_layered_nav_' . $taxonomy_filter . '">';
                 echo '<option value="">' . sprintf(__('Any %s', 'woocommerce'), wc_attribute_label($taxonomy)) . '</option>';
                 foreach ($terms as $term) {
                     // If on a term page, skip that term in widget list
                     if ($term->term_id == $current_term) {
                         continue;
                     }
                     // Get count based on current view
                     $_products_in_term = wc_get_term_product_ids($term->term_id, $taxonomy);
                     $option_is_set = isset($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']);
                     // If this is an AND query, only show options with count > 0
                     if ('and' == $query_type) {
                         $count = sizeof(array_intersect($_products_in_term, WC()->query->filtered_product_ids));
                         if (0 < $count) {
                             $found = true;
                         }
                         if (0 == $count && !$option_is_set) {
                             continue;
                         }
                         // If this is an OR query, show all options so search can be expanded
                     } else {
                         $count = sizeof(array_intersect($_products_in_term, WC()->query->unfiltered_product_ids));
                         if (0 < $count) {
                             $found = true;
                         }
                     }
                     echo '<option value="' . esc_attr($term->term_id) . '" ' . selected(isset($_GET['filter_' . $taxonomy_filter]) ? $_GET['filter_' . $taxonomy_filter] : '', $term->term_id, false) . '>' . esc_html($term->name) . '</option>';
                 }
                 echo '</select>';
                 wc_enqueue_js("\n\t\t\t\t\t\tjQuery( '.dropdown_layered_nav_{$taxonomy_filter}' ).change( function() {\n\t\t\t\t\t\t\tvar term_id = parseInt( jQuery( this ).val(), 10 );\n\t\t\t\t\t\t\tlocation.href = '" . preg_replace('%\\/page\\/[0-9]+%', '', str_replace(array('&amp;', '%2C'), array('&', ','), esc_js(add_query_arg('filtering', '1', remove_query_arg(array('page', 'filter_' . $taxonomy_filter)))))) . "&filter_{$taxonomy_filter}=' + ( isNaN( term_id ) ? '' : term_id );\n\t\t\t\t\t\t});\n\t\t\t\t\t");
             }
         } else {
             // List display
             echo '<ul>';
             // flip the filtered_products_ids array so that we can use the more efficient array_intersect_key
             $filtered_product_ids = array_flip(WC()->query->filtered_product_ids);
             foreach ($terms as $term) {
                 // Get count based on current view - uses transients
                 $_products_in_term = wc_get_term_product_ids($term->term_id, $taxonomy);
                 $option_is_set = isset($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']);
                 // skip the term for the current archive
                 if ($current_term == $term->term_id) {
                     continue;
                 }
                 // If this is an AND query, only show options with count > 0
                 if ('and' == $query_type) {
                     // flip the product_in_term array so that we can use array_intersect_key
                     $_products_in_term = array_flip($_products_in_term);
                     // Intersect both arrays now they have been flipped so that we can use their keys
                     $count = sizeof(array_intersect_key($_products_in_term, $filtered_product_ids));
                     if (0 < $count && $current_term !== $term->term_id) {
                         $found = true;
                     }
                     if (0 == $count && !$option_is_set) {
                         continue;
                     }
                     // If this is an OR query, show all options so search can be expanded
                 } else {
                     $count = sizeof(array_intersect($_products_in_term, WC()->query->unfiltered_product_ids));
                     if (0 < $count) {
                         $found = true;
                     }
                 }
                 $arg = 'filter_' . sanitize_title($instance['attribute']);
                 $current_filter = isset($_GET[$arg]) ? explode(',', $_GET[$arg]) : array();
                 if (!is_array($current_filter)) {
                     $current_filter = array();
                 }
                 $current_filter = array_map('esc_attr', $current_filter);
                 if (!in_array($term->term_id, $current_filter)) {
                     $current_filter[] = $term->term_id;
                 }
                 // Base Link decided by current page
                 if (defined('SHOP_IS_ON_FRONT')) {
                     $link = home_url();
                 } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
                     $link = get_post_type_archive_link('product');
                 } else {
                     $link = get_term_link(get_query_var('term'), get_query_var('taxonomy'));
                 }
                 // All current filters
                 if ($_chosen_attributes) {
                     foreach ($_chosen_attributes as $name => $data) {
                         if ($name !== $taxonomy) {
                             // Exclude query arg for current term archive term
                             while (in_array($current_term, $data['terms'])) {
                                 $key = array_search($current_term, $data);
                                 unset($data['terms'][$key]);
                             }
                             // Remove pa_ and sanitize
                             $filter_name = sanitize_title(str_replace('pa_', '', $name));
                             if (!empty($data['terms'])) {
                                 $link = add_query_arg('filter_' . $filter_name, implode(',', $data['terms']), $link);
                             }
                             if ('or' == $data['query_type']) {
                                 $link = add_query_arg('query_type_' . $filter_name, 'or', $link);
                             }
                         }
                     }
                 }
                 // Min/Max
                 if (isset($_GET['min_price'])) {
                     $link = add_query_arg('min_price', $_GET['min_price'], $link);
                 }
                 if (isset($_GET['max_price'])) {
                     $link = add_query_arg('max_price', $_GET['max_price'], $link);
                 }
                 // Orderby
                 if (isset($_GET['orderby'])) {
                     $link = add_query_arg('orderby', $_GET['orderby'], $link);
                 }
                 // Current Filter = this widget
                 if (isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms'])) {
                     $class = 'class="chosen"';
                     // Remove this term is $current_filter has more than 1 term filtered
                     if (sizeof($current_filter) > 1) {
                         $current_filter_without_this = array_diff($current_filter, array($term->term_id));
                         $link = add_query_arg($arg, implode(',', $current_filter_without_this), $link);
                     }
                 } else {
                     $class = '';
                     $link = add_query_arg($arg, implode(',', $current_filter), $link);
                 }
                 // Search Arg
                 if (get_search_query()) {
                     $link = add_query_arg('s', get_search_query(), $link);
                 }
                 // Post Type Arg
                 if (isset($_GET['post_type'])) {
                     $link = add_query_arg('post_type', $_GET['post_type'], $link);
                 }
                 // Query type Arg
                 if ($query_type == 'or' && !(sizeof($current_filter) == 1 && isset($_chosen_attributes[$taxonomy]['terms']) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']))) {
                     $link = add_query_arg('query_type_' . sanitize_title($instance['attribute']), 'or', $link);
                 }
                 echo '<li ' . $class . '>';
                 echo $count > 0 || $option_is_set ? '<a href="' . esc_url(apply_filters('woocommerce_layered_nav_link', $link)) . '">' : '<span>';
                 echo $term->name;
                 echo $count > 0 || $option_is_set ? '</a>' : '</span>';
                 echo ' <span class="count">(' . $count . ')</span></li>';
             }
             echo '</ul>';
         }
         // End display type conditional
         $this->widget_end($args);
         if (!$found) {
             ob_end_clean();
         } else {
             echo ob_get_clean();
         }
     }
 }
 /**
  * @since 1.1.0 of SA_WC_Compatibility
  */
 public static function wc_attribute_orderby($label)
 {
     if (self::is_wc_21()) {
         return wc_attribute_orderby($label);
     } else {
         global $woocommerce;
         return $woocommerce->attribute_orderby($label);
     }
 }
示例#9
0
 public function widget($args, $instance)
 {
     global $_chosen_attributes, $woocommerce;
     if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
         return;
     }
     $current_term = is_tax() ? get_queried_object()->term_id : '';
     $current_tax = is_tax() ? get_queried_object()->taxonomy : '';
     $taxonomy = isset($instance['attribute']) ? wc_attribute_taxonomy_name($instance['attribute']) : $this->settings['attribute']['std'];
     $query_type = isset($instance['query_type']) ? $instance['query_type'] : $this->settings['query_type']['std'];
     $display_type = isset($instance['display_type']) ? $instance['display_type'] : $this->settings['display_type']['std'];
     if (!taxonomy_exists($taxonomy)) {
         return;
     }
     $get_terms_args = array('hide_empty' => '1');
     $orderby = wc_attribute_orderby($taxonomy);
     switch ($orderby) {
         case 'name':
             $get_terms_args['orderby'] = 'name';
             $get_terms_args['menu_order'] = false;
             break;
         case 'id':
             $get_terms_args['orderby'] = 'id';
             $get_terms_args['order'] = 'ASC';
             $get_terms_args['menu_order'] = false;
             break;
         case 'menu_order':
             $get_terms_args['menu_order'] = 'ASC';
             break;
     }
     $terms = get_terms($taxonomy, $get_terms_args);
     $width = 32;
     $height = 32;
     $swatch_type_options = array('color', 'photo');
     //$swatch_type_options = maybe_unserialize( get_post_meta( $product_id, '_swatch_type_options', true ) );
     // 		if ( !$swatch_type_options ) {
     // 			$swatch_type_options = array();
     // 		}
     if (0 < count($terms)) {
         ob_start();
         $found = false;
         echo $args['before_widget'];
         if ($title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base)) {
             echo $args['before_title'] . $title . $args['after_title'];
         }
         // Force found when option is selected - do not force found on taxonomy attributes
         if (!is_tax() && is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) {
             $found = true;
         }
         // List display
         echo '<ul class="swatches-options clearfix">';
         foreach ($terms as $term) {
             $type = get_woocommerce_term_meta($term->term_id, $term->taxonomy . '_swatches_id_type', true);
             if (!in_array($type, $swatch_type_options)) {
                 continue;
             }
             // Get count based on current view - uses transients
             $transient_name = 'wc_ln_count_' . md5(sanitize_key($taxonomy) . sanitize_key($term->term_taxonomy_id));
             if (false === ($_products_in_term = get_transient($transient_name))) {
                 $_products_in_term = get_objects_in_term($term->term_id, $taxonomy);
                 set_transient($transient_name, $_products_in_term);
             }
             $option_is_set = isset($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']);
             // skip the term for the current archive
             if ($current_term == $term->term_id) {
                 continue;
             }
             // If this is an AND query, only show options with count > 0
             if ('and' == $query_type) {
                 $count = sizeof(array_intersect($_products_in_term, WC()->query->filtered_product_ids));
                 if (0 < $count && $current_term !== $term->term_id) {
                     $found = true;
                 }
                 if (0 == $count && !$option_is_set) {
                     continue;
                 }
                 // If this is an OR query, show all options so search can be expanded
             } else {
                 $count = sizeof(array_intersect($_products_in_term, WC()->query->unfiltered_product_ids));
                 if (0 < $count) {
                     $found = true;
                 }
             }
             $arg = 'filter_' . sanitize_title($instance['attribute']);
             $current_filter = isset($_GET[$arg]) ? explode(',', $_GET[$arg]) : array();
             if (!is_array($current_filter)) {
                 $current_filter = array();
             }
             $current_filter = array_map('esc_attr', $current_filter);
             if (!in_array($term->term_id, $current_filter)) {
                 $current_filter[] = $term->term_id;
             }
             // Base Link decided by current page
             if (defined('SHOP_IS_ON_FRONT')) {
                 $link = home_url();
             } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
                 $link = get_post_type_archive_link('product');
             } else {
                 $link = get_term_link(get_query_var('term'), get_query_var('taxonomy'));
             }
             // All current filters
             if ($_chosen_attributes) {
                 foreach ($_chosen_attributes as $name => $data) {
                     if ($name !== $taxonomy) {
                         // Exclude query arg for current term archive term
                         while (in_array($current_term, $data['terms'])) {
                             $key = array_search($current_term, $data);
                             unset($data['terms'][$key]);
                         }
                         // Remove pa_ and sanitize
                         $filter_name = sanitize_title(str_replace('pa_', '', $name));
                         if (!empty($data['terms'])) {
                             $link = add_query_arg('filter_' . $filter_name, implode(',', $data['terms']), $link);
                         }
                         if ('or' == $data['query_type']) {
                             $link = add_query_arg('query_type_' . $filter_name, 'or', $link);
                         }
                     }
                 }
             }
             // Min/Max
             if (isset($_GET['min_price'])) {
                 $link = add_query_arg('min_price', $_GET['min_price'], $link);
             }
             if (isset($_GET['max_price'])) {
                 $link = add_query_arg('max_price', $_GET['max_price'], $link);
             }
             // Orderby
             if (isset($_GET['orderby'])) {
                 $link = add_query_arg('orderby', $_GET['orderby'], $link);
             }
             $filter_title = '';
             // Current Filter = this widget
             if (isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms'])) {
                 $class = 'class="chosen"';
                 $filter_title = __('Remove Filter', 'sitesao');
                 // Remove this term is $current_filter has more than 1 term filtered
                 if (sizeof($current_filter) > 1) {
                     $current_filter_without_this = array_diff($current_filter, array($term->term_id));
                     $link = add_query_arg($arg, implode(',', $current_filter_without_this), $link);
                 }
             } else {
                 $filter_title = $term->name . ' (' . $count . ')';
                 $class = '';
                 $link = add_query_arg($arg, implode(',', $current_filter), $link);
             }
             // Search Arg
             if (get_search_query()) {
                 $link = add_query_arg('s', get_search_query(), $link);
             }
             // Post Type Arg
             if (isset($_GET['post_type'])) {
                 $link = add_query_arg('post_type', $_GET['post_type'], $link);
             }
             // Query type Arg
             if ($query_type == 'or' && !(sizeof($current_filter) == 1 && isset($_chosen_attributes[$taxonomy]['terms']) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']))) {
                 $link = add_query_arg('query_type_' . sanitize_title($instance['attribute']), 'or', $link);
             }
             //$swatch_term = new WC_Product_Swatch_Term( $this->swatch_type_options[$lookup_name], $term->term_id, $taxonomy_lookup_name, $selected_value == $term->slug, $size );
             echo '<li ' . $class . '>';
             echo $count > 0 || $option_is_set ? '<a title="' . $filter_title . '" href="' . esc_url(apply_filters('woocommerce_layered_nav_link', $link)) . '">' : '<span>';
             if ($type == 'color') {
                 $term_color = get_woocommerce_term_meta($term->term_id, $term->taxonomy . '_swatches_id_color', true);
                 if (empty($term_color)) {
                     $term_color = '#ffffff';
                 }
                 echo '<i style="width:32px;height:32px;background-color:' . $term_color . ';"></i>';
             } elseif ($type == 'photo') {
                 $thumbnail_id = get_woocommerce_term_meta($term->term_id, $term->taxonomy . '_swatches_id_photo', true);
                 $thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
                 if ($thumbnail_id) {
                     $imgsrc = wp_get_attachment_image_src($thumbnail_id);
                     if ($imgsrc && is_array($imgsrc)) {
                         $thumbnail_src = current($imgsrc);
                     } else {
                         $thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
                     }
                 } else {
                     $thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
                 }
                 echo '<img src="' . $thumbnail_src . '" alt="' . esc_attr($term->name) . '"  width="32" height="32"/>';
             }
             echo $count > 0 || $option_is_set ? '</a>' : '</span>';
             echo '</li>';
         }
         echo '</ul>';
         echo $args['after_widget'];
         //var_dump($_chosen_attributes);die;
         if (!$found) {
             ob_end_clean();
         } else {
             echo ob_get_clean();
         }
     }
 }
        private function get_variation_items($attribute_name, $options, $color_config, $productId, $default_value)
        {
            $orderby = wc_attribute_orderby($attribute_name);
            $attribute_type = get_variation_attribute_type($attribute_name);
            $base_layer = get_post_meta($productId, "_wpc_base_color_dependency", true);
            $edge_layer = get_post_meta($productId, "_wpc_edge_layer", true);
            $emb_layer = get_post_meta($productId, "_wpc_emb_layer", true);
            $model_layer = get_post_meta($productId, "_wpc_color_dependency", true);
            switch ($orderby) {
                case 'name':
                    $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                    break;
                case 'id':
                    $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
                    break;
                case 'menu_order':
                    $args = array('menu_order' => 'ASC', 'hide_empty' => false);
                    break;
            }
            $terms = get_terms($attribute_name, $args);
            ob_start();
            ?>
            <ul class="attribute_loop">
                <?php 
            if (isset($terms) && !empty($terms)) {
                foreach ($terms as $term) {
                    if (has_term(absint($term->term_id), $attribute_name, $productId)) {
                        ?>
                <li class="wpc-variation wpc_term_<?php 
                        echo $term->slug;
                        ?>
"
                    data-att="<?php 
                        echo $attribute_name;
                        ?>
" data-attvalue="<?php 
                        echo $term->slug;
                        ?>
">
                    <?php 
                        if ($attribute_type == "image") {
                            $attr_image = get_option('_wpc_variation_attr_image_' . $term->term_id);
                            $available_models = get_post_meta($productId, '_wpc_available_models', true);
                            $extraClass = in_array($term->term_id, $available_models) ? "wpc_available_model" : "";
                            $selected_class = $term->slug == $default_value ? "atv" : "";
                            $model_class = $attribute_name == $model_layer ? "wpc_model" : "";
                            ?>
                        <a href="#" data-display="<?php 
                            echo $term->name;
                            ?>
" class="<?php 
                            echo $model_class;
                            ?>
 <?php 
                            echo $selected_class;
                            ?>
 <?php 
                            echo $extraClass;
                            ?>
 wpc_attribute_button_<?php 
                            echo $attribute_name . '_' . $term->slug;
                            ?>
"
                           data-attribute="<?php 
                            echo $attribute_name;
                            ?>
" data-id="<?php 
                            echo $term->term_id;
                            ?>
" data-term="<?php 
                            echo $term->slug;
                            ?>
">
                            <img src="<?php 
                            echo $attr_image;
                            ?>
"
                                 title="<?php 
                            echo $term->name;
                            ?>
"/><span><?php 
                            echo $term->name;
                            ?>
</span>
                        </a>
                        <?php 
                            if ($term->slug == $default_value) {
                                echo '<i class="fa fa-check"></i>';
                                self::$default_model = $term->term_id;
                                self::$colorsMeta = get_post_meta($productId, "_wpc_colors_" . self::$default_model, true);
                                self::$textureMeta = get_post_meta($productId, "_wpc_textures_" . self::$default_model, true);
                            }
                            ?>
                    <?php 
                        } else {
                            $activeClass = $term->slug == $default_value ? "atv" : "";
                            $button_class = null;
                            $no_cords = get_post_meta($productId, "_wpc_no_cords", true);
                            $texture_cords = get_post_meta($productId, "_wpc_multicolor_cords", true);
                            $static_layer = get_post_meta($productId, "_wpc_static_layers", true);
                            if (in_array($term->term_id, $no_cords)) {
                                $button_class = "wpc_no_cords";
                            }
                            if (in_array($term->term_id, $texture_cords)) {
                                $button_class = "wpc_texture_cords";
                            }
                            if (!in_array($term->term_id, $no_cords) && !in_array($term->term_id, $texture_cords) && $emb_layer != $attribute_name) {
                                $button_class = "wpc_color_cords";
                            }
                            if ($emb_layer == $attribute_name) {
                                $button_class = "wpc_emb_buttons";
                                $no_emb = get_post_meta($productId, "_wpc_no_emb", true);
                                if ($no_emb == $term->term_id) {
                                    $button_class = "wpc_no_emb";
                                }
                            }
                            if (in_array($attribute_name, $static_layer)) {
                                $button_class .= " wpc_static_layer";
                            }
                            ?>
                        <?php 
                            if (($button_class == "wpc_color_cords" || $button_class == "wpc_texture_cords") && $activeClass == "atv") {
                                ?>
                            <script type="text/javascript">
                                cords.push({attribute:'<?php 
                                echo $attribute_name;
                                ?>
',term:'<?php 
                                echo $term->slug;
                                ?>
'});
                                actualCords.push({attribute:'<?php 
                                echo $attribute_name;
                                ?>
',term:'<?php 
                                echo $term->slug;
                                ?>
'});
                            </script>
                       <?php 
                            }
                            ?>
                        <button
                            class="wpc_terms <?php 
                            echo $activeClass;
                            ?>
 <?php 
                            echo $button_class;
                            ?>
 wpc_attribute_button_<?php 
                            echo $attribute_name . '_' . $term->slug;
                            ?>
"
                            data-attribute="<?php 
                            echo $attribute_name;
                            ?>
" data-display="<?php 
                            echo $term->name;
                            ?>
"
                            data-term="<?php 
                            echo $term->slug;
                            ?>
" data-id="<?php 
                            echo $term->term_id;
                            ?>
"><?php 
                            echo $term->name;
                            ?>
</button>
                     <?php 
                        }
                        ?>
                    </li>
                <?php 
                    }
                }
            }
            ?>
            </ul>
            <?php 
            //  $static_button_class=is_array($static_layer) && in_array($attribute_name,$static_layer)?"static_button":"";
            //   $colorOfThisAttribute=isset(self::$colorsMeta[$attribute_name][$default_value]['colors'])?self::$colorsMeta[$attribute_name][$default_value]['colors']:array();
            //   $textureOfThisAttribute=isset(self::$textureMeta[$attribute_name][$default_value]['textures'])?self::$textureMeta[$attribute_name][$default_value]['textures']:array();
            ?>
        <div class="c-seclect" id="wpc_color_tab_<?php 
            echo $attribute_name;
            ?>
">

        </div>
            <div class="c-seclect" id="wpc_texture_tab_<?php 
            echo $attribute_name;
            ?>
">

            </div>
            <?php 
            if ($attribute_name == $emb_layer) {
                ?>
                <div class="wpc_hidden" id="embroidery_tab">
                    <a href="#" class="wpc_clear_all"><i class="fa fa-refresh"></i> <?php 
                echo __('Reset', 'wpc');
                ?>
</a>
                    <ul id="wpc_emb_buttons">
                    </ul>
                    <div id="wpc_emb_image" class="wpc_hidden wpc_emb_controls">
                        <form id="wpc_image_upload_form"
                              action="<?php 
                echo admin_url('admin-ajax.php') . '?action=wpc_embroidery_image_upload';
                ?>
"
                              method="post" name="wpc_image_upload_form" enctype="multipart/form-data">
                            <div class="choose_file">
                                <span><?php 
                _e('Choose Image', 'wpc');
                ?>
 </span>
                                <input name="wpc_image_upload" type="file" id="wpc_image_upload"/>
                            </div>
                        </form>
                        <div class="row wpc_hidden wpc_emb_rotate_buttons">
                            <div class="col-sm-12">
                                <a href="#" id="wpc_reset_angle"><i class="fa fa-refresh"></i> <?php 
                echo __('Reset', 'wpc');
                ?>
</a>
                                <?php 
                $settings = get_option("wpc_settings");
                $angle = isset($settings["emb_settings"]["rotation_angle"]) && !empty($settings["emb_settings"]["rotation_angle"]) ? $settings["emb_settings"]["rotation_angle"] : "45";
                ?>
                                <button data-angle=<?php 
                echo $angle;
                ?>
 type="button" class="wpc_emb_rotate_only wpc_buttons btn btn-default"><?php 
                echo __("Rotate", "wpc");
                ?>
</button>
                            </div>
                        </div>
                    </div>
                    <div id="wpc_emb_text" class="wpc_hidden wpc_emb_controls">
                        <div id="wpc_text_add_div">
                            <div id="wpc_text_options" class="wpc_hidden row">
                                <div class="col-sm-4">
                                    <a id="wpc_bold_select" title="<?php 
                echo __('Bold', 'wpc');
                ?>
" class="bcnt" href=""><i class="fa fa-bold"></i></a>
                                    <a id="wpc_italic_select" title="<?php 
                echo __('Italic', 'wpc');
                ?>
" class="bcnt" href=""><i class="fa fa-italic"></i></a>
                                </div>
                                <div class="col-sm-8">
                                    <select id="wpc_font_select">

                                    </select>
                                    <select id="wpc_size_select">

                                    </select>
                                </div>

                            </div>
                            <textarea id="wpc_text_add" cols="10" rows="3"></textarea>
                            <button id="wpc_add_text_btn"><?php 
                echo __("Add Text", "wpc");
                ?>
</button>
                            <div class="row wpc_hidden wpc_emb_rotate_buttons">
                                <div class="col-sm-12">
                                    <a href="#" id="wpc_reset_angle"><i class="fa fa-refresh"></i> <?php 
                echo __('Reset', 'wpc');
                ?>
</a>
                                    <?php 
                $settings = get_option("wpc_settings");
                $angle = isset($settings["emb_settings"]["rotation_angle"]) && !empty($settings["emb_settings"]["rotation_angle"]) ? $settings["emb_settings"]["rotation_angle"] : "45";
                ?>
                                    <button data-angle=<?php 
                echo $angle;
                ?>
 type="button" class="wpc_emb_rotate_only wpc_buttons btn btn-default"><?php 
                echo __("Rotate", "wpc");
                ?>
</button>
                                </div>
                            </div>
                            <div id="wpc_emb_colors" class="wpc_hidden">

                            </div>
                        </div>
                    </div>


                    <div id="wpc_emb_postion_buttons" class="btn-group wpc_hidden" role="group">

                    </div>
                    <div id="wpc_emb_extra_comment" class="row">
                        <div class="col-sm-5"><?php 
                echo __('Additional Comment', 'wpc');
                ?>
</div>
                        <div class="col-sm-7">
                            <textarea class="textar" cols="3" id="wpc_emb_extra_comment_text"></textarea>
                            <button class="wpc_button" id="wpc_emb_extra_comment_button"><?php 
                echo __('Add', 'wpc');
                ?>
</button>
                            <button class="wpc_button" id="wpc_emb_extra_comment_button_remove"><?php 
                echo __('Remove', 'wpc');
                ?>
</button>
                        </div>
                    </div>
                </div>
                <?php 
            }
            ?>
       <?php 
        }
示例#11
0
     $variations_show_name = $variations_options[$att_id]['variations_show_name'];
 }
 $variations_show_reset_button = "";
 if (isset($variations_options[$att_id]) && !empty($variations_options[$att_id]['variations_show_reset_button'])) {
     $variations_show_reset_button = $variations_options[$att_id]['variations_show_reset_button'];
 }
 if (isset($_REQUEST['attribute_' . $att_id])) {
     $selected_value = $_REQUEST['attribute_' . $att_id];
 } elseif (isset($selected_attributes[$att_id])) {
     $selected_value = $selected_attributes[$att_id];
 } else {
     $selected_value = '';
 }
 // Get terms if this is a taxonomy - ordered
 if (taxonomy_exists($att_id)) {
     $orderby = wc_attribute_orderby($att_id);
     switch ($orderby) {
         case 'name':
             $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
             break;
         case 'id':
             $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
             break;
         case 'menu_order':
             $args = array('menu_order' => 'ASC', 'hide_empty' => false);
             break;
     }
     $terms = get_terms($att_id, $args);
     $flipped_haystack = array_flip($options);
     $_index = 0;
     foreach ($terms as $term) {
 /**
  * Get a listing of product attribute terms.
  *
  * @since 2.5.0
  * @param int $attribute_id Attribute ID.
  * @param string|null $fields Fields to limit response to.
  * @return array
  */
 public function get_product_attribute_terms($attribute_id, $fields = null)
 {
     try {
         // Permissions check.
         if (!current_user_can('manage_product_terms')) {
             throw new WC_API_Exception('woocommerce_api_user_cannot_read_product_attribute_terms', __('You do not have permission to read product attribute terms', 'woocommerce'), 401);
         }
         $taxonomy = wc_attribute_taxonomy_name_by_id($attribute_id);
         if (!$taxonomy) {
             throw new WC_API_Exception('woocommerce_api_invalid_product_attribute_id', __('A product attribute with the provided ID could not be found', 'woocommerce'), 404);
         }
         $args = array('hide_empty' => false);
         $orderby = wc_attribute_orderby($taxonomy);
         switch ($orderby) {
             case 'name':
                 $args['orderby'] = 'name';
                 $args['menu_order'] = false;
                 break;
             case 'id':
                 $args['orderby'] = 'id';
                 $args['order'] = 'ASC';
                 $args['menu_order'] = false;
                 break;
             case 'menu_order':
                 $args['menu_order'] = 'ASC';
                 break;
         }
         $terms = get_terms($taxonomy, $args);
         $attribute_terms = array();
         foreach ($terms as $term) {
             $attribute_terms[] = array('id' => $term->term_id, 'slug' => $term->slug, 'name' => $term->name, 'count' => $term->count);
         }
         return array('product_attribute_terms' => apply_filters('woocommerce_api_product_attribute_terms_response', $attribute_terms, $terms, $fields, $this));
     } catch (WC_API_Exception $e) {
         return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
     }
 }
示例#13
0
							<option value=""><?php 
        echo __('Choose an option', 'woocommerce');
        ?>
&hellip;</option>
							<?php 
        if (is_array($options)) {
            if (isset($_REQUEST['attribute_' . sanitize_title($name)])) {
                $selected_value = $_REQUEST['attribute_' . sanitize_title($name)];
            } elseif (isset($selected_attributes[sanitize_title($name)])) {
                $selected_value = $selected_attributes[sanitize_title($name)];
            } else {
                $selected_value = '';
            }
            // Get terms if this is a taxonomy - ordered
            if (taxonomy_exists($name)) {
                $orderby = wc_attribute_orderby($name);
                switch ($orderby) {
                    case 'name':
                        $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                        break;
                    case 'id':
                        $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
                        break;
                    case 'menu_order':
                        $args = array('menu_order' => 'ASC', 'hide_empty' => false);
                        break;
                }
                $terms = get_terms($name, $args);
                foreach ($terms as $term) {
                    if (!in_array($term->slug, $options)) {
                        continue;
 /**
  * Output widget.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
         return;
     }
     $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();
     $taxonomy = isset($instance['attribute']) ? wc_attribute_taxonomy_name($instance['attribute']) : $this->settings['attribute']['std'];
     $query_type = isset($instance['query_type']) ? $instance['query_type'] : $this->settings['query_type']['std'];
     $display_type = isset($instance['display_type']) ? $instance['display_type'] : $this->settings['display_type']['std'];
     if (!taxonomy_exists($taxonomy)) {
         return;
     }
     $get_terms_args = array('hide_empty' => '1');
     $orderby = wc_attribute_orderby($taxonomy);
     switch ($orderby) {
         case 'name':
             $get_terms_args['orderby'] = 'name';
             $get_terms_args['menu_order'] = false;
             break;
         case 'id':
             $get_terms_args['orderby'] = 'id';
             $get_terms_args['order'] = 'ASC';
             $get_terms_args['menu_order'] = false;
             break;
         case 'menu_order':
             $get_terms_args['menu_order'] = 'ASC';
             break;
     }
     $terms = get_terms($taxonomy, $get_terms_args);
     if (0 === sizeof($terms)) {
         return;
     }
     switch ($orderby) {
         case 'name_num':
             usort($terms, '_wc_get_product_terms_name_num_usort_callback');
             break;
         case 'parent':
             usort($terms, '_wc_get_product_terms_parent_usort_callback');
             break;
     }
     ob_start();
     $this->widget_start($args, $instance);
     if ('dropdown' === $display_type) {
         $found = $this->layered_nav_dropdown($terms, $taxonomy, $query_type);
     } else {
         $found = $this->layered_nav_list($terms, $taxonomy, $query_type);
     }
     $this->widget_end($args);
     // Force found when option is selected - do not force found on taxonomy attributes
     if (!is_tax() && is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) {
         $found = true;
     }
     if (!$found) {
         ob_end_clean();
     } else {
         echo ob_get_clean();
     }
 }
示例#15
0
 /**
  * Show widget to user
  *
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     $br_options = apply_filters('berocket_aapf_listener_br_options', get_option('br_filters_options'));
     if (@$br_options['filters_turn_off']) {
         return false;
     }
     global $wp_query, $wp;
     wp_register_style('berocket_aapf_widget-style', plugins_url('../css/widget.css', __FILE__));
     wp_enqueue_style('berocket_aapf_widget-style');
     /* custom scrollbar */
     wp_enqueue_script('berocket_aapf_widget-scroll-script', plugins_url('../js/scrollbar/Scrollbar.concat.min.js', __FILE__), array('jquery'));
     wp_register_style('berocket_aapf_widget-scroll-style', plugins_url('../css/scrollbar/Scrollbar.min.css', __FILE__));
     wp_enqueue_style('berocket_aapf_widget-scroll-style');
     /* main scripts */
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-slider');
     wp_enqueue_script('berocket_aapf_widget-script', plugins_url('../js/widget.min.js', __FILE__), array('jquery'));
     wp_enqueue_script('berocket_aapf_widget-hack-script', plugins_url('../js/mobiles.min.js', __FILE__), array('jquery'));
     $wp_query_product_cat = '-1';
     if (@$wp_query->query['product_cat']) {
         $wp_query_product_cat = explode("/", $wp_query->query['product_cat']);
         $wp_query_product_cat = $wp_query_product_cat[count($wp_query_product_cat) - 1];
     }
     if (!$br_options['products_holder_id']) {
         $br_options['products_holder_id'] = 'ul.products';
     }
     $post_temrs = "[]";
     if (@$_POST['terms']) {
         $post_temrs = @json_encode($_POST['terms']);
     }
     wp_localize_script('berocket_aapf_widget-script', 'the_ajax_script', array('current_page_url' => preg_replace("~paged?/[0-9]+/?~", "", home_url($wp->request)), 'ajaxurl' => admin_url('admin-ajax.php'), 'product_cat' => $wp_query_product_cat, 'products_holder_id' => $br_options['products_holder_id'], 'control_sorting' => $br_options['control_sorting'], 'seo_friendly_urls' => $br_options['seo_friendly_urls'], 'berocket_aapf_widget_product_filters' => $post_temrs, 'user_func' => @$br_options['user_func']));
     extract($args);
     extract($instance);
     if ($widget_type == 'update_button') {
         set_query_var('title', apply_filters('berocket_aapf_widget_title', $title));
         br_get_template_part('widget_update_button');
         return '';
     }
     $product_cat = @json_decode($product_cat);
     if ($product_cat) {
         $hide_widget = true;
         $cur_cat = get_term_by('slug', $wp_query_product_cat, 'product_cat');
         $cur_cat_ancestors = get_ancestors($cur_cat->term_id, 'product_cat');
         $cur_cat_ancestors[] = $cur_cat->term_id;
         if ($product_cat) {
             if ($cat_propagation) {
                 foreach ($product_cat as $cat) {
                     $cat = get_term_by('slug', $cat, 'product_cat');
                     if (@in_array($cat->term_id, $cur_cat_ancestors)) {
                         $hide_widget = false;
                     }
                 }
             } else {
                 foreach ($product_cat as $cat) {
                     if ($cat == $wp_query_product_cat) {
                         $hide_widget = false;
                     }
                 }
             }
         }
         if ($hide_widget) {
             return true;
         }
     }
     $woocommerce_hide_out_of_stock_items = BeRocket_AAPF_Widget::woocommerce_hide_out_of_stock_items();
     $terms = $sort_terms = $price_range = array();
     if ($attribute == 'price') {
         $price_range = BeRocket_AAPF_Widget::get_price_range($wp_query_product_cat, $woocommerce_hide_out_of_stock_items);
         if (!$price_range or count($price_range) < 2) {
             return false;
         }
     } else {
         $sort_array = array();
         $wc_order_by = wc_attribute_orderby($attribute);
         if (@$br_options['show_all_values']) {
             $terms = BeRocket_AAPF_Widget::get_attribute_values($attribute);
         } else {
             $terms = BeRocket_AAPF_Widget::get_attribute_values($attribute, 'id', true);
         }
         if (@count($terms) < 2) {
             return false;
         }
         if ($wc_order_by == 'menu_order') {
             foreach ($terms as $term) {
                 $sort_array[] = get_woocommerce_term_meta($term->term_id, 'order_' . $attribute);
             }
             array_multisort($sort_array, $terms);
         } elseif ($wc_order_by == 'name' or $wc_order_by == 'name_num') {
             foreach ($terms as $term) {
                 $sort_array[] = $term->name;
             }
             $sort_as = SORT_STRING;
             if ($wc_order_by == 'name_num') {
                 $sort_as = SORT_NUMERIC;
             }
             array_multisort($sort_array, $terms, SORT_ASC, $sort_as);
         }
         set_query_var('terms', apply_filters('berocket_aapf_widget_terms', $terms));
     }
     $style = $class = '';
     if (@$height and $height != 'auto') {
         $style = "style='height: {$height}px; overflow: hidden;'";
         $class = "berocket_aapf_widget_height_control";
     }
     if (!$scroll_theme) {
         $scroll_theme = 'dark';
     }
     set_query_var('operator', $operator);
     set_query_var('title', apply_filters('berocket_aapf_widget_title', $title));
     set_query_var('class', apply_filters('berocket_aapf_widget_class', $class));
     set_query_var('css_class', apply_filters('berocket_aapf_widget_css_class', $css_class));
     set_query_var('style', apply_filters('berocket_aapf_widget_style', $style));
     set_query_var('scroll_theme', $scroll_theme);
     set_query_var('x', time());
     // widget title and start tag ( <ul> ) can be found in templates/widget_start.php
     br_get_template_part('widget_start');
     if ($type == 'slider') {
         $min = $max = false;
         $main_class = 'slider';
         $slider_class = 'berocket_filter_slider';
         if ($attribute == 'price') {
             if ($price_range) {
                 foreach ($price_range as $price) {
                     if ($min === false or $min > (int) $price) {
                         $min = $price;
                     }
                     if ($max === false or $max < (int) $price) {
                         $max = $price;
                     }
                 }
             }
             $id = rand(0, time());
             $slider_class .= ' berocket_filter_price_slider';
             $main_class .= ' price';
             $min = number_format(floor($min), 2, '.', '');
             $max = number_format(ceil($max), 2, '.', '');
         } else {
             if ($terms) {
                 foreach ($terms as $term) {
                     if ($min === false or $min > (int) $term->slug) {
                         $min = $term->slug;
                     }
                     if ($max === false or $max < (int) $term->slug) {
                         $max = $term->slug;
                     }
                 }
             }
             $id = $term->taxonomy;
         }
         $slider_value1 = $min;
         $slider_value2 = $max;
         if ($attribute == 'price' and @$_POST['price']) {
             $slider_value1 = $_POST['price'][0];
             $slider_value2 = $_POST['price'][1];
         }
         if ($attribute != 'price' and @$_POST['limits']) {
             foreach ($_POST['limits'] as $p_limit) {
                 if ($p_limit[0] == $attribute) {
                     $slider_value1 = $p_limit[1];
                     $slider_value2 = $p_limit[2];
                 }
             }
         }
         set_query_var('slider_value1', $slider_value1);
         set_query_var('slider_value2', $slider_value2);
         set_query_var('filter_slider_id', $id);
         set_query_var('main_class', $main_class);
         set_query_var('slider_class', $slider_class);
         set_query_var('min', $min);
         set_query_var('max', $max);
     }
     br_get_template_part($type);
     br_get_template_part('widget_end');
 }
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 public function widget($args, $instance)
 {
     global $_chosen_attributes;
     extract($args);
     if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
         return;
     }
     $current_term = is_tax() ? get_queried_object()->term_id : '';
     $current_tax = is_tax() ? get_queried_object()->taxonomy : '';
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     // NM
     //$taxonomy 		= isset( $instance['attribute'] ) ? wc_attribute_taxonomy_name($instance['attribute']) : '';
     $taxonomy = wc_attribute_taxonomy_name('color');
     // /NM
     $query_type = isset($instance['query_type']) ? $instance['query_type'] : 'and';
     // NM
     //$display_type 	= isset( $instance['display_type'] ) ? $instance['display_type'] : 'list';
     // /NM
     if (!taxonomy_exists($taxonomy)) {
         return;
     }
     $get_terms_args = array('hide_empty' => '1');
     $orderby = wc_attribute_orderby($taxonomy);
     switch ($orderby) {
         case 'name':
             $get_terms_args['orderby'] = 'name';
             $get_terms_args['menu_order'] = false;
             break;
         case 'id':
             $get_terms_args['orderby'] = 'id';
             $get_terms_args['order'] = 'ASC';
             $get_terms_args['menu_order'] = false;
             break;
         case 'menu_order':
             $get_terms_args['menu_order'] = 'ASC';
             break;
     }
     $terms = get_terms($taxonomy, $get_terms_args);
     if (count($terms) > 0) {
         ob_start();
         $found = false;
         echo $before_widget . $before_title . $title . $after_title;
         // Force found when option is selected - do not force found on taxonomy attributes
         if (!is_tax() && is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) {
             $found = true;
         }
         // NM: Removed "display_type" if statement
         // List display
         // NM
         //echo "<ul>";
         $columns_class = 'no-col';
         if (isset($instance['columns']) && $instance['columns'] !== '1') {
             $columns_class = $instance['columns'] === '2' ? 'small-block-grid-2 has-col' : 'small-block-grid-2 medium-block-grid-1 has-col';
         }
         echo '<ul class="' . $columns_class . '">';
         // /NM
         foreach ($terms as $term) {
             // Get count based on current view - uses transients
             $transient_name = 'wc_ln_count_' . md5(sanitize_key($taxonomy) . sanitize_key($term->term_taxonomy_id));
             if (false === ($_products_in_term = get_transient($transient_name))) {
                 $_products_in_term = get_objects_in_term($term->term_id, $taxonomy);
                 set_transient($transient_name, $_products_in_term);
             }
             $option_is_set = isset($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']);
             // skip the term for the current archive
             if ($current_term == $term->term_id) {
                 continue;
             }
             // If this is an AND query, only show options with count > 0
             if ($query_type == 'and') {
                 $count = sizeof(array_intersect($_products_in_term, WC()->query->filtered_product_ids));
                 if ($count > 0 && $current_term !== $term->term_id) {
                     $found = true;
                 }
                 if ($count == 0 && !$option_is_set) {
                     continue;
                 }
                 // If this is an OR query, show all options so search can be expanded
             } else {
                 $count = sizeof(array_intersect($_products_in_term, WC()->query->unfiltered_product_ids));
                 if ($count > 0) {
                     $found = true;
                 }
             }
             $arg = 'filter_' . sanitize_title($instance['attribute']);
             $current_filter = isset($_GET[$arg]) ? explode(',', $_GET[$arg]) : array();
             if (!is_array($current_filter)) {
                 $current_filter = array();
             }
             $current_filter = array_map('esc_attr', $current_filter);
             if (!in_array($term->term_id, $current_filter)) {
                 $current_filter[] = $term->term_id;
             }
             // Base Link decided by current page
             if (defined('SHOP_IS_ON_FRONT')) {
                 $link = home_url();
             } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
                 $link = get_post_type_archive_link('product');
             } else {
                 $link = get_term_link(get_query_var('term'), get_query_var('taxonomy'));
             }
             // All current filters
             if ($_chosen_attributes) {
                 foreach ($_chosen_attributes as $name => $data) {
                     if ($name !== $taxonomy) {
                         // Exclude query arg for current term archive term
                         while (in_array($current_term, $data['terms'])) {
                             $key = array_search($current_term, $data);
                             unset($data['terms'][$key]);
                         }
                         // Remove pa_ and sanitize
                         $filter_name = sanitize_title(str_replace('pa_', '', $name));
                         if (!empty($data['terms'])) {
                             $link = add_query_arg('filter_' . $filter_name, implode(',', $data['terms']), $link);
                         }
                         if ($data['query_type'] == 'or') {
                             $link = add_query_arg('query_type_' . $filter_name, 'or', $link);
                         }
                     }
                 }
             }
             // Min/Max
             if (isset($_GET['min_price'])) {
                 $link = add_query_arg('min_price', $_GET['min_price'], $link);
             }
             if (isset($_GET['max_price'])) {
                 $link = add_query_arg('max_price', $_GET['max_price'], $link);
             }
             // Orderby
             if (isset($_GET['orderby'])) {
                 $link = add_query_arg('orderby', $_GET['orderby'], $link);
             }
             // Current Filter = this widget
             if (isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms'])) {
                 $class = 'class="chosen"';
                 // Remove this term is $current_filter has more than 1 term filtered
                 if (sizeof($current_filter) > 1) {
                     $current_filter_without_this = array_diff($current_filter, array($term->term_id));
                     $link = add_query_arg($arg, implode(',', $current_filter_without_this), $link);
                 }
             } else {
                 $class = '';
                 $link = add_query_arg($arg, implode(',', $current_filter), $link);
             }
             // Search Arg
             if (get_search_query()) {
                 $link = add_query_arg('s', get_search_query(), $link);
             }
             // Post Type Arg
             if (isset($_GET['post_type'])) {
                 $link = add_query_arg('post_type', $_GET['post_type'], $link);
             }
             // Query type Arg
             if ($query_type == 'or' && !(sizeof($current_filter) == 1 && isset($_chosen_attributes[$taxonomy]['terms']) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']))) {
                 $link = add_query_arg('query_type_' . sanitize_title($instance['attribute']), 'or', $link);
             }
             echo '<li ' . $class . '>';
             echo $count > 0 || $option_is_set ? '<a href="' . esc_url(apply_filters('woocommerce_layered_nav_link', $link)) . '">' : '<span>';
             // NM
             $color_val = isset($instance['colors'][$term->term_id]) ? $instance['colors'][$term->term_id] : '#e0e0e0';
             echo '<i style="background-color:' . esc_attr($color_val) . ';" class="nm-filter-color nm-filter-color-' . esc_attr(strtolower($term->name)) . '"></i>';
             // /NM
             echo esc_attr($term->name);
             echo $count > 0 || $option_is_set ? '</a>' : '</span>';
             echo ' <small class="count">' . $count . '</small></li>';
         }
         echo "</ul>";
         echo $after_widget;
         if (!$found) {
             ob_end_clean();
         } else {
             echo ob_get_clean();
         }
     }
 }
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 public function widget($args, $instance)
 {
     global $_chosen_brands;
     extract($args);
     //if ( ! is_post_type_archive( 'product' ) && ! is_tax( get_object_taxonomies( 'product' ) ) )
     //return;
     $current_term = is_tax() ? get_queried_object()->term_id : '';
     $current_tax = is_tax() ? get_queried_object()->taxonomy : '';
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $taxonomy = 'product_brand';
     $query_type = isset($instance['query_type']) ? $instance['query_type'] : 'and';
     $display_type = isset($instance['display_type']) ? $instance['display_type'] : 'list';
     //echo '<pre>' . print_r( $taxonomy )
     if (!taxonomy_exists($taxonomy)) {
         return;
     }
     $get_terms_args = array('hide_empty' => '1');
     $orderby = wc_attribute_orderby($taxonomy);
     switch ($orderby) {
         case 'name':
             $get_terms_args['orderby'] = 'name';
             $get_terms_args['menu_order'] = false;
             break;
         case 'id':
             $get_terms_args['orderby'] = 'id';
             $get_terms_args['order'] = 'ASC';
             $get_terms_args['menu_order'] = false;
             break;
         case 'menu_order':
             $get_terms_args['menu_order'] = 'ASC';
             break;
     }
     $terms = get_terms($taxonomy, $get_terms_args);
     if (count($terms) > 0) {
         ob_start();
         $found = false;
         echo $before_widget . $before_title . $title . $after_title;
         // Force found when option is selected - do not force found on taxonomy attributes
         if (!is_tax() && is_array($_chosen_brands) && array_key_exists($taxonomy, $_chosen_brands)) {
             $found = true;
         }
         if ($display_type == 'dropdown') {
             // skip when viewing the taxonomy
             if ($current_tax && $taxonomy == $current_tax) {
                 $found = false;
             } else {
                 $taxonomy_filter = str_replace('pa_', '', $taxonomy);
                 $found = false;
                 echo '<select class="dropdown_layered_nav_' . $taxonomy_filter . '">';
                 echo '<option value="">' . sprintf(__('Any %s', 'media_center'), wc_attribute_label($taxonomy)) . '</option>';
                 foreach ($terms as $term) {
                     // If on a term page, skip that term in widget list
                     if ($term->term_id == $current_term) {
                         continue;
                     }
                     // Get count based on current view - uses transients
                     $transient_name = 'wc_ln_count_' . md5(sanitize_key($taxonomy) . sanitize_key($term->term_taxonomy_id));
                     if (false === ($_products_in_term = get_transient($transient_name))) {
                         $_products_in_term = get_objects_in_term($term->term_id, $taxonomy);
                         set_transient($transient_name, $_products_in_term, YEAR_IN_SECONDS);
                     }
                     $option_is_set = isset($_chosen_brands[$taxonomy]) && in_array($term->term_id, $_chosen_brands[$taxonomy]['terms']);
                     // If this is an AND query, only show options with count > 0
                     if ($query_type == 'and') {
                         $count = sizeof(array_intersect($_products_in_term, WC()->query->filtered_product_ids));
                         if ($count > 0) {
                             $found = true;
                         }
                         if ($count == 0 && !$option_is_set) {
                             continue;
                         }
                         // If this is an OR query, show all options so search can be expanded
                     } else {
                         $count = sizeof(array_intersect($_products_in_term, WC()->query->unfiltered_product_ids));
                         if ($count > 0) {
                             $found = true;
                         }
                     }
                     echo '<option value="' . esc_attr($term->term_id) . '" ' . selected(isset($_GET['filter_' . $taxonomy_filter]) ? $_GET['filter_' . $taxonomy_filter] : '', $term->term_id, false) . '>' . $term->name . '</option>';
                 }
                 echo '</select>';
                 wc_enqueue_js("\n\n\t\t\t\t\t\tjQuery('.dropdown_layered_nav_{$taxonomy_filter}').change(function(){\n\n\t\t\t\t\t\t\tlocation.href = '" . esc_url_raw(preg_replace('%\\/page/[0-9]+%', '', add_query_arg('filtering', '1', remove_query_arg(array('page', 'filter_' . $taxonomy_filter))))) . "&filter_{$taxonomy_filter}=' + jQuery(this).val();\n\n\t\t\t\t\t\t});\n\n\t\t\t\t\t");
             }
         } else {
             // List display
             echo "<ul>";
             foreach ($terms as $term) {
                 // Get count based on current view - uses transients
                 $transient_name = 'wc_ln_count_' . md5(sanitize_key($taxonomy) . sanitize_key($term->term_taxonomy_id));
                 if (false === ($_products_in_term = get_transient($transient_name))) {
                     $_products_in_term = get_objects_in_term($term->term_id, $taxonomy);
                     set_transient($transient_name, $_products_in_term);
                 }
                 $option_is_set = isset($_chosen_brands[$taxonomy]) && in_array($term->term_id, $_chosen_brands[$taxonomy]['terms']);
                 // skip the term for the current archive
                 if ($current_term == $term->term_id) {
                     continue;
                 }
                 // If this is an AND query, only show options with count > 0
                 if ($query_type == 'and') {
                     $count = sizeof(array_intersect($_products_in_term, WC()->query->filtered_product_ids));
                     if ($count > 0 && $current_term !== $term->term_id) {
                         $found = true;
                     }
                     if ($count == 0 && !$option_is_set) {
                         continue;
                     }
                     // If this is an OR query, show all options so search can be expanded
                 } else {
                     $count = sizeof(array_intersect($_products_in_term, WC()->query->unfiltered_product_ids));
                     if ($count > 0) {
                         $found = true;
                     }
                 }
                 $arg = 'filter_' . sanitize_title('product_brand');
                 $current_filter = isset($_GET[$arg]) ? explode(',', $_GET[$arg]) : array();
                 if (!is_array($current_filter)) {
                     $current_filter = array();
                 }
                 $current_filter = array_map('esc_attr', $current_filter);
                 if (!in_array($term->term_id, $current_filter)) {
                     $current_filter[] = $term->term_id;
                 }
                 // Base Link decided by current page
                 if (defined('SHOP_IS_ON_FRONT')) {
                     $link = home_url();
                 } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
                     $link = get_post_type_archive_link('product');
                 } else {
                     $link = get_term_link(get_query_var('term'), get_query_var('taxonomy'));
                 }
                 // All current filters
                 if ($_chosen_brands) {
                     foreach ($_chosen_brands as $name => $data) {
                         if ($name !== $taxonomy) {
                             // Exclude query arg for current term archive term
                             while (in_array($current_term, $data['terms'])) {
                                 $key = array_search($current_term, $data);
                                 unset($data['terms'][$key]);
                             }
                             // Remove pa_ and sanitize
                             $filter_name = sanitize_title(str_replace('pa_', '', $name));
                             if (!empty($data['terms'])) {
                                 $link = add_query_arg('filter_' . $filter_name, implode(',', $data['terms']), $link);
                             }
                             if ($data['query_type'] == 'or') {
                                 $link = add_query_arg('query_type_' . $filter_name, 'or', $link);
                             }
                         }
                     }
                 }
                 // Min/Max
                 if (isset($_GET['min_price'])) {
                     $link = add_query_arg('min_price', $_GET['min_price'], $link);
                 }
                 if (isset($_GET['max_price'])) {
                     $link = add_query_arg('max_price', $_GET['max_price'], $link);
                 }
                 // Orderby
                 if (isset($_GET['orderby'])) {
                     $link = add_query_arg('orderby', $_GET['orderby'], $link);
                 }
                 // Current Filter = this widget
                 if (isset($_chosen_brands[$taxonomy]) && is_array($_chosen_brands[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_brands[$taxonomy]['terms'])) {
                     $class = 'class="chosen"';
                     // Remove this term is $current_filter has more than 1 term filtered
                     if (sizeof($current_filter) > 1) {
                         $current_filter_without_this = array_diff($current_filter, array($term->term_id));
                         $link = add_query_arg($arg, implode(',', $current_filter_without_this), $link);
                     }
                 } else {
                     $class = '';
                     $link = add_query_arg($arg, implode(',', $current_filter), $link);
                 }
                 // Search Arg
                 if (get_search_query()) {
                     $link = add_query_arg('s', get_search_query(), $link);
                 }
                 // Post Type Arg
                 if (isset($_GET['post_type'])) {
                     $link = add_query_arg('post_type', $_GET['post_type'], $link);
                 }
                 // Query type Arg
                 if ($query_type == 'or' && !(sizeof($current_filter) == 1 && isset($_chosen_brands[$taxonomy]['terms']) && is_array($_chosen_brands[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_brands[$taxonomy]['terms']))) {
                     $link = add_query_arg('query_type_' . sanitize_title('product_brand'), 'or', $link);
                 }
                 echo '<li ' . $class . '>';
                 echo $count > 0 || $option_is_set ? '<a href="' . esc_url(apply_filters('woocommerce_layered_nav_link', $link)) . '">' : '<span>';
                 echo $term->name;
                 echo $count > 0 || $option_is_set ? '</a>' : '</span>';
                 echo ' <small class="count">' . $count . '</small></li>';
             }
             echo "</ul>";
         }
         // End display type conditional
         echo $after_widget;
         if (!$found) {
             ob_end_clean();
         } else {
             echo ob_get_clean();
         }
     }
 }
 /**
  * Generates element sub-options for variations.
  *
  * @since 3.0.0
  * @access private
  */
 public function builder_sub_variations_options($meta = array(), $product_id = 0)
 {
     $o = array();
     $name = "tm_builder_variation_options";
     $class = " withupload";
     $upload = '&nbsp;<span data-tm-tooltip-html="' . esc_attr(__("Choose the image to use in place of the radio button.", TM_EPO_TRANSLATION)) . '" class="tm_upload_button cp_button tm-tooltip"><i class="tcfa tcfa-upload"></i></span><span data-tm-tooltip-html="' . esc_attr(__("Remove the image.", TM_EPO_TRANSLATION)) . '" class="tm-upload-button-remove cp-button tm-tooltip"><i class="tcfa tcfa-times"></i></span>';
     $uploadp = '&nbsp;<span data-tm-tooltip-html="' . esc_attr(__("Choose the image to replace the product image with.", TM_EPO_TRANSLATION)) . '" class="tm_upload_button tm_upload_buttonp cp_button tm-tooltip"><i class="tcfa tcfa-upload"></i></span><span data-tm-tooltip-html="' . esc_attr(__("Remove the image.", TM_EPO_TRANSLATION)) . '" class="tm-upload-button-remove cp-button tm-tooltip"><i class="tcfa tcfa-times"></i></span>';
     $settings_attribute = array(array("id" => "variations_display_as", "default" => "select", "type" => "select", "tags" => array("class" => "variations-display-as", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]"), "options" => array(array("text" => __("Select boxes", TM_EPO_TRANSLATION), "value" => "select"), array("text" => __("Radio buttons", TM_EPO_TRANSLATION), "value" => "radio"), array("text" => __("Image swatches", TM_EPO_TRANSLATION), "value" => "image"), array("text" => __("Color swatches", TM_EPO_TRANSLATION), "value" => "color")), "label" => __("Display as", TM_EPO_TRANSLATION), "desc" => __("Select the display type of this attribute.", TM_EPO_TRANSLATION)), array("id" => "variations_label", "default" => "", "type" => "text", "tags" => array("class" => "t", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]", "value" => ""), "label" => __('Attribute Label', TM_EPO_TRANSLATION), "desc" => __('Leave blank to use the original attribute label.', TM_EPO_TRANSLATION)), array("id" => "variations_show_reset_button", "message0x0_class" => "tma-hide-for-select-box", "default" => "", "type" => "select", "tags" => array("id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]"), "options" => array(array("text" => __("Disable", TM_EPO_TRANSLATION), "value" => ""), array("text" => __("Enable", TM_EPO_TRANSLATION), "value" => "yes")), "label" => __('Show reset button', TM_EPO_TRANSLATION), "desc" => __('Enables the display of a reset button for this attribute.', TM_EPO_TRANSLATION)), array("id" => "variations_class", "default" => "", "type" => "text", "tags" => array("class" => "t", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]", "value" => ""), "label" => __('Attribute element class name', TM_EPO_TRANSLATION), "desc" => __('Enter an extra class name to add to this attribute element', TM_EPO_TRANSLATION)), array("id" => "variations_items_per_row", "message0x0_class" => "tma-hide-for-select-box", "default" => "", "type" => "text", "tags" => array("class" => "n", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]", "value" => ""), "label" => __('Items per row', TM_EPO_TRANSLATION), "desc" => __('Use this field to make a grid display. Enter how many items per row for the grid or leave blank for normal display.', TM_EPO_TRANSLATION)), array("id" => "variations_item_width", "message0x0_class" => "tma-show-for-swatches tma-hide-for-select-box", "default" => "", "type" => "text", "tags" => array("class" => "n", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]", "value" => ""), "label" => __('Width', TM_EPO_TRANSLATION), "desc" => __('Enter the width of the displayed item or leave blank for auto width.', TM_EPO_TRANSLATION)), array("id" => "variations_item_height", "message0x0_class" => "tma-show-for-swatches tma-hide-for-select-box", "default" => "", "type" => "text", "tags" => array("class" => "n", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]", "value" => ""), "label" => __('Height', TM_EPO_TRANSLATION), "desc" => __('Enter the height of the displayed item or leave blank for auto height.', TM_EPO_TRANSLATION)), array("id" => "variations_changes_product_image", "default" => "", "type" => "select", "tags" => array("class" => "tm-changes-product-image", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]"), "options" => array(array("text" => __('No', TM_EPO_TRANSLATION), "value" => ""), array("text" => __('Use the image replacements', TM_EPO_TRANSLATION), "value" => "images"), array("text" => __('Use custom image', TM_EPO_TRANSLATION), "value" => "custom")), "label" => __('Changes product image', TM_EPO_TRANSLATION), "desc" => __('Choose whether to change the product image.', TM_EPO_TRANSLATION)), array("id" => "variations_show_name", "message0x0_class" => "tma-show-for-swatches", "default" => "hide", "type" => "select", "tags" => array("class" => "variations-show-name", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][%id%]"), "options" => array(array("text" => __('Hide', TM_EPO_TRANSLATION), "value" => "hide"), array("text" => __('Show bottom', TM_EPO_TRANSLATION), "value" => "bottom"), array("text" => __('Show inside', TM_EPO_TRANSLATION), "value" => "inside"), array("text" => __('Tooltip', TM_EPO_TRANSLATION), "value" => "tooltip")), "label" => __('Show attribute name', TM_EPO_TRANSLATION), "desc" => __('Choose whether to show or hide the attribute name.', TM_EPO_TRANSLATION)));
     $settings_term = array(array("id" => "variations_color", "message0x0_class" => "tma-term-color", "default" => "", "type" => "text", "tags" => array("class" => "tm-color-picker", "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][[%id%]][%term_id%]", "value" => ""), "label" => __('Color', TM_EPO_TRANSLATION), "desc" => __('Select the color to use.', TM_EPO_TRANSLATION)), array("id" => "variations_image", "message0x0_class" => "tma-term-image", "default" => "", "type" => "hidden", "tags" => array("class" => "n tm_option_image" . $class, "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][[%id%]][%term_id%]"), "label" => __('Image replacement', TM_EPO_TRANSLATION), "desc" => __('Select an image for this term.', TM_EPO_TRANSLATION), "extra" => $upload . '<span class="tm_upload_image"><img class="tm_upload_image_img" alt="" src="%value%" /></span>'), array("id" => "variations_imagep", "message0x0_class" => "tma-term-custom-image", "default" => "", "type" => "hidden", "tags" => array("class" => "n tm_option_image tm_option_imagep" . $class, "id" => "builder_%id%", "name" => "tm_meta[tmfbuilder][variations_options][%attribute_id%][[%id%]][%term_id%]"), "label" => __('Product Image replacement', TM_EPO_TRANSLATION), "desc" => __('Select the image to replace the product image with.', TM_EPO_TRANSLATION), "extra" => $uploadp . '<span class="tm_upload_image tm_upload_imagep"><img class="tm_upload_image_img" alt="" src="%value%" /></span>'));
     $out = "";
     $attributes = array();
     $d_counter = 0;
     if (!empty($product_id)) {
         $product = wc_get_product($product_id);
         if ($product && is_object($product) && method_exists($product, 'get_variation_attributes')) {
             $attributes = $product->get_variation_attributes();
         }
     }
     if (empty($attributes)) {
         return '<div class="errortitle"><p><i class="tcfa tcfa-exclamation-triangle"></i> ' . __('No saved variations found.', TM_EPO_TRANSLATION) . '</p></div>';
     }
     foreach ($attributes as $name => $options) {
         $out .= '<div class="tma-handle-wrap tm-attribute">' . '<div class="tma-handle"><div class="tma-attribute_label">' . wc_attribute_label($name) . '</div><div class="tmicon tcfa fold tcfa-caret-up"></div></div>' . '<div class="tma-handle-wrapper tm-hidden">' . '<div class="tma-attribute w100">';
         $attribute_id = sanitize_title($name);
         foreach ($settings_attribute as $setting) {
             $setting["tags"]["id"] = str_replace("%id%", $setting["id"], $setting["tags"]["id"]);
             $setting["tags"]["name"] = str_replace("%id%", $setting["id"], $setting["tags"]["name"]);
             $setting["tags"]["name"] = str_replace("%attribute_id%", $attribute_id, $setting["tags"]["name"]);
             if (!empty($meta) && isset($meta[$attribute_id]) && isset($meta[$attribute_id][$setting["id"]])) {
                 $setting["default"] = $meta[$attribute_id][$setting["id"]];
             }
             $out .= TM_EPO_HTML()->tm_make_field($setting, 0);
         }
         if (is_array($options)) {
             if (taxonomy_exists(sanitize_title($name))) {
                 $orderby = wc_attribute_orderby(sanitize_title($name));
                 $args = array();
                 switch ($orderby) {
                     case 'name':
                         $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                         break;
                     case 'id':
                         $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
                         break;
                     case 'menu_order':
                         $args = array('menu_order' => 'ASC', 'hide_empty' => false);
                         break;
                 }
                 if (!empty($args)) {
                     $terms = get_terms(sanitize_title($name), $args);
                     foreach ($terms as $term) {
                         // Get only selected terms
                         if (!($has_term = has_term((int) $term->term_id, sanitize_title($name), $product_id))) {
                             continue;
                         }
                         $term_id = $term->slug;
                         $out .= '<div class="tma-handle-wrap tm-term">' . '<div class="tma-handle"><div class="tma-attribute_label">' . apply_filters('woocommerce_variation_option_name', $term->name) . '</div><div class="tmicon tcfa fold tcfa-caret-up"></div></div>' . '<div class="tma-handle-wrapper tm-hidden">' . '<div class="tma-attribute w100">';
                         foreach ($settings_term as $setting) {
                             $setting["tags"]["id"] = str_replace("%id%", $setting["id"], $setting["tags"]["id"]);
                             $setting["tags"]["name"] = str_replace("%id%", $setting["id"], $setting["tags"]["name"]);
                             $setting["tags"]["name"] = str_replace("%attribute_id%", sanitize_title($name), $setting["tags"]["name"]);
                             $setting["tags"]["name"] = str_replace("%term_id%", esc_attr($term_id), $setting["tags"]["name"]);
                             if (!empty($meta) && isset($meta[$attribute_id]) && isset($meta[$attribute_id][$setting["id"]]) && isset($meta[$attribute_id][$setting["id"]][$term_id])) {
                                 $setting["default"] = $meta[$attribute_id][$setting["id"]][$term_id];
                                 if (isset($setting["extra"])) {
                                     $setting["extra"] = str_replace("%value%", $meta[$attribute_id][$setting["id"]][$term_id], $setting["extra"]);
                                 }
                             } else {
                                 if (isset($setting["extra"])) {
                                     $setting["extra"] = str_replace("%value%", "", $setting["extra"]);
                                 }
                             }
                             $out .= TM_EPO_HTML()->tm_make_field($setting, 0);
                         }
                         $out .= '</div></div></div>';
                     }
                 }
             } else {
                 foreach ($options as $option) {
                     $option = html_entity_decode($option, ENT_COMPAT | ENT_HTML401, 'UTF-8');
                     $out .= '<div class="tma-handle-wrap tm-term">' . '<div class="tma-handle"><div class="tma-attribute_label">' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . '</div><div class="tmicon tcfa fold tcfa-caret-up"></div></div>' . '<div class="tma-handle-wrapper tm-hidden">' . '<div class="tma-attribute w100">';
                     foreach ($settings_term as $setting) {
                         $setting["tags"]["id"] = str_replace("%id%", $setting["id"], $setting["tags"]["id"]);
                         $setting["tags"]["name"] = str_replace("%id%", $setting["id"], $setting["tags"]["name"]);
                         $setting["tags"]["name"] = str_replace("%attribute_id%", sanitize_title($name), $setting["tags"]["name"]);
                         $setting["tags"]["name"] = str_replace("%term_id%", esc_attr($option), $setting["tags"]["name"]);
                         if (!empty($meta) && isset($meta[$attribute_id]) && isset($meta[$attribute_id][$setting["id"]]) && isset($meta[$attribute_id][$setting["id"]][$option])) {
                             $setting["default"] = $meta[$attribute_id][$setting["id"]][$option];
                             if (isset($setting["extra"])) {
                                 $setting["extra"] = str_replace("%value%", $meta[$attribute_id][$setting["id"]][$option], $setting["extra"]);
                             }
                         } else {
                             if (isset($setting["extra"])) {
                                 $setting["extra"] = str_replace("%value%", "", $setting["extra"]);
                             }
                         }
                         $out .= TM_EPO_HTML()->tm_make_field($setting, 0);
                     }
                     $out .= '</div></div></div>';
                 }
             }
         }
         $out .= '</div></div></div>';
     }
     return $out;
 }
示例#19
0
							<option value=""><?php 
        echo __('Choose an option', 'woocommerce');
        ?>
&hellip;</option>
							<?php 
        if (is_array($options)) {
            if (isset($_REQUEST['attribute_' . sanitize_title($name)])) {
                $selected_value = $_REQUEST['attribute_' . sanitize_title($name)];
            } elseif (isset($selected_attributes[sanitize_title($name)])) {
                $selected_value = $selected_attributes[sanitize_title($name)];
            } else {
                $selected_value = '';
            }
            // Get terms if this is a taxonomy - ordered
            if (taxonomy_exists(sanitize_title($name))) {
                $orderby = wc_attribute_orderby(sanitize_title($name));
                switch ($orderby) {
                    case 'name':
                        $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                        break;
                    case 'id':
                        $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
                        break;
                    case 'menu_order':
                        $args = array('menu_order' => 'ASC', 'hide_empty' => false);
                        break;
                }
                $terms = get_terms(sanitize_title($name), $args);
                foreach ($terms as $term) {
                    if (!in_array($term->slug, $options)) {
                        continue;
 /**
  * widget function.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  *
  * @return void
  */
 public function widget($args, $instance)
 {
     global $_chosen_attributes;
     $this->instance = $instance;
     if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
         return;
     }
     $this->current_term = is_tax() ? get_queried_object()->term_id : '';
     $current_tax = is_tax() ? get_queried_object()->taxonomy : '';
     $this->taxonomy = isset($instance['attribute']) ? wc_attribute_taxonomy_name($instance['attribute']) : $this->settings['attribute']['std'];
     $this->query_type = isset($instance['query_type']) ? $instance['query_type'] : $this->settings['query_type']['std'];
     $display_type = isset($instance['display_type']) ? $instance['display_type'] : $this->settings['display_type']['std'];
     if (!taxonomy_exists($this->taxonomy)) {
         return;
     }
     $get_terms_args = array('hide_empty' => '1');
     $orderby = wc_attribute_orderby($this->taxonomy);
     switch ($orderby) {
         case 'name':
             $get_terms_args['orderby'] = 'name';
             $get_terms_args['menu_order'] = false;
             break;
         case 'id':
             $get_terms_args['orderby'] = 'id';
             $get_terms_args['order'] = 'ASC';
             $get_terms_args['menu_order'] = false;
             break;
         case 'menu_order':
             $get_terms_args['menu_order'] = 'ASC';
             break;
     }
     $terms = get_terms($this->taxonomy, $get_terms_args);
     if (0 < count($terms)) {
         ob_start();
         $this->found = false;
         $this->widget_start($args, $instance);
         // Force found when option is selected - do not force found on taxonomy attributes
         if (!is_tax() && is_array($_chosen_attributes) && array_key_exists($this->taxonomy, $_chosen_attributes)) {
             $this->found = true;
         }
         $filters = array();
         foreach ($terms as $term) {
             if ($term->parent == '0') {
                 $filters[$term->term_id]['parent'] = $this->build_list_item($term);
             } elseif ($term->parent != '0') {
                 $filters[$term->parent]['children'][] = $this->build_list_item($term);
             }
         }
         // List display
         echo '<ul>';
         foreach ($filters as $filter) {
             echo $filter['parent'];
             if (!empty(array_filter($filter['children']))) {
                 echo '<ul>';
                 foreach ($filter['children'] as $child) {
                     echo $child . '</li>';
                 }
                 echo '</ul>';
             }
             echo '</li>';
             // close list
         }
         echo '</ul>';
         $this->widget_end($args);
         if (!$this->found) {
             ob_end_clean();
         } else {
             echo ob_get_clean();
         }
     }
 }
 public function set_variable_add_to_cart()
 {
     global $woocommerce, $product, $post;
     $show_if_stocked = get_post_meta($post->ID, self::ID . '_show_stock_product', true);
     $stock_override = get_option(self::ID . '_show_stocks');
     $is_virtual = get_post_meta($post->ID, '_virtual', true);
     $show_stock = true;
     if ($stock_override != '1' && $stock_override != 'yes') {
         $show_stock = false;
     }
     if ($show_if_stocked == 'show') {
         $show_stock = true;
         if ($stock_override != '1' && $stock_override != 'yes') {
             $show_stock = false;
         }
     } else {
         $show_stock = false;
         if ($stock_override == '1' || $stock_override == 'yes') {
             $show_stock = true;
         }
     }
     if ($is_virtual == '1' || $is_virtual == 'yes') {
         $show_stock = false;
     }
     //$available_variations = array();
     $available_variations = $product->get_available_variations();
     do_action('woocommerce_before_add_to_cart_form');
     echo '<form class="variations_form cart paywhatyouwant_form_variations" method="post" enctype="multipart/form-data" data-product_id="' . $post->ID . '" data-product_variations="' . esc_attr(json_encode($available_variations)) . '">';
     if (!empty($available_variations)) {
         echo "<table class=\"variations\" cellspacing=\"0\">";
         echo "   <tbody>";
         $loop = 0;
         $attributes = $product->get_variation_attributes();
         $default_attributes = $product->get_variation_default_attributes();
         foreach ($attributes as $name => $options) {
             $loop++;
             echo '      <tr>';
             echo '          <td class="label"><label for="' . sanitize_title($name) . '">' . wc_attribute_label($name) . '</label></td>';
             echo '          <td class="value"><select class="pwyw_sku_value" id="' . esc_attr(sanitize_title($name)) . '" name="attribute_' . sanitize_title($name) . '">';
             //echo '          <option value="">' . __( 'Choose an option', 'woocommerce' ) . '&hellip;</option>';
             if (is_array($options)) {
                 if (isset($_REQUEST['attribute_' . sanitize_title($name)])) {
                     $selected_value = $_REQUEST['attribute_' . sanitize_title($name)];
                 } elseif (isset($selected_attributes[sanitize_title($name)])) {
                     $selected_value = $selected_attributes[sanitize_title($name)];
                 } else {
                     $selected_value = '';
                 }
                 // Get terms if this is a taxonomy - ordered
                 if (taxonomy_exists($name)) {
                     $orderby = wc_attribute_orderby($name);
                     switch ($orderby) {
                         case 'name':
                             $args = array('orderby' => 'name', 'hide_empty' => false, 'menu_order' => false);
                             break;
                         case 'id':
                             $args = array('orderby' => 'id', 'order' => 'ASC', 'menu_order' => false, 'hide_empty' => false);
                             break;
                         case 'menu_order':
                             $args = array('menu_order' => 'ASC', 'hide_empty' => false);
                             break;
                     }
                     $terms = get_terms($name, $args);
                     $loop1 = 0;
                     foreach ($terms as $term) {
                         $data_pid = $available_variations[$loop1]['variation_id'];
                         $data_sku = $available_variations[$loop1]['sku'];
                         $enable_pwyw = get_post_meta($post->ID, self::ID . '_enable_for_product', true);
                         $data_sales = '';
                         $data_price = '';
                         $data_d_sales = '';
                         $data_d_price = '';
                         if ($enable_pwyw != '1' && $enable_pwyw != 'yes') {
                             $data_sales = round(self::get_variation_sales_price($data_pid), 2);
                             $data_price = round(self::get_variation_regular_price($data_pid), 2);
                             $data_d_sales = wc_price($data_sales);
                             $data_d_price = wc_price($data_price);
                         }
                         $data_attribute = $available_variations[$loop1]['attributes']['attribute_' . $name];
                         $data_img = $available_variations[$loop1]['image_src'];
                         $data_min = $available_variations[$loop1]['min_qty'];
                         $data_max = $available_variations[$loop1]['max_qty'];
                         //$data_img_alt = $available_variations[$loop1]['image_src'];
                         //$data_img_title = $available_variations[$loop1]['image_src'];
                         $selected_option = '';
                         if ($default_attributes[$name] == $data_attribute) {
                             $selected_option = ' selected="selected"';
                         }
                         if (!isset($data_max) || empty($data_max)) {
                             $data_max = '5777';
                         }
                         if (!in_array($term->slug, $options)) {
                             continue;
                         }
                         $attributes_list = '';
                         $attributes_list .= ' data-min="' . esc_attr($data_min) . '" ';
                         $attributes_list .= ' data-max="' . esc_attr($data_max) . '" ';
                         $attributes_list .= ' data-attrib="' . esc_attr($name) . '" ';
                         $attributes_list .= ' data-item="' . esc_attr($loop1) . '" ';
                         $attributes_list .= ' data-product_id="' . esc_attr($data_pid) . '" ';
                         $attributes_list .= ' data-sku="' . esc_attr($data_sku) . '" ';
                         $attributes_list .= ' data-sales="' . esc_attr($data_sales) . '" ';
                         $attributes_list .= ' data-price="' . esc_attr($data_price) . '" ';
                         $attributes_list .= ' data-d_sales="' . esc_attr($data_d_sales) . '" ';
                         $attributes_list .= ' data-d_price="' . esc_attr($data_d_price) . '" ';
                         $attributes_list .= ' data-image="' . esc_attr($data_img) . '" ';
                         $attributes_list .= ' ' . esc_attr($selected_option) . ' ';
                         echo '                <option ' . $attributes_list . ' value="' . esc_attr($term->slug) . '" ' . selected(sanitize_title($selected_value), sanitize_title($term->slug), false) . '>' . apply_filters('woocommerce_variation_option_name', $term->name) . '</option>';
                         $loop1++;
                     }
                 } else {
                     foreach ($options as $option) {
                         echo '                <option value="' . esc_attr(sanitize_title($option)) . '" ' . selected(sanitize_title($selected_value), sanitize_title($option), false) . '>' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . '</option>';
                     }
                 }
             }
             echo "              </select>";
             if (sizeof($attributes) == $loop) {
                 echo '          <a class="reset_variations" href="#reset">' . __('Clear selection', 'woocommerce') . '</a>';
             }
             echo '          </td>';
             echo '      </tr>';
         }
         echo '  </tbody>';
         echo '</table>';
         do_action('woocommerce_before_add_to_cart_button');
         echo '<div class="single_variation_wrap">';
         do_action('woocommerce_before_single_variation');
         if ($show_stock) {
             //echo '  <span class="instock_variation">';
             echo "    <link class='instock_class' itemprop=\"availability\" href=\"http://schema.org/" . $product->is_in_stock() ? 'InStock' : 'OutOfStock' . "\" />";
             //echo '  </span>';
         }
         $enable_pwyw = get_post_meta($post->ID, self::ID . '_enable_for_product', true);
         $price_style = '';
         if ($enable_pwyw == '1' || $enable_pwyw == 'yes') {
             $price_style = ' style="display:none;" ';
             /* PRICE VALUES */
             $min_price = get_post_meta($post->ID, self::ID . '_amount_min_price', true);
             $max_price = get_post_meta($post->ID, self::ID . '_amount_max_price', true);
             echo '<input type="hidden" class="input_pwyw_price" value="true" />';
             echo '<div class="single_variation">';
             echo '  <span class="price">';
             echo '  <del class="span_price">REGULAR</del>';
             echo '  <ins class="span_price">SALES</ins>';
             echo '  <span class="span_price">';
             echo "Min: " . wc_price($min_price) . " -  Max: " . wc_price($max_price);
             echo '  </span>';
             echo '  </span>';
             echo '</div>';
         } else {
             echo '  <div class="single_variation"' . $price_style . '>';
             echo '  <span class="price">';
             echo '  <del class="span_price">REGULAR</del>';
             echo '  <ins class="span_price">SALES</ins>';
             echo '  <span class="span_price">PRICE</span>';
             echo '  </span>';
             echo '  </div>';
         }
         echo '  <div class="variations_button">';
         $defaults = array('input_name' => 'quantity', 'input_value' => '1', 'max_value' => '5555', 'min_value' => '1', 'step' => '1');
         woocommerce_quantity_input($defaults, $product, true);
         echo '      <button onclick="pwyw_add_variation_to_cart(' . esc_attr($post->ID) . ')" type="button" class="single_add_to_cart_button button alt pwyw_price_input">' . $product->single_add_to_cart_text() . '</button>';
         echo '  </div>';
         echo '  <input type="hidden" name="add-to-cart" value="' . $product->id . '" />';
         echo '  <input type="hidden" name="product_id" value="' . esc_attr($post->ID) . '" />';
         echo '  <input type="hidden" name="variation_id" value="" />';
         do_action('woocommerce_after_single_variation');
         echo '</div>';
         do_action('woocommerce_after_add_to_cart_button');
     } else {
         echo '<p class="stock out-of-stock">' . _e('This product is currently out of stock and unavailable.', 'woocommerce') . '</p>';
     }
     echo '</form>';
     do_action('woocommerce_after_add_to_cart_form');
     self::set_product_meta();
 }
function wc_bundles_attribute_order_by($arg)
{
    _deprecated_function('wc_bundles_attribute_order_by', '4.8.0', 'wc_attribute_orderby');
    return wc_attribute_orderby($arg);
}