public function add_image_uploader_to_edit_form($term) { $term_id = $term->term_id; $attr_image = get_option('_wpc_variation_attr_image_' . $term_id); $taxonomy_name = esc_html($_GET["taxonomy"]); $attribute_type = get_variation_attribute_type($taxonomy_name); ?> <?php if ($attribute_type == "image") { ?> <tr class="form-field"> <th> <label for="hd_wpc_attribute_image"><?php _e('Image', 'wpc'); ?> </label> </th> <td class="wpc-upload-field"> <input type="text" class="wide-fat" id="hd_wpb_attribute_image" value="<?php echo $attr_image; ?> " name="hd_wpb_attribute_image"/> <button class="button button-secondary wpc_upload_button" id="btn_wpc_attribute_image_upload"><?php _e('Upload', 'wpc'); ?> </button> </td> </tr> <?php } ?> <?php }
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 }