public function add_image_uploader_to_edit_form($term) { $term_id = $term->term_id; $attr_image = get_option('_wpb_variation_attr_image_' . $term_id); $taxonomy_name = esc_html($_GET["taxonomy"]); $attribute_type = WPB_Common_Functions::get_variation_attribute_type($taxonomy_name); ?> <?php if ($attribute_type == "carousel" || $attribute_type == "extra") { ?> <tr class="form-field"> <th> <label for="hd_wpc_attribute_image"><?php _e('Image', 'wpb'); ?> </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 wpb_upload_button" id="btn_wpc_attribute_image_upload"><?php _e('Upload', 'wpb'); ?> </button> </td> </tr> <?php } ?> <?php }
public function woocommerce_order_items_meta_get_formatted($formatted_meta, $obj) { foreach ($formatted_meta as $key => $meta) { $taxonomy = $meta["key"]; $original_value = $meta["value"]; $attribute_type = WPB_Common_Functions::get_variation_attribute_type($taxonomy); if ($attribute_type == "extra") { $extra_data = $this->wpb_cart_item["extra"] ? $this->wpb_cart_item["extra"] : array(); if (isset($extra_data[$taxonomy])) { $formatted_meta[$key]["value"] = $original_value . " (" . $extra_data[$taxonomy] . ")"; } } if ($attribute_type == "size") { $size_data = $this->wpb_cart_item["size"] ? $this->wpb_cart_item["size"] : array(); if (isset($size_data[$taxonomy])) { $formatted_meta[$key]["value"] = $size_data[$taxonomy]; } } } // $formatted_meta=array(); /// print_r("test"); return $formatted_meta; }
public function add_product_designer() { global $post, $wpdb, $product, $woocommerce; //$attributes = $product->get_variation_attributes(); $attributes = maybe_unserialize(get_post_meta($post->ID, '_product_attributes', true)); $allExtras = get_post_meta($post->ID, '_wpb_extras', true); $allSize = get_post_meta($post->ID, '_wpb_dimensions', true); $notAvilables = WPB_Common_Functions::notAvailableAttributes($post->ID); $reorderSizes = WPB_Common_Functions::reorderSize($post->ID); $variations = $product->get_variation_attributes(); ?> <div id="wc-product-builder"> <div id="wpb_steps" class="f-step"> <ul class="progress-indicator" id="progress-indicator"> <?php if (!empty($attributes)) { $c = 0; foreach ($attributes as $name => $options) { if (!in_array($name, $notAvilables)) { $attribute_type = WPB_Common_Functions::get_variation_attribute_type($name); $classes = $c == 0 ? "completed acctive" : ""; ?> <li data-tab="#wpb-steps-<?php echo $name; ?> " data-taxonomy="<?php echo $name; ?> " data-counting="<?php echo $c; ?> " data-type="<?php echo $attribute_type; ?> " class="<?php echo $classes; ?> "> <a href="#"> <p><?php echo wc_attribute_label($name); ?> </p> <span class="bubble"><span class="bbll"></span></span> </a> </li> <?php $c++; } } } ?> </ul> </div> <div id="wpb_step_tab"> <?php if (!empty($attributes)) { $c = 0; foreach ($attributes as $name => $options) { // print_r($options); if (!in_array($name, $notAvilables)) { $classes = $c == 0 ? 'wpb_onedblk' : 'wpb_aldnn'; ?> <div id="wpb-steps-<?php echo $name; ?> " class="wpb_tabs <?php echo $classes; ?> "> <?php $all_terms = wc_get_product_terms($post->ID, $name, array('fields' => 'all')); $attribute_type = WPB_Common_Functions::get_variation_attribute_type($name); $default_value = $product->get_variation_default_attribute($name); $checkOptions = $variations[$name] ? $variations[$name] : array(); ?> <?php if ($attribute_type == "carousel") { ?> <?php echo self::makeCarousel($all_terms, $name, $checkOptions, $post->ID, $attribute_type, $default_value); ?> <?php } ?> <?php if ($attribute_type == "extra") { ?> <?php if ($options["is_variation"] == 1) { echo self::makeCarousel($all_terms, $name, $checkOptions, $post->ID, $attribute_type, $default_value); ?> <?php } ?> <?php $extraCarousel = $allExtras[$name] ? $allExtras[$name] : array(); ?> <?php if ($extraCarousel) { foreach ($extraCarousel as $carousel) { $allTerms = wc_get_product_terms($post->ID, $carousel, array('fields' => 'all')); $carouselOptions = $variations[$carousel] ? $variations[$carousel] : array(); $carousel_default_value = $product->get_variation_default_attribute($carousel); ?> <?php echo self::makeCarousel($allTerms, $carousel, $carouselOptions, $post->ID, 'carousel', $carousel_default_value, true); ?> <?php } } ?> <?php } ?> <?php if ($attribute_type == "dimension") { ?> <?php $attributeDimensions = $reorderSizes[$name]; if ($attributeDimensions) { foreach ($attributeDimensions as $dimension) { $regulator = $dimension[0]; $selectBox = $dimension[1]; $regulatorTerms = wc_get_product_terms($post->ID, $regulator, array('fields' => 'all')); $regulatorVariations = $variations[$regulator] ? $variations[$regulator] : array(); $regulatorDefault = $product->get_variation_default_attribute($regulator); $selectBoxTerms = wc_get_product_terms($post->ID, $selectBox, array('fields' => 'all')); $selectBoxVariations = $variations[$selectBox] ? $variations[$selectBox] : array(); $selectBoxDefault = $product->get_variation_default_attribute($selectBox); if (isset($_REQUEST['attribute_' . sanitize_title($regulator)])) { $regulatorDefault = wc_clean($_REQUEST['attribute_' . sanitize_title($regulator)]); } if (isset($_REQUEST['attribute_' . sanitize_title($selectBox)])) { $selectBoxDefault = wc_clean($_REQUEST['attribute_' . sanitize_title($selectBox)]); } self::$defaultSelections[$regulator] = $regulatorDefault; self::$defaultSelections[$selectBox] = $selectBoxDefault; ?> <div class="row"> <div class="col-sm-7"> <div class="rng-sl-sec"> <div class="rngsec"> <h2><?php echo wc_attribute_label($regulator); ?> </h2> <div id="wpb_slider_<?php echo $regulator; ?> "></div> <span id="wpb_regulator_min_<?php echo $regulator; ?> "></span> <span id="wpb_regulator_max_<?php echo $regulator; ?> " class="alr"></span> </div> </div> </div> <div class="col-sm-5"> <div class="r-inp-sec clearfix"> <select class="wpb-rngslct wbp_slider" id="wpb_rangeselect_<?php echo $regulator; ?> " data-taxonomy="<?php echo $regulator; ?> "> <?php if ($regulatorTerms) { foreach ($regulatorTerms as $r) { ?> <?php if (has_term(absint($r->term_id), $regulator, $post->ID)) { if (in_array($r->slug, $regulatorVariations)) { $selected = $regulatorDefault == $r->slug ? "selected" : ""; ?> <option <?php echo $selected; ?> value="<?php echo $r->slug; ?> "><?php echo $r->name; ?> </option> <?php } } ?> <?php } } ?> </select> <div class="rthtx"> <h2><?php echo wc_attribute_label($selectBox); ?> : </h2> <select class="wpb-rngtxt wpb-rngslct" data-taxonomy="<?php echo $selectBox; ?> " id="wpb_select_<?php echo $selectBox; ?> "> <?php if ($selectBoxTerms) { foreach ($selectBoxTerms as $s) { ?> <?php if (has_term(absint($s->term_id), $selectBox, $post->ID)) { if (in_array($s->slug, $selectBoxVariations)) { $selected = $selectBoxDefault == $s->slug ? "selected" : ""; ?> <option <?php echo $selected; ?> value="<?php echo $s->slug; ?> "><?php echo $s->name; ?> </option> <?php } } ?> <?php } } ?> </select> </div> </div> </div> </div> <?php } ?> <?php } ?> <?php } ?> </div> <?php $c++; } } } ?> </div> </div> <script type="text/javascript"> var wpb_default_selections=<?php echo json_encode(self::$defaultSelections); ?> </script> <?php }
public function add_product_data_panel() { global $wpdb, $post, $product; $attributes = maybe_unserialize(get_post_meta($post->ID, '_product_attributes', true)); $args = array('posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'wpb_info_box', 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'post_status' => 'publish', 'suppress_filters' => true); $all_posts = get_posts($args); $info_boxes = get_post_meta($post->ID, "_wpb_info_boxes", true); ?> <script type="application/javascript"> var wpb_product_page=true; </script> <div id="wpb_instructions_tab" class="panel woocommerce_options_panel wc-metaboxes-wrapper"> <div id="wpb_attribute_tab"> <div class="toolbar toolbar-top"> <table cellpadding="10" cellspacing="10"> <?php if (!empty($attributes)) { foreach ($attributes as $attr => $option) { ?> <tr> <td><?php echo wc_attribute_label($attr); ?> </td> <td> <select name="wpb_info_boxes[<?php echo $attr; ?> ]" id="wpb_info_boxes_<?php echo $attr; ?> "> <option value="">---</option> <?php if (!empty($all_posts)) { foreach ($all_posts as $p) { $selected = $info_boxes[$attr] == $p->ID ? "selected" : ""; ?> <option <?php echo $selected; ?> value="<?php echo $p->ID; ?> "><?php echo $p->post_title; ?> </option> <?php } } ?> </select> </td> </tr> <?php } ?> <tr> <td colspan="2"> <div class="toolbar toolbar-top"> <a href="#" class="button-primary wpb_save_infobox"><?php echo __('Save Info Box', 'wpb'); ?> </a> </div> </td> </tr> <?php } ?> </table> </div> </div> </div> <div id="wpb_dimension_tab" class="panel woocommerce_options_panel wc-metaboxes-wrapper"> <?php $dimension_data = get_post_meta($post->ID, '_wpb_dimensions', true); ?> <?php if (!empty($attributes)) { ?> <?php foreach ($attributes as $attr => $option) { $attribute_type = WPB_Common_Functions::get_variation_attribute_type($attr); if ($attribute_type == "dimension") { ?> <h2><?php echo __('Attributes For', 'wpb'); ?> <?php echo wc_attribute_label($attr); ?> </h2> <div id="wpb_dimension_<?php echo $attr; ?> " class="wpb_dimension"> <div id="wpb_dimension_<?php echo $attr; ?> _template"> <table cellpadding="10" cellspacing="10"> <tbody> <tr> <td class="attribute_name"> <?php echo __("Choose Multiple Attributes", "wpb"); ?> </td> <td> <select multiple id="wpb_dimension_<?php echo $attr; ?> _#index#" name="wpb_dimensions[<?php echo $attr; ?> ][#index#][]" class="wpb_enhanced_select"> <?php foreach ($attributes as $n => $m) { $opt_type = WPB_Common_Functions::get_variation_attribute_type($n); if ($opt_type == "regulator" || $opt_type == "select") { ?> <option value="<?php echo $n; ?> "><?php echo wc_attribute_label($n); ?> </option> <?php } } ?> </select> </td> </tr> </tbody> </table> </div> <div id="wpb_dimension_<?php echo $attr; ?> _noforms_template"><?php echo __("No Attribute", "wpb"); ?> </div> <div id="wpb_dimension_<?php echo $attr; ?> _controls"> <div id="wpb_dimension_<?php echo $attr; ?> _add" class="alin-btn"><a class="button"><span><?php echo __('Add Attribute', 'wpb'); ?> </span></a></div> <div id="wpb_dimension_<?php echo $attr; ?> _remove_last" class="alin-btn"><a class="button"><span><?php echo __('Remove', 'wpb'); ?> </span></a></div> </div> </div> <?php $inject_data = array(); if (!empty($dimension_data[$attr])) { foreach ($dimension_data[$attr] as $dimension) { //print_r($dimension_data); array_push($inject_data, array('wpb_dimension_' . $attr . '_#index#' => $dimension)); } } ?> <input type='hidden' value='<?php echo json_encode($inject_data); ?> '> <?php } } ?> <div class="toolbar toolbar-top"> <a href="#" class="button-primary wpb_save_dimensions"><?php echo __('Save Dimensions', 'wpb'); ?> </a> </div> <?php } ?> </div> <div id="wpb_extra_tab" class="panel woocommerce_options_panel wc-metaboxes-wrapper"> <?php $extra_data = get_post_meta($post->ID, '_wpb_extras', true); ?> <?php if (!empty($attributes)) { ?> <?php foreach ($attributes as $k => $v) { $attribute_type = WPB_Common_Functions::get_variation_attribute_type($k); if ($attribute_type == "extra") { ?> <h2><?php echo wc_attribute_label($k); ?> </h2> <div id="wpb_extra_<?php echo $k; ?> " class="wpb_dimension"> <div id="wpb_extra_<?php echo $k; ?> _template"> <table cellpadding="10" cellspacing="10"> <tbody> <tr> <td class="attribute_name"> <?php echo __("Choose Attribute", "wpb"); ?> </td> <td> <select id="wpb_extra_<?php echo $k; ?> _#index#" name="wpb_extras[<?php echo $k; ?> ][#index#]" class=""> <?php foreach ($attributes as $n => $m) { $opt_type = WPB_Common_Functions::get_variation_attribute_type($n); if ($opt_type == "carousel") { ?> <option value="<?php echo $n; ?> "><?php echo wc_attribute_label($n); ?> </option> <?php } } ?> </select> </td> </tr> </tbody> </table> </div> <div id="wpb_extra_<?php echo $k; ?> _noforms_template"><?php echo __("No Attribute", "wpb"); ?> </div> <div id="wpb_extra_<?php echo $k; ?> _controls"> <div id="wpb_extra_<?php echo $k; ?> _add" class="alin-btn"><a class="button"><span><?php echo __('Add Attribute', 'wpb'); ?> </span></a></div> <div id="wpb_extra_<?php echo $k; ?> _remove_last" class="alin-btn"><a class="button"><span><?php echo __('Remove', 'wpb'); ?> </span></a></div> </div> </div> <?php $inject_data = array(); if (!empty($extra_data[$k])) { foreach ($extra_data[$k] as $extra) { //print_r($dimension_data); array_push($inject_data, array('wpb_extra_' . $k . '_#index#' => $extra)); } } ?> <input type='hidden' value='<?php echo json_encode($inject_data); ?> '> <?php } } ?> <div class="toolbar toolbar-top"> <a href="#" class="button-primary wpb_save_extras"><?php echo __('Save Additional Carousels', 'wpb'); ?> </a> </div> <?php } ?> </div> <div id="wpb_defaults_tab" class="panel woocommerce_options_panel wc-metaboxes-wrapper"> <h2><?php echo __("Default Selections", "wpb"); ?> </h2> <table> <?php $defaults = get_post_meta($post->ID, '_wpb_defaults', true); if (!empty($attributes)) { ?> <?php foreach ($attributes as $attr => $options) { if ($options["is_variation"] == 1) { $selected_option = isset($defaults[$attr]) ? $defaults[$attr] : ""; ?> <tr> <td> <?php echo wc_attribute_label($attr); ?> </td> <td> <?php $terms = wc_get_product_terms($post->ID, $attr, array('fields' => 'all')); ?> <select name="wpb_defaults[<?php echo $attr; ?> ]"> <?php if (!empty($terms)) { foreach ($terms as $term) { if (has_term(absint($term->term_id), $attr, $post->ID)) { ?> <option <?php echo $selected_option == $term->slug ? "selected" : ""; ?> value="<?php echo $term->slug; ?> "><?php echo $term->name; ?> </option> <?php } } } ?> </select> </td> </tr> <?php } ?> <?php } ?> <?php } ?> <tr><td colspan="2"> <div class="toolbar toolbar-top"> <a href="#" class="button-primary wpb_save_defaults"><?php echo __('Save Default Selections', 'wpb'); ?> </a> </div> </td></tr> </table> </div> <?php }