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 enqueue_styles() { global $post, $woocommerce, $wp_styles; $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; if (WPB_Common_Functions::wpb_enabled($post->ID)) { wp_enqueue_style('wpb_style_grids', WPB_PLUGIN_ASSETS_DIR . '/css/grid12.css', false); wp_enqueue_style('wpb_style_range_slider', '//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css', false); wp_enqueue_style('wpb_style_bx_slider', WPB_PLUGIN_ASSETS_DIR . '/css/jquery.bxslider.css', false); wp_enqueue_style('wpb_style_styles', WPB_PLUGIN_ASSETS_DIR . '/css/style.css', false); echo '<!--[if IE]>'; wp_enqueue_style('wpb_style_ie_styles', WPB_PLUGIN_ASSETS_DIR . '/css/ie.css'); echo '<![endif]-->'; $wp_styles->add_data('wpb_style_ie_styles', 'conditional', 'IE'); wp_enqueue_script('wpb_script_toucheswipe', WPB_PLUGIN_ASSETS_DIR . '/js/jquery.touchSwipe.min.js', array('jquery'), null, true); wp_enqueue_script('wpb_script_flim_roll', WPB_PLUGIN_ASSETS_DIR . '/js/jquery.film_roll.min.js', array('jquery'), null, true); wp_enqueue_script('wpb_script_underscore', WPB_PLUGIN_ASSETS_DIR . '/js/underscore-min.js', array('jquery'), null, true); wp_register_script('wpb_script_frontend', WPB_PLUGIN_ASSETS_DIR . '/js/wpb.frontend.js', array('jquery'), null, true); wp_enqueue_script('jquery-ui-slider'); wp_enqueue_script('wpb_prettyPhoto', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), $woocommerce->version, true); // wp_enqueue_script( 'prettyPhoto-init', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true ); wp_enqueue_style('wpb_woocommerce_prettyPhoto_css', $woocommerce->plugin_url() . '/assets/css/prettyPhoto.css'); wp_enqueue_script('wpb_script_touch', WPB_PLUGIN_ASSETS_DIR . '/js/jquery.ui.touch-punch.min.js', array('jquery'), null, true); wp_localize_script("wpb_script_frontend", "wpb_local_params", array("continue_text" => __("Continue", "wpb"), "add_to_cart_text" => __("Add to Cart", "wpb"), "productId" => $post->ID, "ajaxUrl" => admin_url('admin-ajax.php'), "resetText" => __("Are you sure to reset?", "wpb"))); wp_enqueue_script('wpb_script_frontend'); } }
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_class($classes) { global $post; if (WPB_Common_Functions::wpb_enabled($post->ID)) { $classes[] = 'wpb-body-product'; } return $classes; }
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 }