/**
 * Output a text input box.
 *
 * @param array $field
 */
function woocommerce_wp_text_input($field)
{
    global $thepostid, $post;
    $thepostid = empty($thepostid) ? $post->ID : $thepostid;
    $field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
    $field['class'] = isset($field['class']) ? $field['class'] : 'short';
    $field['style'] = isset($field['style']) ? $field['style'] : '';
    $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
    $field['value'] = isset($field['value']) ? $field['value'] : get_post_meta($thepostid, $field['id'], true);
    $field['name'] = isset($field['name']) ? $field['name'] : $field['id'];
    $field['type'] = isset($field['type']) ? $field['type'] : 'text';
    $field['desc_tip'] = isset($field['desc_tip']) ? $field['desc_tip'] : false;
    $data_type = empty($field['data_type']) ? '' : $field['data_type'];
    switch ($data_type) {
        case 'price':
            $field['class'] .= ' wc_input_price';
            $field['value'] = wc_format_localized_price($field['value']);
            break;
        case 'decimal':
            $field['class'] .= ' wc_input_decimal';
            $field['value'] = wc_format_localized_decimal($field['value']);
            break;
        case 'stock':
            $field['class'] .= ' wc_input_stock';
            $field['value'] = wc_stock_amount($field['value']);
            break;
        case 'url':
            $field['class'] .= ' wc_input_url';
            $field['value'] = esc_url($field['value']);
            break;
        default:
            break;
    }
    // Custom attribute handling
    $custom_attributes = array();
    if (!empty($field['custom_attributes']) && is_array($field['custom_attributes'])) {
        foreach ($field['custom_attributes'] as $attribute => $value) {
            $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($value) . '"';
        }
    }
    echo '<p class="form-field ' . esc_attr($field['id']) . '_field ' . esc_attr($field['wrapper_class']) . '">
		<label for="' . esc_attr($field['id']) . '">' . wp_kses_post($field['label']) . '</label>';
    if (!empty($field['description']) && false !== $field['desc_tip']) {
        echo wc_help_tip($field['description']);
    }
    echo '<input type="' . esc_attr($field['type']) . '" class="' . esc_attr($field['class']) . '" style="' . esc_attr($field['style']) . '" name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($field['value']) . '" placeholder="' . esc_attr($field['placeholder']) . '" ' . implode(' ', $custom_attributes) . ' /> ';
    if (!empty($field['description']) && false === $field['desc_tip']) {
        echo '<span class="description">' . wp_kses_post($field['description']) . '</span>';
    }
    echo '</p>';
}
/**
 * Output a text input box.
 *
 * @access public
 * @param array $field
 * @return void
 */
function woocommerce_wp_text_input($field)
{
    global $thepostid, $post, $woocommerce;
    $thepostid = empty($thepostid) ? $post->ID : $thepostid;
    $field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
    $field['class'] = isset($field['class']) ? $field['class'] : 'short';
    $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
    $field['value'] = isset($field['value']) ? $field['value'] : get_post_meta($thepostid, $field['id'], true);
    $field['name'] = isset($field['name']) ? $field['name'] : $field['id'];
    $field['type'] = isset($field['type']) ? $field['type'] : 'text';
    $data_type = empty($field['data_type']) ? '' : $field['data_type'];
    switch ($data_type) {
        case 'price':
            $field['class'] .= ' wc_input_price';
            $field['value'] = wc_format_localized_price($field['value']);
            break;
        case 'decimal':
            $field['class'] .= ' wc_input_decimal';
            $field['value'] = wc_format_localized_decimal($field['value']);
            break;
    }
    // Custom attribute handling
    $custom_attributes = array();
    if (!empty($field['custom_attributes']) && is_array($field['custom_attributes'])) {
        foreach ($field['custom_attributes'] as $attribute => $value) {
            $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($value) . '"';
        }
    }
    echo '<p class="form-field ' . esc_attr($field['id']) . '_field ' . esc_attr($field['wrapper_class']) . '"><label for="' . esc_attr($field['id']) . '">' . wp_kses_post($field['label']) . '</label><input type="' . esc_attr($field['type']) . '" class="' . esc_attr($field['class']) . '" name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($field['value']) . '" placeholder="' . esc_attr($field['placeholder']) . '" ' . implode(' ', $custom_attributes) . ' /> ';
    if (!empty($field['description'])) {
        if (isset($field['desc_tip']) && false !== $field['desc_tip']) {
            echo '<img class="help_tip" data-tip="' . esc_attr($field['description']) . '" src="' . esc_url(WC()->plugin_url()) . '/assets/images/help.png" height="16" width="16" />';
        } else {
            echo '<span class="description">' . wp_kses_post($field['description']) . '</span>';
        }
    }
    echo '</p>';
}
 /**
  * Returns formatted dimensions.
  * @return string
  */
 public function get_dimensions()
 {
     $dimensions = implode(' x ', array_filter(array(wc_format_localized_decimal($this->get_length()), wc_format_localized_decimal($this->get_width()), wc_format_localized_decimal($this->get_height()))));
     if (!empty($dimensions)) {
         $dimensions .= ' ' . get_option('woocommerce_dimension_unit');
     }
     return apply_filters('woocommerce_product_dimensions', $dimensions, $this);
 }
 /**
  * Test wc_format_localized_decimal().
  *
  * @since 2.2
  */
 public function test_wc_format_localized_decimal()
 {
     $this->assertEquals('1.17', wc_format_localized_decimal('1.17'));
 }
 private function decimalInput(array $attrs = array())
 {
     if (isset($attrs['value']) && (string) $attrs['value'] !== '') {
         $attrs['value'] = wc_format_localized_decimal($attrs['value']);
     }
     $attrs['class'] = (array) @$attrs['class'];
     $attrs['class'][] = 'wc_input_decimal input-text';
     return $this->input($attrs);
 }
 /**
  * Load variations via AJAX
  */
 public static function load_variations()
 {
     ob_start();
     check_ajax_referer('load-variations', 'security');
     // Check permissions again and make sure we have what we need
     if (!current_user_can('edit_products') || empty($_POST['product_id']) || empty($_POST['attributes'])) {
         die(-1);
     }
     global $post;
     $product_id = absint($_POST['product_id']);
     $post = get_post($product_id);
     // Set $post global so its available like within the admin screens
     $per_page = !empty($_POST['per_page']) ? absint($_POST['per_page']) : 10;
     $page = !empty($_POST['page']) ? absint($_POST['page']) : 1;
     // Get attributes
     $attributes = array();
     foreach ($_POST['attributes'] as $key => $value) {
         $attributes[wc_clean($key)] = array_map('wc_clean', $value);
     }
     // Get tax classes
     $tax_classes = WC_Tax::get_tax_classes();
     $tax_class_options = array();
     $tax_class_options[''] = __('Standard', 'woocommerce');
     if (!empty($tax_classes)) {
         foreach ($tax_classes as $class) {
             $tax_class_options[sanitize_title($class)] = esc_attr($class);
         }
     }
     // Set backorder options
     $backorder_options = array('no' => __('Do not allow', 'woocommerce'), 'notify' => __('Allow, but notify customer', 'woocommerce'), 'yes' => __('Allow', 'woocommerce'));
     // set stock status options
     $stock_status_options = array('instock' => __('In stock', 'woocommerce'), 'outofstock' => __('Out of stock', 'woocommerce'));
     $parent_data = array('id' => $product_id, 'attributes' => $attributes, 'tax_class_options' => $tax_class_options, 'sku' => get_post_meta($product_id, '_sku', true), 'weight' => wc_format_localized_decimal(get_post_meta($product_id, '_weight', true)), 'length' => wc_format_localized_decimal(get_post_meta($product_id, '_length', true)), 'width' => wc_format_localized_decimal(get_post_meta($product_id, '_width', true)), 'height' => wc_format_localized_decimal(get_post_meta($product_id, '_height', true)), 'tax_class' => get_post_meta($product_id, '_tax_class', true), 'backorder_options' => $backorder_options, 'stock_status_options' => $stock_status_options);
     if (!$parent_data['weight']) {
         $parent_data['weight'] = wc_format_localized_decimal(0);
     }
     if (!$parent_data['length']) {
         $parent_data['length'] = wc_format_localized_decimal(0);
     }
     if (!$parent_data['width']) {
         $parent_data['width'] = wc_format_localized_decimal(0);
     }
     if (!$parent_data['height']) {
         $parent_data['height'] = wc_format_localized_decimal(0);
     }
     // Get variations
     $args = array('post_type' => 'product_variation', 'post_status' => array('private', 'publish'), 'posts_per_page' => $per_page, 'paged' => $page, 'orderby' => 'ID', 'order' => 'DESC', 'post_parent' => $product_id);
     $variations = get_posts($args);
     $loop = 0;
     if ($variations) {
         foreach ($variations as $variation) {
             $variation_id = absint($variation->ID);
             $variation_meta = get_post_meta($variation_id);
             $variation_data = array();
             $shipping_classes = get_the_terms($variation_id, 'product_shipping_class');
             $variation_fields = array('_sku' => '', '_stock' => '', '_regular_price' => '', '_sale_price' => '', '_weight' => '', '_length' => '', '_width' => '', '_height' => '', '_download_limit' => '', '_download_expiry' => '', '_downloadable_files' => '', '_downloadable' => '', '_virtual' => '', '_thumbnail_id' => '', '_sale_price_dates_from' => '', '_sale_price_dates_to' => '', '_manage_stock' => '', '_stock_status' => '', '_backorders' => null, '_tax_class' => null, '_variation_description' => '');
             foreach ($variation_fields as $field => $value) {
                 $variation_data[$field] = isset($variation_meta[$field][0]) ? maybe_unserialize($variation_meta[$field][0]) : $value;
             }
             // Add the variation attributes
             foreach ($variation_meta as $key => $value) {
                 if (0 !== strpos($key, 'attribute_')) {
                     continue;
                 }
                 /**
                  * Pre 2.4 handling where 'slugs' were saved instead of the full text attribute.
                  * Attempt to get full version of the text attribute from the parent.
                  */
                 if (sanitize_title($value[0]) === $value[0] && version_compare(get_post_meta($product_id, '_product_version', true), '2.4.0', '<')) {
                     foreach ($attributes as $attribute) {
                         if ($key !== 'attribute_' . sanitize_title($attribute['name'])) {
                             continue;
                         }
                         $text_attributes = wc_get_text_attributes($attribute['value']);
                         foreach ($text_attributes as $text_attribute) {
                             if (sanitize_title($text_attribute) === $value[0]) {
                                 $value[0] = $text_attribute;
                             }
                         }
                     }
                 }
                 $variation_data[$key] = $value[0];
             }
             // Formatting
             $variation_data['_regular_price'] = wc_format_localized_price($variation_data['_regular_price']);
             $variation_data['_sale_price'] = wc_format_localized_price($variation_data['_sale_price']);
             $variation_data['_weight'] = wc_format_localized_decimal($variation_data['_weight']);
             $variation_data['_length'] = wc_format_localized_decimal($variation_data['_length']);
             $variation_data['_width'] = wc_format_localized_decimal($variation_data['_width']);
             $variation_data['_height'] = wc_format_localized_decimal($variation_data['_height']);
             $variation_data['_thumbnail_id'] = absint($variation_data['_thumbnail_id']);
             $variation_data['image'] = $variation_data['_thumbnail_id'] ? wp_get_attachment_thumb_url($variation_data['_thumbnail_id']) : '';
             $variation_data['shipping_class'] = $shipping_classes && !is_wp_error($shipping_classes) ? current($shipping_classes)->term_id : '';
             // Stock BW compat
             if ('' !== $variation_data['_stock']) {
                 $variation_data['_manage_stock'] = 'yes';
             }
             include 'admin/meta-boxes/views/html-variation-admin.php';
             $loop++;
         }
     }
     die;
 }
		<?php 
if (wc_product_weight_enabled() || wc_product_dimensions_enabled()) {
    ?>
		<div class="dimension_fields">

			<?php 
    if (wc_product_weight_enabled()) {
        ?>
				<label>
					<span class="title"><?php 
        _e('Weight', 'woocommerce');
        ?>
</span>
					<span class="input-text-wrap">
						<input type="text" name="_weight" class="text weight" placeholder="<?php 
        echo wc_format_localized_decimal(0);
        ?>
" value="">
					</span>
				</label>
				<br class="clear" />
			<?php 
    }
    ?>

			<?php 
    if (wc_product_dimensions_enabled()) {
        ?>
				<div class="inline-edit-group dimensions">
					<div>
						<span class="title"><?php 
    private static function listProfiles(array $profiles)
    {
        $current_profile_id = WBS_Profile_Manager::instance()->current_profile_id();
        ?>
            <table id="woowbs_shipping_methods" class="wc_shipping widefat">
                <thead>
                <tr>
                    <th class="name">   <?php 
        esc_html_e('Name', 'woowbs');
        ?>
                  </th>
                    <th>                <?php 
        esc_html_e('Destination', 'woowbs');
        ?>
           </th>
                    <th>                <?php 
        esc_html_e('Weight', 'woowbs');
        ?>
                </th>
                    <th>                <?php 
        esc_html_e('Subtotal', 'woowbs');
        ?>
              </th>
                    <th>                <?php 
        esc_html_e('Cost', 'woowbs');
        ?>
                  </th>
                    <th class="status"> <?php 
        esc_html_e('Active', 'woowbs');
        ?>
                </th>
                    <th>                <?php 
        esc_html_e('Actions');
        ?>
                         </th>
                </tr>
                </thead>
                <tbody>
                <?php 
        /** @var WC_Weight_Based_Shipping[] $profiles */
        ?>
                <?php 
        foreach ($profiles as $profile) {
            ?>
                    <tr
                        <?php 
            echo $profile->profile_id === $current_profile_id ? 'class="wbs-current"' : null;
            ?>
                        data-settings-url="<?php 
            echo esc_html(WbsRuleUrls::edit($profile));
            ?>
"
                        >
                        <td class="name"><?php 
            echo esc_html($profile->name);
            ?>
</td>

                        <td class="countries">
                            <?php 
            if ($profile->availability === 'all') {
                ?>
                                <?php 
                esc_html_e('Any', 'woowbs');
                ?>
                            <?php 
            } else {
                ?>
                                <?php 
                if ($profile->availability === 'excluding') {
                    ?>
                                    <?php 
                    esc_html_e('All except', 'woowbs');
                    ?>
                                <?php 
                }
                ?>
                                <?php 
                echo esc_html(join(', ', $profile->countries));
                ?>
                            <?php 
            }
            ?>
                        </td>

                        <?php 
            foreach (array($profile->weight, $profile->subtotal) as $range) {
                ?>
                            <td>
                                <?php 
                echo isset($range->min) || isset($range->max) ? ($range->minInclusive || !isset($range->min) ? '[' : '(') . esc_html(wc_format_localized_decimal((double) $range->min)) . '&nbsp;–&nbsp;' . (isset($range->max) ? esc_html(wc_format_localized_decimal($range->max)) : '<span style="font-family:monospace">&infin;</span>') . ($range->maxInclusive ? ']' : ')') : 'Any';
                ?>
                            </td>
                        <?php 
            }
            ?>

                        <td>
                            <?php 
            echo esc_html($profile->makeCostString());
            ?>
                        </td>

                        <td class="status">
                            <?php 
            if ($profile->enabled == 'yes') {
                ?>
                                <span class="status-enabled tips" data-tip="<?php 
                esc_html_e('Enabled', 'woowbs');
                ?>
"><?php 
                esc_html_e('Enabled', 'woowbs');
                ?>
</span>
                            <?php 
            } else {
                ?>
                                -
                            <?php 
            }
            ?>
                        </td>

                        <td class="actions">
                            <a class="button" href="<?php 
            echo esc_html(WbsRuleUrls::duplicate($profile));
            ?>
">
                                <?php 
            esc_html_e('Duplicate', 'woowbs');
            ?>
                            </a>

                            <a class="button" href="<?php 
            echo esc_html(WbsRuleUrls::delete($profile));
            ?>
"
                               onclick="return confirm('<?php 
            esc_html_e('Are you sure you want to delete this rule?', 'woowbs');
            ?>
');">
                                <?php 
            esc_html_e('Delete');
            ?>
                            </a>
                        </td>
                    </tr>
                <?php 
        }
        ?>
                </tbody>
            </table>
            <script>
                jQuery((function($)
                {
                    var $table = $("#woowbs_shipping_methods");
                    $table.find('tbody').on("sortcreate", function() { $(this).sortable('destroy'); });
                    $table.find('td').click(function(e) { if (e.target == this) location.href = $(this).parent().data('settingsUrl'); });
                })(jQuery));
            </script>

            <!--suppress CssUnusedSymbol -->
            <style>
                #woowbs_shipping_methods td { cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
                #woowbs_shipping_methods .actions { white-space: nowrap; }
                #woowbs_shipping_methods .countries { max-width: 15em; }
                #woowbs_shipping_methods .wbs-current td { background-color: #eee; }
                #woowbs_shipping_methods tr:hover td { background-color: #ddd; }
                tr.wbs-title th { padding: 2em 0 0 0; }
                tr.wbs-title h4 { font-size: 1.2em; }
                .wc-settings-sub-title { padding-top: 2em; }
                .form-table { border-top: 1px solid #aaa; }
                tr.wbs-profiles > td { padding: 0; }

                .wbs-destination label { display: none; }
                .wbs-destination .forminp { padding-top: 0; }
                .wbs-destination fieldset { margin-top: -15px !important; }

                .wbs-subtotal .forminp { padding-bottom: 0}
                .wbs-subtotal + tr > * { padding-top: 0 }
                .wbs-subtotal + tr label { display: none; }
                .wbs-minifield { width: 15.7em; }
                .wbs-minifield.wc_input_decimal { text-align: right; }
                .wbs-minifield-container { display: block ! important; }
                .wbs-minifield-label { display: inline-block; min-width: 3em; }
                .wbs-range-simple .wbs-minifield-label { min-width: 5em; }
                .wbs-range-simple .wbs-minifield { min-width: 19.7em; }
                .wbs-weight-rate .wbs-minifield-label { min-width: 5em; }
                .wbs-weight-rate .wbs-minifield { width: 17.3em; }

                .wbs-input-group {
                    display: inline-block;
                    height: 29px;
                    box-sizing: border-box;
                }

                .wbs-input-group-addon {
                    display: inline-block;
                    box-sizing: border-box;
                    height: 100%;
                    width: 2.5em;
                    text-align: center;
                    border: 1px solid #ddd;
                    padding: 3px 0;
                }

                .wbs-input-group-addon:first-child {
                    border-right: 0;
                    float: left;
                }

                .wbs-input-group-addon:last-child {
                    border-left: 0;
                    float: right;
                }

                .wbs-input-group input[type="text"] {
                    display: inline-block;
                    height: 100%;
                    box-sizing: border-box;
                    margin: 0;
                }

                .wbs-code {
                    font-size: inherit;
                    padding: 0 0.5em;
                    font-family: monospace;
                }

                .shippingrows {
                    overflow: hidden;
                }

                .shippingrows th, .shippingrows td {
                    width: auto;
                    white-space: nowrap;
                    padding: 1em;
                }

                .shippingrows .wc_input_decimal {
                    width: 7em;
                }

                .flat_rate .wbs-minifield-container {
                    display: inline !important;
                    margin-left: 1em;
                }

                .flat_rate .wbs-minifield-container:first-child {
                    margin-left: 0;
                }

                .flat_rate .wbs-minifield-label {
                    display: inline;
                }

                .flat_rate .wbs-minifield {
                    width: 6em;
                }

                .flat_rate_tpl {
                    display: none;
                }
            </style>
            <?php 
    }
    /**
     * Variable Products meta for WC pre 2.3
     */
    public static function output_pre($loop, $variation_data)
    {
        $variation_id = isset($variation_data['variation_post_id']) ? $variation_data['variation_post_id'] : -1;
        $delivery_times = get_the_terms($variation_id, 'product_delivery_time');
        $delivery_time = $delivery_times && !is_wp_error($delivery_times) ? current($delivery_times)->term_id : '';
        ?>
		<tr>
			<td>
				<label><?php 
        _e('Unit', 'woocommerce-germanized');
        ?>
:</label>
				<select name="variable_unit[<?php 
        echo $loop;
        ?>
]">
					<option value="parent" <?php 
        selected(is_null(isset($variation_data['_unit'][0]) ? $variation_data['_unit'][0] : null), true);
        ?>
><?php 
        _e('None', 'woocommerce-germanized');
        ?>
</option>
					<?php 
        foreach (WC_germanized()->units->get_units() as $key => $value) {
            echo '<option value="' . esc_attr($key) . '" ' . selected($key === (isset($variation_data['_unit'][0]) ? $variation_data['_unit'][0] : ''), true, false) . '>' . esc_html($value) . '</option>';
        }
        ?>
</select>
			</td>
			<td>
				<label for="variable_unit_base"><?php 
        echo __('Unit Base', 'woocommerce-germanized');
        ?>
:</label>
				<input class="input-text wc_input_decimal" size="6" type="text" name="variable_unit_base[<?php 
        echo $loop;
        ?>
]" value="<?php 
        echo isset($variation_data['_unit_base'][0]) ? esc_attr(wc_format_localized_decimal($variation_data['_unit_base'][0])) : '';
        ?>
" placeholder="" />
			</td>
		</tr>
		<tr>
			<td>
				<label for="variable_unit_price_regular"><?php 
        echo __('Regular Unit Price', 'woocommerce-germanized') . ' (' . get_woocommerce_currency_symbol() . ')';
        ?>
:</label>
				<input class="input-text wc_input_price" size="5" type="text" name="variable_unit_price_regular[<?php 
        echo $loop;
        ?>
]" value="<?php 
        echo isset($variation_data['_unit_price_regular'][0]) ? esc_attr(wc_format_localized_price($variation_data['_unit_price_regular'][0])) : '';
        ?>
" placeholder="" />
			</td>
			<td>
				<label for="variable_unit_price_sale"><?php 
        echo __('Sale Unit Price', 'woocommerce-germanized') . ' (' . get_woocommerce_currency_symbol() . ')';
        ?>
:</label>
				<input class="input-text wc_input_price" size="5" type="text" name="variable_unit_price_sale[<?php 
        echo $loop;
        ?>
]" value="<?php 
        echo isset($variation_data['_unit_price_sale'][0]) ? esc_attr(wc_format_localized_price($variation_data['_unit_price_sale'][0])) : '';
        ?>
" placeholder="" />
			</td>
		</tr>
		<tr>
			<td class="hide_if_variation_virtual">
				<label><?php 
        _e('Delivery Time', 'woocommerce-germanized');
        ?>
:</label> 
				<?php 
        $args = array('taxonomy' => 'product_delivery_time', 'hide_empty' => 0, 'show_option_none' => __('None', 'woocommerce-germanized'), 'name' => 'variable_delivery_time[' . $loop . ']', 'id' => '', 'selected' => isset($delivery_time) ? esc_attr($delivery_time) : '', 'echo' => 0);
        echo wp_dropdown_categories($args);
        ?>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="variable_cart_mini_desc_pre">
				<label for="variable_product_mini_desc"><?php 
        echo __('Optional Mini Description', 'woocommerce-germanized');
        ?>
:</label>
				<?php 
        wp_editor(htmlspecialchars_decode(isset($variation_data['_mini_desc'][0]) ? $variation_data['_mini_desc'][0] : ''), 'wc_gzd_product_mini_desc_' . $loop, array('textarea_name' => 'variable_product_mini_desc[' . $loop . ']', 'textarea_rows' => 5, 'media_buttons' => false, 'teeny' => true));
        ?>
			</td>
		</tr>
		<?php 
    }
" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php 
    echo esc_attr(wc_format_localized_decimal($product_object->get_length('edit')));
    ?>
" />
						<input placeholder="<?php 
    esc_attr_e('Width', 'woocommerce');
    ?>
" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php 
    echo esc_attr(wc_format_localized_decimal($product_object->get_width('edit')));
    ?>
" />
						<input placeholder="<?php 
    esc_attr_e('Height', 'woocommerce');
    ?>
" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php 
    echo esc_attr(wc_format_localized_decimal($product_object->get_height('edit')));
    ?>
" />
					</span>
					<?php 
    echo wc_help_tip(__('LxWxH in decimal form', 'woocommerce'));
    ?>
				</p><?php 
}
do_action('woocommerce_product_options_dimensions');
?>
	</div>

	<div class="options_group">
		<?php 
$args = array('taxonomy' => 'product_shipping_class', 'hide_empty' => 0, 'show_option_none' => __('No shipping class', 'woocommerce'), 'name' => 'product_shipping_class', 'id' => 'product_shipping_class', 'selected' => $product_object->get_shipping_class_id('edit'), 'class' => 'select short');
 /**
  * Return the array with all products and all attributes values
  *
  * @return array The complete list of products with all attributes value
  */
 public function get_products_list($products = array())
 {
     $list = array();
     $products = empty($products) ? $this->products_list : $products;
     $products = apply_filters('yith_woocompare_exclude_products_from_list', $products);
     $fields = $this->fields();
     foreach ($products as $product_id) {
         $product = $this->wc_get_product($product_id);
         if (!$product) {
             continue;
         }
         $product->fields = array();
         // custom attributes
         foreach ($fields as $field => $name) {
             switch ($field) {
                 case 'title':
                     $product->fields[$field] = $product->get_title();
                     break;
                 case 'price':
                     $product->fields[$field] = $product->get_price_html();
                     break;
                 case 'image':
                     $product->fields[$field] = intval(get_post_thumbnail_id($product_id));
                     break;
                 case 'description':
                     $product->fields[$field] = apply_filters('woocommerce_short_description', $product->post->post_excerpt);
                     break;
                 case 'stock':
                     $availability = $product->get_availability();
                     if (empty($availability['availability'])) {
                         $availability['availability'] = __('In stock', 'yith-woocommerce-compare');
                     }
                     $product->fields[$field] = sprintf('<span class="%s">%s</span>', esc_attr($availability['class']), esc_html($availability['availability']));
                     break;
                 case 'weight':
                     if ($weight = $product->get_weight()) {
                         $weight = wc_format_localized_decimal($weight) . ' ' . esc_attr(get_option('woocommerce_weight_unit'));
                     } else {
                         $weight = '-';
                     }
                     $product->fields[$field] = sprintf('<span>%s</span>', esc_html($weight));
                     break;
                 case 'dimensions':
                     if (!($dimensions = $product->get_dimensions())) {
                         $dimensions = '-';
                     }
                     $product->fields[$field] = sprintf('<span>%s</span>', esc_html($dimensions));
                     break;
                 default:
                     if (taxonomy_exists($field)) {
                         $product->fields[$field] = array();
                         $terms = get_the_terms($product_id, $field);
                         if (!empty($terms)) {
                             foreach ($terms as $term) {
                                 $term = sanitize_term($term, $field);
                                 $product->fields[$field][] = $term->name;
                             }
                         }
                         $product->fields[$field] = implode(', ', $product->fields[$field]);
                     } else {
                         do_action_ref_array('yith_woocompare_field_' . $field, array($product, &$product->fields));
                     }
                     break;
             }
         }
         $list[] = $product;
     }
     return $list;
 }
        /**
         * Output section.
         *
         * @access public
         * @return void
         */
        public function section_settings($not_available_countries, $group = array())
        {
            if (!isset($group['name'])) {
                $group['name'] = '';
            }
            if (!isset($group['countries'])) {
                $group['countries'] = array();
            }
            if (!isset($group['currency'])) {
                $group['currency'] = get_option('woocommerce_currency');
            }
            if (!isset($group['empty_price_method'])) {
                $group['empty_price_method'] = '';
            }
            if (!isset($group['exchange_rate'])) {
                $group['exchange_rate'] = '1';
            }
            ?>
		<h3><?php 
            echo $group['name'] ? esc_html($group['name']) : __('Add Group', 'wc-price-based-country');
            ?>
</h3>
		<table class="form-table">

			<!-- Region name -->
			<tr valign="top">
				<th scope="row" class="titledesc">
					<label for="group_name"><?php 
            _e('Region Name', 'wc-price-based-country');
            ?>
</label>
					<?php 
            //echo $tip;
            ?>
				</th>
                <td class="forminp forminp-text">
                	<input name="group_name" id="group_name" type="text" value="<?php 
            echo esc_attr($group['name']);
            ?>
"/> 
                	<?php 
            //echo $description;
            ?>
                </td>
			</tr>

			<!-- Country multiselect -->			
			<tr valign="top">
				<th scope="row" class="titledesc">
					<label for="group_countries"><?php 
            _e('Countries', 'wc-price-based-country');
            ?>
</label>
				</th>
				<td class="forminp">
					<select multiple="multiple" name="group_countries[]" style="width:350px" data-placeholder="<?php 
            _e('Choose countries&hellip;', 'woocommerce');
            ?>
" title="Country" class="chosen_select">
						<?php 
            $countries = WC()->countries->countries;
            asort($countries);
            foreach ($countries as $key => $val) {
                if (!in_array($key, $not_available_countries)) {
                    echo '<option value="' . esc_attr($key) . '" ' . selected(in_array($key, $group['countries']), true, false) . '>' . $val . '</option>';
                }
            }
            ?>
					</select>
					<!-- <a class="select_all button" href="#"><?php 
            _e('Select all', 'woocommerce');
            ?>
</a> <a class="select_none button" href="#"><?php 
            _e('Select none', 'woocommerce');
            ?>
</a> -->
				</td>
			</tr>

			<!-- Currency select -->			
			<tr valign="top">
				<th scope="row" class="titledesc">
					<label for="group_currency"><?php 
            _e('Currency', 'woocommerce');
            ?>
</label>
					<?php 
            //echo $tip;
            ?>
				</th>
				<td class="forminp forminp-select">
					<select name="group_currency" id="group_currency" class="chosen_select">
						<?php 
            foreach (get_woocommerce_currencies() as $code => $name) {
                echo '<option value="' . esc_attr($code) . '" ' . selected($group['currency'], $code) . '>' . $name . ' (' . get_woocommerce_currency_symbol($code) . ')' . '</option>';
            }
            ?>
					</select>
				</td>
			</tr>
			

			<!-- Exchange rate -->			
			<tr valign="top">
				<th scope="row" class="titledesc">
					<label for="exchange_rate"><?php 
            _e('Exchange Rate', 'wc-price-based-country');
            ?>
</label>
					<img class="help_tip" data-tip="<?php 
            echo esc_attr(__("For each product, if select autocalculate, product's price will be the result of multiplying the default price by this exchange rate.", 'wc-price-based-country'));
            ?>
" src="<?php 
            echo WC()->plugin_url();
            ?>
/assets/images/help.png" height="16" width="16" />
				</th>
                <td class="forminp forminp-text">                	
                	1 <?php 
            echo get_option('woocommerce_currency');
            ?>
 = <input name="exchange_rate" id="exchange_rate" type="text" class="short wc_input_decimal" value="<?php 
            echo wc_format_localized_decimal($group['exchange_rate']);
            ?>
"/> 
                	<?php 
            //echo $description;
            ?>
                </td>
			</tr>

		</table>

		<?php 
        }
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        global $post, $thepostid;
        wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce');
        $thepostid = $post->ID;
        if ($terms = wp_get_object_terms($post->ID, 'product_type')) {
            $product_type = sanitize_title(current($terms)->name);
        } else {
            $product_type = apply_filters('default_product_type', 'simple');
        }
        $product_type_selector = apply_filters('product_type_selector', array('simple' => __('Simple product', 'woocommerce'), 'grouped' => __('Grouped product', 'woocommerce'), 'external' => __('External/Affiliate product', 'woocommerce'), 'variable' => __('Variable product', 'woocommerce')), $product_type);
        $type_box = '<label for="product-type"><select id="product-type" name="product-type"><optgroup label="' . esc_attr__('Product Type', 'woocommerce') . '">';
        foreach ($product_type_selector as $value => $label) {
            $type_box .= '<option value="' . esc_attr($value) . '" ' . selected($product_type, $value, false) . '>' . esc_html($label) . '</option>';
        }
        $type_box .= '</optgroup></select></label>';
        $product_type_options = apply_filters('product_type_options', array());
        foreach ($product_type_options as $key => $option) {
            $selected_value = get_post_meta($post->ID, '_' . $key, true);
            if ('' == $selected_value && isset($option['default'])) {
                $selected_value = $option['default'];
            }
            $type_box .= '<label for="' . esc_attr($option['id']) . '" class="' . esc_attr($option['wrapper_class']) . ' tips" data-tip="' . esc_attr($option['description']) . '">' . esc_html($option['label']) . ': <input type="checkbox" name="' . esc_attr($option['id']) . '" id="' . esc_attr($option['id']) . '" ' . checked($selected_value, 'yes', false) . ' /></label>';
        }
        ?>
		<div class="panel-wrap product_data">

			<ul class="product_data_tabs wc-tabs" style="display:none;">
				<?php 
        $product_data_tabs = apply_filters('woocommerce_product_data_tabs', array('attribute' => array('label' => __('Attributes', 'woocommerce'), 'target' => 'product_attributes', 'class' => array())));
        foreach ($product_data_tabs as $key => $tab) {
            ?>
<li class="<?php 
            echo $key;
            ?>
_options <?php 
            echo $key;
            ?>
_tab <?php 
            echo implode(' ', $tab['class']);
            ?>
">
							<a href="#<?php 
            echo $tab['target'];
            ?>
"><?php 
            echo esc_html($tab['label']);
            ?>
</a>
						</li><?php 
        }
        do_action('woocommerce_product_write_panel_tabs');
        ?>
			</ul>

			<div id="inventory_product_data" class="panel woocommerce_options_panel">

				<?php 
        echo '<div class="options_group">';
        if ('yes' == get_option('woocommerce_manage_stock')) {
            // manage stock
            woocommerce_wp_checkbox(array('id' => '_manage_stock', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Manage stock?', 'woocommerce'), 'description' => __('Enable stock management at product level', 'woocommerce')));
            do_action('woocommerce_product_options_stock');
            echo '<div class="stock_fields show_if_simple show_if_variable">';
            // Stock
            woocommerce_wp_text_input(array('id' => '_stock', 'label' => __('Stock Qty', 'woocommerce'), 'desc_tip' => true, 'description' => __('Stock quantity. If this is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('step' => 'any'), 'data_type' => 'stock'));
            // Backorders?
            woocommerce_wp_select(array('id' => '_backorders', 'label' => __('Allow Backorders?', 'woocommerce'), 'options' => array('no' => __('Do not allow', 'woocommerce'), 'notify' => __('Allow, but notify customer', 'woocommerce'), 'yes' => __('Allow', 'woocommerce')), 'desc_tip' => true, 'description' => __('If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.', 'woocommerce')));
            do_action('woocommerce_product_options_stock_fields');
            echo '</div>';
        }
        // Stock status
        woocommerce_wp_select(array('id' => '_stock_status', 'wrapper_class' => 'hide_if_variable', 'label' => __('Stock status', 'woocommerce'), 'options' => array('instock' => __('In stock', 'woocommerce'), 'outofstock' => __('Out of stock', 'woocommerce')), 'desc_tip' => true, 'description' => __('Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce')));
        do_action('woocommerce_product_options_stock_status');
        echo '</div>';
        echo '<div class="options_group show_if_simple show_if_variable">';
        // Individual product
        woocommerce_wp_checkbox(array('id' => '_sold_individually', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Sold Individually', 'woocommerce'), 'description' => __('Enable this to only allow one of this item to be bought in a single order', 'woocommerce')));
        do_action('woocommerce_product_options_sold_individually');
        echo '</div>';
        do_action('woocommerce_product_options_inventory_product_data');
        ?>

			</div>

			<div id="shipping_product_data" class="panel woocommerce_options_panel">

				<?php 
        echo '<div class="options_group">';
        // Weight
        if (wc_product_weight_enabled()) {
            woocommerce_wp_text_input(array('id' => '_weight', 'label' => __('Weight', 'woocommerce') . ' (' . get_option('woocommerce_weight_unit') . ')', 'placeholder' => wc_format_localized_decimal(0), 'desc_tip' => 'true', 'description' => __('Weight in decimal form', 'woocommerce'), 'type' => 'text', 'data_type' => 'decimal'));
        }
        // Size fields
        if (wc_product_dimensions_enabled()) {
            ?>
<p class="form-field dimensions_field">
							<label for="product_length"><?php 
            echo __('Dimensions', 'woocommerce') . ' (' . get_option('woocommerce_dimension_unit') . ')';
            ?>
</label>
							<span class="wrap">
								<input id="product_length" placeholder="<?php 
            esc_attr_e('Length', 'woocommerce');
            ?>
" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_length', true)));
            ?>
" />
								<input placeholder="<?php 
            esc_attr_e('Width', 'woocommerce');
            ?>
" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_width', true)));
            ?>
" />
								<input placeholder="<?php 
            esc_attr_e('Height', 'woocommerce');
            ?>
" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_height', true)));
            ?>
" />
							</span>
							<img class="help_tip" data-tip="<?php 
            esc_attr_e('LxWxH in decimal form', 'woocommerce');
            ?>
" src="<?php 
            echo esc_url(WC()->plugin_url());
            ?>
/assets/images/help.png" height="16" width="16" />
						</p><?php 
        }
        do_action('woocommerce_product_options_dimensions');
        echo '</div>';
        echo '<div class="options_group">';
        // Shipping Class
        $classes = get_the_terms($thepostid, 'product_shipping_class');
        if ($classes && !is_wp_error($classes)) {
            $current_shipping_class = current($classes)->term_id;
        } else {
            $current_shipping_class = '';
        }
        $args = array('taxonomy' => 'product_shipping_class', 'hide_empty' => 0, 'show_option_none' => __('No shipping class', 'woocommerce'), 'name' => 'product_shipping_class', 'id' => 'product_shipping_class', 'selected' => $current_shipping_class, 'class' => 'select short');
        ?>
<p class="form-field dimensions_field"><label for="product_shipping_class"><?php 
        _e('Shipping class', 'woocommerce');
        ?>
</label> <?php 
        wp_dropdown_categories($args);
        ?>
 <img class="help_tip" data-tip="<?php 
        esc_attr_e('Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce');
        ?>
" src="<?php 
        echo esc_url(WC()->plugin_url());
        ?>
/assets/images/help.png" height="16" width="16" /></p><?php 
        do_action('woocommerce_product_options_shipping');
        echo '</div>';
        ?>

			</div>

			<div id="product_attributes" class="panel wc-metaboxes-wrapper">
				<div class="toolbar toolbar-top">
					<span class="expand-close">
						<a href="#" class="expand_all"><?php 
        _e('Разшири', 'woocommerce');
        ?>
</a> / <a href="#" class="close_all"><?php 
        _e('Затвори', 'woocommerce');
        ?>
</a>
					</span>
					<select name="attribute_taxonomy" class="attribute_taxonomy">
						<option value=""><?php 
        _e('Атрибут', 'woocommerce');
        ?>
</option>
						<?php 
        global $wc_product_attributes;
        // Array of defined attribute taxonomies
        $attribute_taxonomies = wc_get_attribute_taxonomies();
        if ($attribute_taxonomies) {
            foreach ($attribute_taxonomies as $tax) {
                $attribute_taxonomy_name = wc_attribute_taxonomy_name($tax->attribute_name);
                $label = $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name;
                echo '<option value="' . esc_attr($attribute_taxonomy_name) . '">' . esc_html($label) . '</option>';
            }
        }
        ?>
					</select>
					<button type="button" class="button add_attribute"><?php 
        _e('Add', 'woocommerce');
        ?>
</button>
				</div>
				<div class="product_attributes wc-metaboxes">
					<?php 
        // Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set
        $attributes = maybe_unserialize(get_post_meta($thepostid, '_product_attributes', true));
        // Output All Set Attributes
        if (!empty($attributes)) {
            $attribute_keys = array_keys($attributes);
            $attribute_total = sizeof($attribute_keys);
            for ($i = 0; $i < $attribute_total; $i++) {
                $attribute = $attributes[$attribute_keys[$i]];
                $position = empty($attribute['position']) ? 0 : absint($attribute['position']);
                $taxonomy = '';
                $metabox_class = array();
                if ($attribute['is_taxonomy']) {
                    $taxonomy = $attribute['name'];
                    if (!taxonomy_exists($taxonomy)) {
                        continue;
                    }
                    $attribute_taxonomy = $wc_product_attributes[$taxonomy];
                    $metabox_class[] = 'taxonomy';
                    $metabox_class[] = $taxonomy;
                    $attribute_label = wc_attribute_label($taxonomy);
                } else {
                    $attribute_label = apply_filters('woocommerce_attribute_label', $attribute['name'], $attribute['name']);
                }
                include 'views/html-product-attribute.php';
            }
        }
        ?>
				</div>
				<div class="toolbar">
					<span class="expand-close">
						<a href="#" class="expand_all"><?php 
        _e('Expand', 'woocommerce');
        ?>
</a> / <a href="#" class="close_all"><?php 
        _e('Close', 'woocommerce');
        ?>
</a>
					</span>
					<button type="button" class="button save_attributes button-primary"><?php 
        _e('Save Attributes', 'woocommerce');
        ?>
</button>
				</div>
				<?php 
        do_action('woocommerce_product_options_attributes');
        ?>
			</div>
			<div id="linked_product_data" class="panel woocommerce_options_panel">

				<div class="options_group">

					<p class="form-field">
						<label for="upsell_ids"><?php 
        _e('Up-Sells', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="upsell_ids" name="upsell_ids" data-placeholder="<?php 
        esc_attr_e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $product_ids = array_filter(array_map('absint', (array) get_post_meta($post->ID, '_upsell_ids', true)));
        $json_ids = array();
        foreach ($product_ids as $product_id) {
            $product = wc_get_product($product_id);
            if (is_object($product)) {
                $json_ids[$product_id] = wp_kses_post(html_entity_decode($product->get_formatted_name(), ENT_QUOTES, get_bloginfo('charset')));
            }
        }
        echo esc_attr(json_encode($json_ids));
        ?>
" value="<?php 
        echo implode(',', array_keys($json_ids));
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>

					<p class="form-field">
						<label for="crosssell_ids"><?php 
        _e('Cross-Sells', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="crosssell_ids" name="crosssell_ids" data-placeholder="<?php 
        esc_attr_e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $product_ids = array_filter(array_map('absint', (array) get_post_meta($post->ID, '_crosssell_ids', true)));
        $json_ids = array();
        foreach ($product_ids as $product_id) {
            $product = wc_get_product($product_id);
            if (is_object($product)) {
                $json_ids[$product_id] = wp_kses_post(html_entity_decode($product->get_formatted_name(), ENT_QUOTES, get_bloginfo('charset')));
            }
        }
        echo esc_attr(json_encode($json_ids));
        ?>
" value="<?php 
        echo implode(',', array_keys($json_ids));
        ?>
" /> <img class="help_tip" data-tip='<?php 
        esc_attr_e('Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>
				</div>

				<div class="options_group grouping show_if_simple show_if_external">

					<p class="form-field">
						<label for="parent_id"><?php 
        _e('Grouping', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="parent_id" name="parent_id" data-placeholder="<?php 
        esc_attr_e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_grouped_products" data-allow_clear="true" data-multiple="false" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $parent_id = absint($post->post_parent);
        if ($parent_id) {
            $parent = wc_get_product($parent_id);
            if (is_object($parent)) {
                $parent_title = wp_kses_post(html_entity_decode($parent->get_formatted_name(), ENT_QUOTES, get_bloginfo('charset')));
            }
            echo esc_attr($parent_title);
        }
        ?>
" value="<?php 
        echo $parent_id ? $parent_id : '';
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Set this option to make this product part of a grouped product.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>

					<?php 
        woocommerce_wp_hidden_input(array('id' => 'previous_parent_id', 'value' => absint($post->post_parent)));
        do_action('woocommerce_product_options_grouping');
        ?>
				</div>

				<?php 
        do_action('woocommerce_product_options_related');
        ?>
			</div>

			<div id="advanced_product_data" class="panel woocommerce_options_panel">

				<div class="options_group hide_if_external">
					<?php 
        // Purchase note
        woocommerce_wp_textarea_input(array('id' => '_purchase_note', 'label' => __('Purchase Note', 'woocommerce'), 'desc_tip' => 'true', 'description' => __('Enter an optional note to send the customer after purchase.', 'woocommerce')));
        ?>
				</div>

				<div class="options_group">
					<?php 
        // menu_order
        woocommerce_wp_text_input(array('id' => 'menu_order', 'label' => __('Menu order', 'woocommerce'), 'desc_tip' => 'true', 'description' => __('Custom ordering position.', 'woocommerce'), 'value' => intval($post->menu_order), 'type' => 'number', 'custom_attributes' => array('step' => '1')));
        ?>
				</div>

				<div class="options_group reviews">
					<?php 
        woocommerce_wp_checkbox(array('id' => 'comment_status', 'label' => __('Enable reviews', 'woocommerce'), 'cbvalue' => 'open', 'value' => esc_attr($post->comment_status)));
        do_action('woocommerce_product_options_reviews');
        ?>
				</div>

				<?php 
        do_action('woocommerce_product_options_advanced');
        ?>

			</div>

			<?php 
        self::output_variations();
        do_action('woocommerce_product_data_panels');
        do_action('woocommerce_product_write_panels');
        // _deprecated
        ?>

			<div class="clear"></div>

		</div>
		<?php 
    }
        $variation_data['variation_backorders'][0] = $_backorders;
        $variation_data['variation_taxclass'][0] = $_tax_class;
        $variation_data['variation_shippingclass'][0] = $shipping_class;
        $variation_data['variation_attributes'][0] = $filter_attributes;
        $variation_data['tax_class_options'][0] = $tax_class_options;
        $variation_data['variation_post_status'][0] = $variation_post_status;
        $variation_data['_downloadable_files'][0] = $_downloadable_files;
        $variation_data['placeholder_image'][0] = esc_url(wc_placeholder_img_src());
        $variation_data['post_id'][0] = $post_id;
        // Locale formatting
        $_regular_price = wc_format_localized_price($_regular_price);
        $_sale_price = wc_format_localized_price($_sale_price);
        $_weight = wc_format_localized_decimal($_weight);
        $_length = wc_format_localized_decimal($_length);
        $_width = wc_format_localized_decimal($_width);
        $_height = wc_format_localized_decimal($_height);
        // Stock BW compat
        if ('' !== $_stock) {
            $_manage_stock = 'yes';
        }
        ?>
            <tr data-variation_data='<?php 
        echo json_encode($variation_data);
        ?>
'>
            <?php 
        include 'variation-item.php';
        $loop++;
        ?>
            </tr>
            <?php 
    public function decimal_field($value)
    {
        $option_value = WC_Admin_Settings::get_option($value['id']);
        if (!empty($option_value)) {
            update_option($value['id'], wc_format_decimal($option_value));
        }
        if (empty($option_value)) {
            $option_value = $value['default'];
        }
        $value['class'] .= 'wc_input_decimal';
        if ($value['desc_tip']) {
            $value['desc_tip'] = $value['desc'];
        }
        ?>
		<tr valign="top">
			<th scope="row" class="titledesc">
				<label for="<?php 
        echo esc_attr($value['id']);
        ?>
"><?php 
        echo esc_html($value['title']);
        ?>
</label>
				<?php 
        if (!empty($value['desc_tip'])) {
            ?>
					<img class="help_tip" data-tip="<?php 
            echo esc_attr(wp_kses_post($value['desc_tip']));
            ?>
" src="<?php 
            echo WC()->plugin_url();
            ?>
/assets/images/help.png" height="16" width="16" />
				<?php 
        }
        ?>
			</th>
			<td class="forminp forminp-attachment wc-gzdp-attachment-wrapper">
				<input 
					id="<?php 
        echo esc_attr($value['id']);
        ?>
" 
					name="<?php 
        echo esc_attr($value['id']);
        ?>
" 
					type="text"
					style="<?php 
        echo esc_attr($value['css']);
        ?>
"
					value="<?php 
        echo wc_format_localized_decimal($option_value);
        ?>
"
					class="<?php 
        echo esc_attr($value['class']);
        ?>
"
				/>
				<div class="clear"></div>
				<?php 
        if ($value['desc'] && empty($value['desc_tip'])) {
            ?>
					<p class="description"><?php 
            echo wp_kses_post($value['desc']);
            ?>
</p>
				<?php 
        }
        ?>
			</td>
		</tr>
		<?php 
    }
    ?>
</span>
					<span class="input-text-wrap">
						<select class="change_weight change_to" name="change_weight">
						<?php 
    $options = array('' => __('— No Change —', 'woocommerce'), '1' => __('Change to:', 'woocommerce'));
    foreach ($options as $key => $value) {
        echo '<option value="' . esc_attr($key) . '">' . $value . '</option>';
    }
    ?>
						</select>
					</span>
				</label>
				<label class="change-input">
					<input type="text" name="_weight" class="text weight" placeholder="<?php 
    echo sprintf(__('%1$s (%2$s)', 'woocommerce'), wc_format_localized_decimal(0), get_option('woocommerce_weight_unit'));
    ?>
" value="">
				</label>
			</div>
		<?php 
}
?>

		<?php 
if (wc_product_dimensions_enabled()) {
    ?>
			<div class="inline-edit-group dimensions">
				<label class="alignleft">
					<span class="title"><?php 
    _e('L/W/H', 'woocommerce');
    /**
     * Generate Decimal Input HTML.
     *
     * @param  mixed $key
     * @param  mixed $data
     * @since  1.0.0
     * @return string
     */
    public function generate_decimal_html($key, $data)
    {
        $field = $this->get_field_key($key);
        $defaults = array('title' => '', 'disabled' => false, 'class' => '', 'css' => '', 'placeholder' => '', 'type' => 'text', 'desc_tip' => false, 'description' => '', 'custom_attributes' => array());
        $data = wp_parse_args($data, $defaults);
        ob_start();
        ?>
		<tr valign="top">
			<th scope="row" class="titledesc">
				<label for="<?php 
        echo esc_attr($field);
        ?>
"><?php 
        echo wp_kses_post($data['title']);
        ?>
</label>
				<?php 
        echo $this->get_tooltip_html($data);
        ?>
			</th>
			<td class="forminp">
				<fieldset>
					<legend class="screen-reader-text"><span><?php 
        echo wp_kses_post($data['title']);
        ?>
</span></legend>
					<input class="wc_input_decimal input-text regular-input <?php 
        echo esc_attr($data['class']);
        ?>
" type="text" name="<?php 
        echo esc_attr($field);
        ?>
" id="<?php 
        echo esc_attr($field);
        ?>
" style="<?php 
        echo esc_attr($data['css']);
        ?>
" value="<?php 
        echo esc_attr(wc_format_localized_decimal($this->get_option($key)));
        ?>
" placeholder="<?php 
        echo esc_attr($data['placeholder']);
        ?>
" <?php 
        disabled($data['disabled'], true);
        ?>
 <?php 
        echo $this->get_custom_attribute_html($data);
        ?>
 />
					<?php 
        echo $this->get_description_html($data);
        ?>
				</fieldset>
			</td>
		</tr>
		<?php 
        return ob_get_clean();
    }
function bf_wc_shipping($thepostid, $customfield)
{
    ?>
    <div id="shipping_product_data" class="hide_if_virtual hide_if_grouped hide_if_external">

    <?php 
    echo '<div class="options_group">';
    // Weight
    if (wc_product_weight_enabled()) {
        woocommerce_wp_text_input(array('id' => '_weight', 'label' => __('Weight', 'woocommerce') . ' (' . get_option('woocommerce_weight_unit') . ')<br>', 'placeholder' => wc_format_localized_decimal(0), 'desc_tip' => 'true', 'description' => __('Weight in decimal form', 'woocommerce'), 'type' => 'text', 'data_type' => 'decimal'));
    }
    // Size fields
    if (wc_product_dimensions_enabled()) {
        ?>
<p class="form-field dimensions_field">
        <label for="product_length"><?php 
        echo __('Dimensions', 'woocommerce') . ' (' . get_option('woocommerce_dimension_unit') . ')';
        ?>
</label><br>
							<span class="wrap">
								<input id="product_length" placeholder="<?php 
        _e('Length', 'woocommerce');
        ?>
" class="input-text wc_input_decimal dimensions_field" size="12" type="text" name="_length" value="<?php 
        echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_length', true)));
        ?>
" />
								<input placeholder="<?php 
        _e('Width', 'woocommerce');
        ?>
" class="input-text wc_input_decimal dimensions_field" size="12" type="text" name="_width" value="<?php 
        echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_width', true)));
        ?>
" />
								<input placeholder="<?php 
        _e('Height', 'woocommerce');
        ?>
" class="input-text wc_input_decimal last dimensions_field" size="12" type="text" name="_height" value="<?php 
        echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_height', true)));
        ?>
" />
							</span>
        <img class="help_tip" data-tip="<?php 
        esc_attr_e('LxWxH in decimal form', 'woocommerce');
        ?>
" src="<?php 
        echo esc_url(WC()->plugin_url());
        ?>
/assets/images/help.png" height="16" width="16" />
        </p><?php 
    }
    do_action('woocommerce_product_options_dimensions');
    echo '</div>';
    echo '<div class="options_group">';
    // Shipping Class
    $classes = get_the_terms($thepostid, 'product_shipping_class');
    if ($classes && !is_wp_error($classes)) {
        $current_shipping_class = current($classes)->term_id;
    } else {
        $current_shipping_class = '';
    }
    $args = array('taxonomy' => 'product_shipping_class', 'hide_empty' => 0, 'show_option_none' => __('No shipping class', 'woocommerce'), 'name' => 'product_shipping_class', 'id' => 'product_shipping_class', 'selected' => $current_shipping_class, 'class' => 'select short');
    ?>
<label for="product_shipping_class"><?php 
    _e('Shipping class', 'woocommerce');
    ?>
</label><p class="form-field dimensions_field"><?php 
    wp_dropdown_categories($args);
    ?>
 <img class="help_tip" data-tip="<?php 
    esc_attr_e('Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce');
    ?>
" src="<?php 
    echo esc_url(WC()->plugin_url());
    ?>
/assets/images/help.png" height="16" width="16" /></p><?php 
    do_action('woocommerce_product_options_shipping');
    echo '</div></div>';
}
		<?php 
    if ($product->has_weight()) {
        $has_row = true;
        ?>
			<tr class="<?php 
        if (($alt = $alt * -1) === 1) {
            echo 'alt';
        }
        ?>
">
				<th><?php 
        _e('Weight', 'woocommerce');
        ?>
</th>
				<td class="product_weight"><?php 
        echo wc_format_localized_decimal($product->get_weight()) . ' ' . esc_attr(get_option('woocommerce_weight_unit'));
        ?>
</td>
			</tr>
		<?php 
    }
    ?>

		<?php 
    if ($product->has_dimensions()) {
        $has_row = true;
        ?>
			<tr class="<?php 
        if (($alt = $alt * -1) === 1) {
            echo 'alt';
        }
    ?>
" class="input-text wc_input_decimal" size="6" type="text" name="variable_width[<?php 
    echo $loop;
    ?>
]" value="<?php 
    echo esc_attr(wc_format_localized_decimal($variation_object->get_width('edit')));
    ?>
" />
								<input placeholder="<?php 
    esc_attr_e('Height', 'woocommerce');
    ?>
" class="input-text wc_input_decimal last" size="6" type="text" name="variable_height[<?php 
    echo $loop;
    ?>
]" value="<?php 
    echo esc_attr(wc_format_localized_decimal($variation_object->get_height('edit')));
    ?>
" />
							</span>
						</p><?php 
}
/**
 * woocommerce_variation_options_dimensions action.
 *
 * @since 2.5.0
 *
 * @param int     $loop
 * @param array   $variation_data
 * @param WP_Post $variation
 */
do_action('woocommerce_variation_options_dimensions', $loop, $variation_data, $variation);
 /**
  * Initialise Gateway Settings Form Fields
  *
  * @access public
  * @return void
  */
 function init_form_fields()
 {
     $this->form_fields = array('enabled' => array('title' => __('Enable/Disable', 'woocommerce'), 'type' => 'checkbox', 'label' => __('Enable this shipping method', 'woocommerce'), 'default' => 'no'), 'title' => array('title' => __('Method Title', 'woocommerce'), 'type' => 'text', 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce'), 'default' => __('International Delivery', 'woocommerce'), 'desc_tip' => true), 'availability' => array('title' => __('Availability', 'woocommerce'), 'type' => 'select', 'description' => '', 'default' => 'including', 'options' => array('including' => __('Selected countries', 'woocommerce'), 'excluding' => __('Excluding selected countries', 'woocommerce'))), 'countries' => array('title' => __('Countries', 'woocommerce'), 'type' => 'multiselect', 'class' => 'chosen_select', 'css' => 'width: 450px;', 'default' => '', 'options' => WC()->countries->get_shipping_countries(), 'custom_attributes' => array('data-placeholder' => __('Select some countries', 'woocommerce'))), 'tax_status' => array('title' => __('Tax Status', 'woocommerce'), 'type' => 'select', 'default' => 'taxable', 'options' => array('taxable' => __('Taxable', 'woocommerce'), 'none' => __('None', 'woocommerce'))), 'type' => array('title' => __('Cost Added...', 'woocommerce'), 'type' => 'select', 'default' => 'order', 'options' => array('order' => __('Per Order - charge shipping for the entire order as a whole', 'woocommerce'), 'item' => __('Per Item - charge shipping for each item individually', 'woocommerce'), 'class' => __('Per Class - charge shipping for each shipping class in an order', 'woocommerce'))), 'cost' => array('title' => __('Cost', 'woocommerce'), 'type' => 'price', 'placeholder' => wc_format_localized_price(0), 'description' => __('Cost excluding tax. Enter an amount, e.g. 2.50. Default is 0', 'woocommerce'), 'default' => '', 'desc_tip' => true), 'fee' => array('title' => __('Handling Fee', 'woocommerce'), 'type' => 'text', 'description' => __('Fee excluding tax. Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woocommerce'), 'default' => '', 'desc_tip' => true, 'placeholder' => wc_format_localized_price(0)), 'minimum_fee' => array('title' => __('Minimum Handling Fee', 'woocommerce'), 'type' => 'decimal', 'description' => __('Enter a minimum fee amount. Fee\'s less than this will be increased. Leave blank to disable.', 'woocommerce'), 'default' => '', 'desc_tip' => true, 'placeholder' => wc_format_localized_decimal('0')));
 }
    function render_admin_field($field)
    {
        ob_start();
        $field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
        $field['value'] = isset($field['value']) ? $field['value'] : get_post_meta($thepostid, $field['id'], true);
        $field['name'] = isset($field['name']) ? $field['name'] : $field['id'];
        $field['value_type'] = isset($field['value_type']) ? $field['value_type'] : 'text';
        $field['class'] = isset($field['class']) ? $field['class'] : '';
        $data_type = empty($field['data_type']) ? '' : $field['data_type'];
        switch ($data_type) {
            case 'price':
                $field['class'] = ' wc_input_price';
                $field['value'] = wc_format_localized_price($field['value']);
                break;
            case 'decimal':
                $field['class'] = ' wc_input_decimal';
                $field['value'] = wc_format_localized_decimal($field['value']);
                break;
            case 'stock':
                $field['class'] = ' wc_input_stock';
                $field['value'] = wc_stock_amount($field['value']);
                break;
            case 'url':
                $field['class'] = ' wc_input_url';
                $field['value'] = esc_url($field['value']);
                break;
            default:
                break;
        }
        if ($field["location"] != "product_cat_add_form_fields" && $field["location"] != "product_cat_edit_form_fields") {
            ?>

		<p class="form-field <?php 
            echo esc_attr($field['name']);
            ?>
_field ">
			<label for="<?php 
            echo esc_attr($field['name']);
            ?>
"><?php 
            echo wp_kses_post($field['label']);
            echo isset($field["required"]) && $field["required"] == "yes" ? ' <span>*</span>' : '';
            ?>
</label>
			<input type="text" class="wccaf-field <?php 
            echo esc_attr($field['class']);
            ?>
" name="<?php 
            echo esc_attr($field['name']);
            ?>
" id="<?php 
            echo esc_attr($field['name']);
            ?>
" value="<?php 
            echo esc_attr($field['value']);
            ?>
" placeholder="<?php 
            echo esc_attr($field['placeholder']);
            ?>
" wccaf-type="text" wccaf-pattern="mandatory" wccaf-mandatory="<?php 
            echo $field["required"];
            ?>
" />
			<?php 
            if (!empty($field['description'])) {
                if (isset($field['desc_tip']) && "no" != $field['desc_tip']) {
                    ?>
					<img class="help_tip" data-tip="<?php 
                    echo wp_kses_post($field['description']);
                    ?>
" src="<?php 
                    echo esc_url(wcff()->info["dir"]);
                    ?>
/assets/images/help.png" height="16" width="16" />
				<?php 
                } else {
                    ?>
					<span class="description"><?php 
                    echo wp_kses_post($field['description']);
                    ?>
</span>
			<?php 
                }
            }
            ?>
	
			<span class="wccaf-validation-message wccaf-is-valid-<?php 
            echo $this->valid;
            ?>
"><?php 
            echo $field["message"];
            ?>
</span>
		</p>
		
		<?php 
        } else {
            if ($field["location"] == "product_cat_add_form_fields") {
                ?>
	
		<div class="form-field">
			<label for="<?php 
                echo esc_attr($field['name']);
                ?>
"><?php 
                echo wp_kses_post($field['label']);
                echo isset($field["required"]) && $field["required"] == "yes" ? ' <span>*</span>' : '';
                ?>
</label>
			<input type="text" class="wccaf-field <?php 
                echo esc_attr($field['class']);
                ?>
" name="<?php 
                echo esc_attr($field['name']);
                ?>
" id="<?php 
                echo esc_attr($field['name']);
                ?>
" value="<?php 
                echo esc_attr($field['value']);
                ?>
" placeholder="<?php 
                echo esc_attr($field['placeholder']);
                ?>
" wccaf-type="text" wccaf-pattern="mandatory" wccaf-mandatory="<?php 
                echo $field["required"];
                ?>
" />
			<p class="description"><?php 
                echo wp_kses_post($field['description']);
                ?>
</p>
			<span class="wccaf-validation-message wccaf-is-valid-<?php 
                echo $this->valid;
                ?>
"><?php 
                echo $field["message"];
                ?>
</span>
		</div>
			
		<?php 
            } else {
                if ($field["location"] == "product_cat_edit_form_fields") {
                    ?>
		
		<tr class="form-field">
			<th scope="row" valign="top"><label for="<?php 
                    echo esc_attr($field['name']);
                    ?>
"><?php 
                    echo wp_kses_post($field['label']);
                    echo isset($field["required"]) && $field["required"] == "yes" ? ' <span>*</span>' : '';
                    ?>
</label></th>
			<td>
				<input type="text" class="wccaf-field <?php 
                    echo esc_attr($field['class']);
                    ?>
" name="<?php 
                    echo esc_attr($field['name']);
                    ?>
" id="<?php 
                    echo esc_attr($field['name']);
                    ?>
" value="<?php 
                    echo esc_attr($field['value']);
                    ?>
" placeholder="<?php 
                    echo esc_attr($field['placeholder']);
                    ?>
" wccaf-type="text" wccaf-pattern="mandatory" wccaf-mandatory="<?php 
                    echo $field["required"];
                    ?>
" />
				<p class="description"><?php 
                    echo wp_kses_post($field['description']);
                    ?>
</p>
				<span class="wccaf-validation-message wccaf-is-valid-<?php 
                    echo $this->valid;
                    ?>
"><?php 
                    echo $field["message"];
                    ?>
</span>
			</td>
		</tr>
		
		<?php 
                }
            }
        }
        return ob_get_clean();
    }
    /**
     * Show options for the variable product type
     */
    public static function output_variations()
    {
        global $post;
        $attributes = maybe_unserialize(get_post_meta($post->ID, '_product_attributes', true));
        // See if any are set
        $variation_attribute_found = false;
        if ($attributes) {
            foreach ($attributes as $attribute) {
                if (isset($attribute['is_variation'])) {
                    $variation_attribute_found = true;
                    break;
                }
            }
        }
        // Get tax classes
        $tax_classes = WC_Tax::get_tax_classes();
        $tax_class_options = array();
        $tax_class_options[''] = __('Standard', 'woocommerce');
        if ($tax_classes) {
            foreach ($tax_classes as $class) {
                $tax_class_options[sanitize_title($class)] = esc_attr($class);
            }
        }
        $backorder_options = array('no' => __('Do not allow', 'woocommerce'), 'notify' => __('Allow, but notify customer', 'woocommerce'), 'yes' => __('Allow', 'woocommerce'));
        $stock_status_options = array('instock' => __('In stock', 'woocommerce'), 'outofstock' => __('Out of stock', 'woocommerce'));
        ?>
		<div id="variable_product_options" class="panel wc-metaboxes-wrapper"><div id="variable_product_options_inner">

			<?php 
        if (!$variation_attribute_found) {
            ?>

				<div id="message" class="inline woocommerce-message">
					<p><?php 
            _e('Before adding variations, add and save some attributes on the <strong>Attributes</strong> tab.', 'woocommerce');
            ?>
</p>

					<p class="submit"><a class="button-primary" href="<?php 
            echo esc_url(apply_filters('woocommerce_docs_url', 'http://docs.woothemes.com/document/variable-product/', 'product-variations'));
            ?>
" target="_blank"><?php 
            _e('Learn more', 'woocommerce');
            ?>
</a></p>
				</div>

			<?php 
        } else {
            ?>

				<p class="toolbar">
					<a href="#" class="close_all"><?php 
            _e('Close all', 'woocommerce');
            ?>
</a><a href="#" class="expand_all"><?php 
            _e('Expand all', 'woocommerce');
            ?>
</a>
					<select id="field_to_edit">
						<option value=""><?php 
            _e('Choose a field to bulk edit&hellip;', 'woocommerce');
            ?>
</option>
						<optgroup label="<?php 
            esc_attr_e('Status', 'woocommerce');
            ?>
">
							<option value="toggle_enabled"><?php 
            _e('Toggle &quot;Enabled&quot;', 'woocommerce');
            ?>
</option>
							<option value="toggle_downloadable"><?php 
            _e('Toggle &quot;Downloadable&quot;', 'woocommerce');
            ?>
</option>
							<option value="toggle_virtual"><?php 
            _e('Toggle &quot;Virtual&quot;', 'woocommerce');
            ?>
</option>
							<option value="delete_all"><?php 
            _e('Delete all variations', 'woocommerce');
            ?>
</option>
						</optgroup>
						<optgroup label="<?php 
            esc_attr_e('Pricing', 'woocommerce');
            ?>
">
							<option value="variable_regular_price"><?php 
            _e('Prices', 'woocommerce');
            ?>
</option>
							<option value="variable_regular_price_increase"><?php 
            _e('Prices increase by (fixed amount or %)', 'woocommerce');
            ?>
</option>
							<option value="variable_regular_price_decrease"><?php 
            _e('Prices decrease by (fixed amount or %)', 'woocommerce');
            ?>
</option>
							<option value="variable_sale_price"><?php 
            _e('Sale prices', 'woocommerce');
            ?>
</option>
							<option value="variable_sale_price_increase"><?php 
            _e('Sale prices increase by (fixed amount or %)', 'woocommerce');
            ?>
</option>
							<option value="variable_sale_price_decrease"><?php 
            _e('Sale prices decrease by (fixed amount or %)', 'woocommerce');
            ?>
</option>
							<option value="variable_sale_schedule"><?php 
            _e('Scheduled sale dates', 'woocommerce');
            ?>
</option>
						</optgroup>
						<optgroup label="<?php 
            esc_attr_e('Inventory', 'woocommerce');
            ?>
">
							<option value="toggle_manage_stock"><?php 
            _e('Toggle &quot;Manage stock&quot;', 'woocommerce');
            ?>
</option>
							<option value="variable_stock"><?php 
            _e('Stock', 'woocommerce');
            ?>
</option>
						</optgroup>
						<optgroup label="<?php 
            esc_attr_e('Shipping', 'woocommerce');
            ?>
">
							<option value="variable_length"><?php 
            _e('Length', 'woocommerce');
            ?>
</option>
							<option value="variable_width"><?php 
            _e('Width', 'woocommerce');
            ?>
</option>
							<option value="variable_height"><?php 
            _e('Height', 'woocommerce');
            ?>
</option>
							<option value="variable_weight"><?php 
            _e('Weight', 'woocommerce');
            ?>
</option>
						</optgroup>
						<optgroup label="<?php 
            esc_attr_e('Downloadable products', 'woocommerce');
            ?>
">
							<option value="variable_download_limit"><?php 
            _e('Download limit', 'woocommerce');
            ?>
</option>
							<option value="variable_download_expiry"><?php 
            _e('Download Expiry', 'woocommerce');
            ?>
</option>
						</optgroup>
						<?php 
            do_action('woocommerce_variable_product_bulk_edit_actions');
            ?>
					</select>
					<a class="button bulk_edit"><?php 
            _e('Go', 'woocommerce');
            ?>
</a>
				</p>

				<div class="woocommerce_variations wc-metaboxes">
					<?php 
            // Get parent data
            $parent_data = array('id' => $post->ID, 'attributes' => $attributes, 'tax_class_options' => $tax_class_options, 'sku' => get_post_meta($post->ID, '_sku', true), 'weight' => wc_format_localized_decimal(get_post_meta($post->ID, '_weight', true)), 'length' => wc_format_localized_decimal(get_post_meta($post->ID, '_length', true)), 'width' => wc_format_localized_decimal(get_post_meta($post->ID, '_width', true)), 'height' => wc_format_localized_decimal(get_post_meta($post->ID, '_height', true)), 'tax_class' => get_post_meta($post->ID, '_tax_class', true), 'backorder_options' => $backorder_options, 'stock_status_options' => $stock_status_options);
            if (!$parent_data['weight']) {
                $parent_data['weight'] = wc_format_localized_decimal(0);
            }
            if (!$parent_data['length']) {
                $parent_data['length'] = wc_format_localized_decimal(0);
            }
            if (!$parent_data['width']) {
                $parent_data['width'] = wc_format_localized_decimal(0);
            }
            if (!$parent_data['height']) {
                $parent_data['height'] = wc_format_localized_decimal(0);
            }
            // Get variations
            $args = array('post_type' => 'product_variation', 'post_status' => array('private', 'publish'), 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'asc', 'post_parent' => $post->ID);
            $variations = get_posts($args);
            $loop = 0;
            if ($variations) {
                foreach ($variations as $variation) {
                    $variation_id = absint($variation->ID);
                    $variation_meta = get_post_meta($variation_id);
                    $variation_data = array();
                    $shipping_classes = get_the_terms($variation_id, 'product_shipping_class');
                    $variation_fields = array('_sku' => '', '_stock' => '', '_regular_price' => '', '_sale_price' => '', '_weight' => '', '_length' => '', '_width' => '', '_height' => '', '_download_limit' => '', '_download_expiry' => '', '_downloadable_files' => '', '_downloadable' => '', '_virtual' => '', '_thumbnail_id' => '', '_sale_price_dates_from' => '', '_sale_price_dates_to' => '', '_manage_stock' => '', '_stock_status' => '', '_backorders' => null, '_tax_class' => null);
                    foreach ($variation_fields as $field => $value) {
                        $variation_data[$field] = isset($variation_meta[$field][0]) ? maybe_unserialize($variation_meta[$field][0]) : $value;
                    }
                    // Add the variation attributes
                    foreach ($variation_meta as $key => $value) {
                        if (false !== strpos($key, 'attribute_')) {
                            $variation_data[$key] = $value;
                        }
                    }
                    // Formatting
                    $variation_data['_regular_price'] = wc_format_localized_price($variation_data['_regular_price']);
                    $variation_data['_sale_price'] = wc_format_localized_price($variation_data['_sale_price']);
                    $variation_data['_weight'] = wc_format_localized_decimal($variation_data['_weight']);
                    $variation_data['_length'] = wc_format_localized_decimal($variation_data['_length']);
                    $variation_data['_width'] = wc_format_localized_decimal($variation_data['_width']);
                    $variation_data['_height'] = wc_format_localized_decimal($variation_data['_height']);
                    $variation_data['_thumbnail_id'] = absint($variation_data['_thumbnail_id']);
                    $variation_data['image'] = $variation_data['_thumbnail_id'] ? wp_get_attachment_thumb_url($variation_data['_thumbnail_id']) : '';
                    $variation_data['shipping_class'] = $shipping_classes && !is_wp_error($shipping_classes) ? current($shipping_classes)->term_id : '';
                    // Stock BW compat
                    if ('' !== $variation_data['_stock']) {
                        $variation_data['_manage_stock'] = 'yes';
                    }
                    include 'views/html-variation-admin.php';
                    $loop++;
                }
            }
            ?>
				</div>

				<p class="toolbar">

					<button type="button" class="button button-primary add_variation" <?php 
            disabled($variation_attribute_found, false);
            ?>
><?php 
            _e('Add Variation', 'woocommerce');
            ?>
</button>

					<button type="button" class="button link_all_variations" <?php 
            disabled($variation_attribute_found, false);
            ?>
><?php 
            _e('Link all variations', 'woocommerce');
            ?>
</button>

					<strong><?php 
            _e('Defaults', 'woocommerce');
            ?>
: <span class="tips" data-tip="<?php 
            _e('These are the attributes that will be pre-selected on the frontend.', 'woocommerce');
            ?>
">[?]</span></strong>
					<?php 
            $default_attributes = maybe_unserialize(get_post_meta($post->ID, '_default_attributes', true));
            foreach ($attributes as $attribute) {
                // Only deal with attributes that are variations
                if (!$attribute['is_variation']) {
                    continue;
                }
                // Get current value for variation (if set)
                $variation_selected_value = isset($default_attributes[sanitize_title($attribute['name'])]) ? $default_attributes[sanitize_title($attribute['name'])] : '';
                // Name will be something like attribute_pa_color
                echo '<select name="default_attribute_' . sanitize_title($attribute['name']) . '"><option value="">' . __('No default', 'woocommerce') . ' ' . esc_html(wc_attribute_label($attribute['name'])) . '&hellip;</option>';
                // Get terms for attribute taxonomy or value if its a custom attribute
                if ($attribute['is_taxonomy']) {
                    $post_terms = wp_get_post_terms($post->ID, $attribute['name']);
                    foreach ($post_terms as $term) {
                        echo '<option ' . selected($variation_selected_value, $term->slug, false) . ' value="' . esc_attr($term->slug) . '">' . apply_filters('woocommerce_variation_option_name', esc_html($term->name)) . '</option>';
                    }
                } else {
                    $options = array_map('trim', explode(WC_DELIMITER, $attribute['value']));
                    foreach ($options as $option) {
                        echo '<option ' . selected(sanitize_title($variation_selected_value), sanitize_title($option), false) . ' value="' . esc_attr(sanitize_title($option)) . '">' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . '</option>';
                    }
                }
                echo '</select>';
            }
            ?>
				</p>

			<?php 
        }
        ?>
		</div></div>
		<?php 
    }
Exemple #24
0
/**
 * Show the variable product options.
 *
 * @access public
 * @return void
 */
function dokan_variable_product_type_options()
{
    global $post, $woocommerce;
    $data = array();
    $attributes = maybe_unserialize(get_post_meta($post->ID, '_product_attributes', true));
    // See if any are set
    $variation_attribute_found = false;
    if ($attributes) {
        foreach ($attributes as $attribute) {
            if (isset($attribute['is_variation'])) {
                $variation_attribute_found = true;
                break;
            }
        }
    }
    // Get tax classes
    $tax_classes = array_filter(array_map('trim', explode("\n", get_option('woocommerce_tax_classes'))));
    $tax_class_options = array();
    $tax_class_options[''] = __('Standard', 'woocommerce');
    if ($tax_classes) {
        foreach ($tax_classes as $class) {
            $tax_class_options[sanitize_title($class)] = esc_attr($class);
        }
    }
    // var_dump( $attributes, $tax_classes, $tax_class_options );
    ?>
    <div id="variable_product_options" class="wc-metaboxes-wrapper">
        <div id="variable_product_options_inner">

        <?php 
    if (!$variation_attribute_found) {
        ?>

            <div id="message" class="inline woocommerce-message">
                <div class="squeezer">
                    <h4><?php 
        _e('Before adding variations, add and save some attributes on the <strong>Attributes</strong> tab.', 'woocommerce');
        ?>
</h4>

                    <p class="submit"><a class="button-primary" href="http://docs.woothemes.com/document/product-variations/" target="_blank"><?php 
        _e('Learn more', 'woocommerce');
        ?>
</a></p>
                </div>
            </div>

        <?php 
    } else {
        ?>

            <div class="woocommerce_variations wc-metaboxes">
                <?php 
        // Get parent data
        $parent_data = array('id' => $post->ID, 'attributes' => $attributes, 'tax_class_options' => $tax_class_options, 'sku' => get_post_meta($post->ID, '_sku', true), 'weight' => get_post_meta($post->ID, '_weight', true), 'length' => get_post_meta($post->ID, '_length', true), 'width' => get_post_meta($post->ID, '_width', true), 'height' => get_post_meta($post->ID, '_height', true), 'tax_class' => get_post_meta($post->ID, '_tax_class', true));
        if (!$parent_data['weight']) {
            $parent_data['weight'] = '0.00';
        }
        if (!$parent_data['length']) {
            $parent_data['length'] = '0';
        }
        if (!$parent_data['width']) {
            $parent_data['width'] = '0';
        }
        if (!$parent_data['height']) {
            $parent_data['height'] = '0';
        }
        // Get variations
        $args = array('post_type' => 'product_variation', 'post_status' => array('private', 'publish'), 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'asc', 'post_parent' => $post->ID);
        $variations = get_posts($args);
        $loop = 0;
        // var_dump( $variations );
        if ($variations) {
            foreach ($variations as $variation) {
                $variation_id = absint($variation->ID);
                $variation_post_status = esc_attr($variation->post_status);
                $variation_data = get_post_meta($variation_id);
                $variation_data['variation_post_id'] = $variation_id;
                // Grab shipping classes
                $shipping_classes = get_the_terms($variation_id, 'product_shipping_class');
                $shipping_class = $shipping_classes && !is_wp_error($shipping_classes) ? current($shipping_classes)->term_id : '';
                $variation_fields = array('_sku', '_stock', '_list_price_mrp', '_regular_price', '_sale_price', '_weight', '_length', '_width', '_height', '_download_limit', '_download_expiry', '_downloadable_files', '_downloadable', '_virtual', '_thumbnail_id', '_sale_price_dates_from', '_sale_price_dates_to');
                foreach ($variation_fields as $field) {
                    ${$field} = isset($variation_data[$field][0]) ? maybe_unserialize($variation_data[$field][0]) : '';
                }
                $_tax_class = isset($variation_data['_tax_class'][0]) ? $variation_data['_tax_class'][0] : null;
                $image_id = absint($_thumbnail_id);
                $image = $image_id ? wp_get_attachment_thumb_url($image_id) : '';
                // Locale formatting
                $_regular_price = wc_format_localized_price($_regular_price);
                $_sale_price = wc_format_localized_price($_sale_price);
                $_weight = wc_format_localized_decimal($_weight);
                $_length = wc_format_localized_decimal($_length);
                $_width = wc_format_localized_decimal($_width);
                $_height = wc_format_localized_decimal($_height);
                include DOKAN_INC_DIR . '/woo-views/variation-admin-html.php';
                $loop++;
            }
        }
        ?>
            </div> <!-- .woocommerce_variations -->

            <p class="toolbar">

                <button type="button" class="btn btn-sm btn-success button-primary add_variation" <?php 
        disabled($variation_attribute_found, false);
        ?>
><?php 
        _e('Add Variation', 'woocommerce');
        ?>
</button>

                <button type="button" class="btn btn-sm btn-default link_all_variations" <?php 
        disabled($variation_attribute_found, false);
        ?>
><?php 
        _e('Link all variations', 'woocommerce');
        ?>
</button>

                <strong><?php 
        _e('Default selections:', 'woocommerce');
        ?>
</strong>
                <?php 
        $default_attributes = maybe_unserialize(get_post_meta($post->ID, '_default_attributes', true));
        foreach ($attributes as $attribute) {
            // Only deal with attributes that are variations
            if (!$attribute['is_variation']) {
                continue;
            }
            // Get current value for variation (if set)
            $variation_selected_value = isset($default_attributes[sanitize_title($attribute['name'])]) ? $default_attributes[sanitize_title($attribute['name'])] : '';
            // Name will be something like attribute_pa_color
            echo '<select name="default_attribute_' . sanitize_title($attribute['name']) . '"><option value="">' . __('No default', 'woocommerce') . ' ' . esc_html(wc_attribute_label($attribute['name'])) . '&hellip;</option>';
            // Get terms for attribute taxonomy or value if its a custom attribute
            if ($attribute['is_taxonomy']) {
                $post_terms = wp_get_post_terms($post->ID, $attribute['name']);
                foreach ($post_terms as $term) {
                    echo '<option ' . selected($variation_selected_value, $term->slug, false) . ' value="' . esc_attr($term->slug) . '">' . apply_filters('woocommerce_variation_option_name', esc_html($term->name)) . '</option>';
                }
            } else {
                $options = array_map('trim', explode('|', $attribute['value']));
                foreach ($options as $option) {
                    echo '<option ' . selected(sanitize_title($variation_selected_value), sanitize_title($option), false) . ' value="' . esc_attr(sanitize_title($option)) . '">' . esc_html(apply_filters('woocommerce_variation_option_name', $option)) . '</option>';
                }
            }
            echo '</select>';
        }
        ?>
            </p> <!-- .toolbar -->

        <?php 
    }
    ?>
    </div>
</div>
    <?php 
    /**
     * Product Type Javascript
     */
    ob_start();
    ?>
    jQuery(function($){

        var variation_sortable_options = {
            items:'.woocommerce_variation',
            cursor:'move',
            axis:'y',
            handle: 'h3',
            scrollSensitivity:40,
            forcePlaceholderSize: true,
            helper: 'clone',
            opacity: 0.65,
            placeholder: 'wc-metabox-sortable-placeholder',
            start:function(event,ui){
                ui.item.css('background-color','#f6f6f6');
            },
            stop:function(event,ui){
                ui.item.removeAttr('style');
                variation_row_indexes();
            }
        };

        // Add a variation
        jQuery('#variable_product_options').on('click', 'button.add_variation', function(){

            jQuery('.woocommerce_variations').block({ message: null, overlayCSS: { background: '#fff url(<?php 
    echo $woocommerce->plugin_url();
    ?>
/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });

            var loop = jQuery('.woocommerce_variation').size();

            var data = {
                action: 'dokan_add_variation',
                post_id: <?php 
    echo $post->ID;
    ?>
,
                loop: loop,
                security: '<?php 
    echo wp_create_nonce("add-variation");
    ?>
'
            };

            jQuery.post('<?php 
    echo admin_url('admin-ajax.php');
    ?>
', data, function(response) {

                jQuery('.woocommerce_variations').append( response );
                jQuery(".tips").tooltip();

                jQuery('input.variable_is_downloadable, input.variable_is_virtual').change();

                jQuery('.woocommerce_variations').unblock();
                jQuery('#variable_product_options').trigger('woocommerce_variations_added');
            });

            return false;

        });

        jQuery('#variable_product_options').on('click', 'button.link_all_variations', function(){

            var answer = confirm('<?php 
    echo esc_js(__('Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max 50 per run).', 'woocommerce'));
    ?>
');

            if (answer) {

                jQuery('#variable_product_options').block({ message: null, overlayCSS: { background: '#fff url(<?php 
    echo $woocommerce->plugin_url();
    ?>
/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });

                var data = {
                    action: 'dokan_link_all_variations',
                    post_id: <?php 
    echo $post->ID;
    ?>
,
                    security: '<?php 
    echo wp_create_nonce("link-variations");
    ?>
'
                };

                jQuery.post('<?php 
    echo admin_url('admin-ajax.php');
    ?>
', data, function(response) {

                    var count = parseInt( response );

                    if (count==1) {
                        alert( count + ' <?php 
    echo esc_js(__("variation added", 'dokan'));
    ?>
');
                    } else if (count==0 || count>1) {
                        alert( count + ' <?php 
    echo esc_js(__("variations added", 'dokan'));
    ?>
');
                    } else {
                        alert('<?php 
    echo esc_js(__("No variations added", 'dokan'));
    ?>
');
                    }

                    if (count>0) {
                        var this_page = window.location.toString();

                        this_page = this_page.replace( 'post-new.php?', 'post.php?post=<?php 
    echo $post->ID;
    ?>
&action=edit&' );

                        $('#variable_product_options').load( this_page + ' #variable_product_options_inner', function() {
                            $('#variable_product_options').unblock();
                            jQuery('#variable_product_options').trigger('woocommerce_variations_added');
                        } );
                    } else {
                        $('#variable_product_options').unblock();
                    }

                });
            }
            return false;
        });

        jQuery('#variable_product_options').on('click', 'button.remove_variation', function(e){
            e.preventDefault();
            var answer = confirm('<?php 
    echo esc_js(__('Are you sure you want to remove this variation?', 'dokan'));
    ?>
');
            if (answer){

                var el = jQuery(this).parent().parent();

                var variation = jQuery(this).attr('rel');

                if (variation>0) {

                    jQuery(el).block({ message: null, overlayCSS: { background: '#fff url(<?php 
    echo $woocommerce->plugin_url();
    ?>
/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });

                    var data = {
                        action: 'woocommerce_remove_variation',
                        variation_id: variation,
                        security: '<?php 
    echo wp_create_nonce("delete-variation");
    ?>
'
                    };

                    jQuery.post('<?php 
    echo admin_url('admin-ajax.php');
    ?>
', data, function(response) {
                        // Success
                        jQuery(el).fadeOut('300', function(){
                            jQuery(el).remove();
                        });
                    });

                } else {
                    jQuery(el).fadeOut('300', function(){
                        jQuery(el).remove();
                    });
                }

            }
            return false;
        });

        jQuery('#variable_product_options').on('change', 'input.variable_is_downloadable', function(){

            jQuery(this).closest('.woocommerce_variation').find('.show_if_variation_downloadable').hide();

            if (jQuery(this).is(':checked')) {
                jQuery(this).closest('.woocommerce_variation').find('.show_if_variation_downloadable').show();
            }

        });

        jQuery('#variable_product_options').on('change', 'input.variable_is_virtual', function(){

            jQuery(this).closest('.woocommerce_variation').find('.hide_if_variation_virtual').show();

            if (jQuery(this).is(':checked')) {
                jQuery(this).closest('.woocommerce_variation').find('.hide_if_variation_virtual').hide();
            }

        });

        jQuery('input.variable_is_downloadable, input.variable_is_virtual').change();

        // Ordering
        $('#variable_product_options').on( 'woocommerce_variations_added', function() {
            $('.woocommerce_variations').sortable( variation_sortable_options );
        } );

        $('.woocommerce_variations').sortable( variation_sortable_options );

        function variation_row_indexes() {
            $('.woocommerce_variations .woocommerce_variation').each(function(index, el){
                $('.variation_menu_order', el).val( parseInt( $(el).index('.woocommerce_variations .woocommerce_variation') ) );
            });
        };

        // Uploader
        var variable_image_frame;
        var setting_variation_image_id;
        var setting_variation_image;
        var wp_media_post_id = wp.media.model.settings.post.id;

        wp.media.view.settings.post = <?php 
    echo json_encode(array('param' => 'dokan', 'post_id' => $post->ID));
    // big juicy hack.
    ?>
;

        jQuery('#variable_product_options').on('click', '.upload_image_button', function( event ) {

            console.log('choose file');

            var $button                = jQuery( this );
            var post_id                = $button.attr('rel');
            var $parent                = $button.closest('.upload_image');
            setting_variation_image    = $parent;
            setting_variation_image_id = post_id;

            event.preventDefault();

            if ( $button.is('.remove') ) {

                setting_variation_image.find( '.upload_image_id' ).val( '' );
                setting_variation_image.find( 'img' ).attr( 'src', '<?php 
    echo woocommerce_placeholder_img_src();
    ?>
' );
                setting_variation_image.find( '.upload_image_button' ).removeClass( 'remove' );

            } else {

                // If the media frame already exists, reopen it.
                if ( variable_image_frame ) {
                    variable_image_frame.uploader.uploader.param( 'post_id', setting_variation_image_id );
                    variable_image_frame.open();
                    return;
                } else {
                    wp.media.model.settings.post.id = setting_variation_image_id;
                    wp.media.model.settings.type = 'dokan';
                }

                // Create the media frame.
                variable_image_frame = wp.media.frames.variable_image = wp.media({
                    // Set the title of the modal.
                    title: '<?php 
    echo esc_js(__('Choose an image', 'woocommerce'));
    ?>
',
                    button: {
                        text: '<?php 
    echo esc_js(__('Set variation image', 'woocommerce'));
    ?>
'
                    }
                });

                // When an image is selected, run a callback.
                variable_image_frame.on( 'select', function() {

                    attachment = variable_image_frame.state().get('selection').first().toJSON();

                    setting_variation_image.find( '.upload_image_id' ).val( attachment.id );
                    setting_variation_image.find( '.upload_image_button' ).addClass( 'remove' );
                    setting_variation_image.find( 'img' ).attr( 'src', attachment.url );

                    wp.media.model.settings.post.id = wp_media_post_id;
                });

                // Finally, open the modal.
                variable_image_frame.open();
            }
        });

        // Restore ID
        jQuery('a.add_media').on('click', function() {
            wp.media.model.settings.post.id = wp_media_post_id;
        } );

    });
    <?php 
    $javascript = ob_get_clean();
    wc_enqueue_js($javascript);
}
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        global $post, $thepostid;
        wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce');
        $thepostid = $post->ID;
        if ($terms = wp_get_object_terms($post->ID, 'product_type')) {
            $product_type = sanitize_title(current($terms)->name);
        } else {
            $product_type = apply_filters('default_product_type', 'simple');
        }
        $product_type_selector = apply_filters('product_type_selector', array('simple' => __('Simple product', 'woocommerce'), 'grouped' => __('Grouped product', 'woocommerce'), 'external' => __('External/Affiliate product', 'woocommerce'), 'variable' => __('Variable product', 'woocommerce')), $product_type);
        $type_box = '<label for="product-type"><select id="product-type" name="product-type"><optgroup label="' . __('Product Type', 'woocommerce') . '">';
        foreach ($product_type_selector as $value => $label) {
            $type_box .= '<option value="' . esc_attr($value) . '" ' . selected($product_type, $value, false) . '>' . esc_html($label) . '</option>';
        }
        $type_box .= '</optgroup></select></label>';
        $product_type_options = apply_filters('product_type_options', array('virtual' => array('id' => '_virtual', 'wrapper_class' => 'show_if_simple', 'label' => __('Virtual', 'woocommerce'), 'description' => __('Virtual products are intangible and aren\'t shipped.', 'woocommerce'), 'default' => 'no'), 'downloadable' => array('id' => '_downloadable', 'wrapper_class' => 'show_if_simple', 'label' => __('Downloadable', 'woocommerce'), 'description' => __('Downloadable products give access to a file upon purchase.', 'woocommerce'), 'default' => 'no')));
        foreach ($product_type_options as $key => $option) {
            $selected_value = get_post_meta($post->ID, '_' . $key, true);
            if ('' == $selected_value && isset($option['default'])) {
                $selected_value = $option['default'];
            }
            $type_box .= '<label for="' . esc_attr($option['id']) . '" class="' . esc_attr($option['wrapper_class']) . ' tips" data-tip="' . esc_attr($option['description']) . '">' . esc_html($option['label']) . ': <input type="checkbox" name="' . esc_attr($option['id']) . '" id="' . esc_attr($option['id']) . '" ' . checked($selected_value, 'yes', false) . ' /></label>';
        }
        ?>
		<div class="panel-wrap product_data">

			<span class="type_box"> &mdash; <?php 
        echo $type_box;
        ?>
</span>

			<ul class="product_data_tabs wc-tabs" style="display:none;">
				<?php 
        $product_data_tabs = apply_filters('woocommerce_product_data_tabs', array('general' => array('label' => __('General', 'woocommerce'), 'target' => 'general_product_data', 'class' => array('hide_if_grouped')), 'inventory' => array('label' => __('Inventory', 'woocommerce'), 'target' => 'inventory_product_data', 'class' => array('show_if_simple', 'show_if_variable', 'show_if_grouped')), 'shipping' => array('label' => __('Shipping', 'woocommerce'), 'target' => 'shipping_product_data', 'class' => array('hide_if_virtual', 'hide_if_grouped', 'hide_if_external')), 'linked_product' => array('label' => __('Linked Products', 'woocommerce'), 'target' => 'linked_product_data', 'class' => array()), 'attribute' => array('label' => __('Attributes', 'woocommerce'), 'target' => 'product_attributes', 'class' => array()), 'variations' => array('label' => __('Variations', 'woocommerce'), 'target' => 'variable_product_options', 'class' => array('variations_tab', 'show_if_variable')), 'advanced' => array('label' => __('Advanced', 'woocommerce'), 'target' => 'advanced_product_data', 'class' => array())));
        foreach ($product_data_tabs as $key => $tab) {
            ?>
<li class="<?php 
            echo $key;
            ?>
_options <?php 
            echo $key;
            ?>
_tab <?php 
            echo implode(' ', $tab['class']);
            ?>
">
							<a href="#<?php 
            echo $tab['target'];
            ?>
"><?php 
            echo esc_html($tab['label']);
            ?>
</a>
						</li><?php 
        }
        do_action('woocommerce_product_write_panel_tabs');
        ?>
			</ul>
			<div id="general_product_data" class="panel woocommerce_options_panel"><?php 
        echo '<div class="options_group hide_if_grouped">';
        // SKU
        if (wc_product_sku_enabled()) {
            woocommerce_wp_text_input(array('id' => '_sku', 'label' => '<abbr title="' . __('Stock Keeping Unit', 'woocommerce') . '">' . __('SKU', 'woocommerce') . '</abbr>', 'desc_tip' => 'true', 'description' => __('SKU refers to a Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased.', 'woocommerce')));
        } else {
            echo '<input type="hidden" name="_sku" value="' . esc_attr(get_post_meta($thepostid, '_sku', true)) . '" />';
        }
        do_action('woocommerce_product_options_sku');
        echo '</div>';
        echo '<div class="options_group show_if_external">';
        // External URL
        woocommerce_wp_text_input(array('id' => '_product_url', 'label' => __('Product URL', 'woocommerce'), 'placeholder' => 'http://', 'description' => __('Enter the external URL to the product.', 'woocommerce')));
        // Button text
        woocommerce_wp_text_input(array('id' => '_button_text', 'label' => __('Button text', 'woocommerce'), 'placeholder' => _x('Buy product', 'placeholder', 'woocommerce'), 'description' => __('This text will be shown on the button linking to the external product.', 'woocommerce')));
        echo '</div>';
        echo '<div class="options_group pricing show_if_simple show_if_external">';
        // Price
        woocommerce_wp_text_input(array('id' => '_regular_price', 'label' => __('Regular Price', 'woocommerce') . ' (' . get_woocommerce_currency_symbol() . ')', 'data_type' => 'price'));
        // Special Price
        woocommerce_wp_text_input(array('id' => '_sale_price', 'data_type' => 'price', 'label' => __('Sale Price', 'woocommerce') . ' (' . get_woocommerce_currency_symbol() . ')', 'description' => '<a href="#" class="sale_schedule">' . __('Schedule', 'woocommerce') . '</a>'));
        // Special Price date range
        $sale_price_dates_from = ($date = get_post_meta($thepostid, '_sale_price_dates_from', true)) ? date_i18n('Y-m-d', $date) : '';
        $sale_price_dates_to = ($date = get_post_meta($thepostid, '_sale_price_dates_to', true)) ? date_i18n('Y-m-d', $date) : '';
        echo '<p class="form-field sale_price_dates_fields">
								<label for="_sale_price_dates_from">' . __('Sale Price Dates', 'woocommerce') . '</label>
								<input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . esc_attr($sale_price_dates_from) . '" placeholder="' . _x('From&hellip;', 'placeholder', 'woocommerce') . ' YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
								<input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . esc_attr($sale_price_dates_to) . '" placeholder="' . _x('To&hellip;', 'placeholder', 'woocommerce') . '  YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
								<a href="#" class="cancel_sale_schedule">' . __('Cancel', 'woocommerce') . '</a>
								<img class="help_tip" style="margin-top: 21px;" data-tip="' . __('The sale will end at the beginning of the set date.', 'woocommerce') . '" src="' . esc_url(WC()->plugin_url()) . '/assets/images/help.png" height="16" width="16" />
							</p>';
        do_action('woocommerce_product_options_pricing');
        echo '</div>';
        echo '<div class="options_group show_if_downloadable">';
        ?>
					<div class="form-field downloadable_files">
						<label><?php 
        _e('Downloadable Files', 'woocommerce');
        ?>
:</label>
						<table class="widefat">
							<thead>
								<tr>
									<th class="sort">&nbsp;</th>
									<th><?php 
        _e('Name', 'woocommerce');
        ?>
 <span class="tips" data-tip="<?php 
        _e('This is the name of the download shown to the customer.', 'woocommerce');
        ?>
">[?]</span></th>
									<th colspan="2"><?php 
        _e('File URL', 'woocommerce');
        ?>
 <span class="tips" data-tip="<?php 
        _e('This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce');
        ?>
">[?]</span></th>
									<th>&nbsp;</th>
								</tr>
							</thead>
							<tbody>
								<?php 
        $downloadable_files = get_post_meta($post->ID, '_downloadable_files', true);
        if ($downloadable_files) {
            foreach ($downloadable_files as $key => $file) {
                include 'views/html-product-download.php';
            }
        }
        ?>
							</tbody>
							<tfoot>
								<tr>
									<th colspan="5">
										<a href="#" class="button insert" data-row="<?php 
        $file = array('file' => '', 'name' => '');
        ob_start();
        include 'views/html-product-download.php';
        echo esc_attr(ob_get_clean());
        ?>
"><?php 
        _e('Add File', 'woocommerce');
        ?>
</a>
									</th>
								</tr>
							</tfoot>
						</table>
					</div>
					<?php 
        // Download Limit
        woocommerce_wp_text_input(array('id' => '_download_limit', 'label' => __('Download Limit', 'woocommerce'), 'placeholder' => __('Unlimited', 'woocommerce'), 'description' => __('Leave blank for unlimited re-downloads.', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('step' => '1', 'min' => '0')));
        // Expirey
        woocommerce_wp_text_input(array('id' => '_download_expiry', 'label' => __('Download Expiry', 'woocommerce'), 'placeholder' => __('Never', 'woocommerce'), 'description' => __('Enter the number of days before a download link expires, or leave blank.', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('step' => '1', 'min' => '0')));
        // Download Type
        woocommerce_wp_select(array('id' => '_download_type', 'label' => __('Download Type', 'woocommerce'), 'description' => sprintf(__('Choose a download type - this controls the <a href="%s">schema</a>.', 'woocommerce'), 'http://schema.org/'), 'options' => array('' => __('Standard Product', 'woocommerce'), 'application' => __('Application/Software', 'woocommerce'), 'music' => __('Music', 'woocommerce'))));
        do_action('woocommerce_product_options_downloads');
        echo '</div>';
        if (wc_tax_enabled()) {
            echo '<div class="options_group show_if_simple show_if_external show_if_variable">';
            // Tax
            woocommerce_wp_select(array('id' => '_tax_status', 'label' => __('Tax Status', 'woocommerce'), 'options' => array('taxable' => __('Taxable', 'woocommerce'), 'shipping' => __('Shipping only', 'woocommerce'), 'none' => _x('None', 'Tax status', 'woocommerce'))));
            $tax_classes = WC_Tax::get_tax_classes();
            $classes_options = array();
            $classes_options[''] = __('Standard', 'woocommerce');
            if (!empty($tax_classes)) {
                foreach ($tax_classes as $class) {
                    $classes_options[sanitize_title($class)] = esc_html($class);
                }
            }
            woocommerce_wp_select(array('id' => '_tax_class', 'label' => __('Tax Class', 'woocommerce'), 'options' => $classes_options));
            do_action('woocommerce_product_options_tax');
            echo '</div>';
        }
        do_action('woocommerce_product_options_general_product_data');
        ?>
			</div>

			<div id="inventory_product_data" class="panel woocommerce_options_panel">

				<?php 
        echo '<div class="options_group">';
        if ('yes' == get_option('woocommerce_manage_stock')) {
            // manage stock
            woocommerce_wp_checkbox(array('id' => '_manage_stock', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Manage stock?', 'woocommerce'), 'description' => __('Enable stock management at product level', 'woocommerce')));
            do_action('woocommerce_product_options_stock');
            echo '<div class="stock_fields show_if_simple show_if_variable">';
            // Stock
            woocommerce_wp_text_input(array('id' => '_stock', 'label' => __('Stock Qty', 'woocommerce'), 'desc_tip' => true, 'description' => __('Stock quantity. If this is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('step' => 'any'), 'data_type' => 'stock'));
            // Backorders?
            woocommerce_wp_select(array('id' => '_backorders', 'label' => __('Allow Backorders?', 'woocommerce'), 'options' => array('no' => __('Do not allow', 'woocommerce'), 'notify' => __('Allow, but notify customer', 'woocommerce'), 'yes' => __('Allow', 'woocommerce')), 'desc_tip' => true, 'description' => __('If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.', 'woocommerce')));
            do_action('woocommerce_product_options_stock_fields');
            echo '</div>';
        }
        // Stock status
        woocommerce_wp_select(array('id' => '_stock_status', 'wrapper_class' => 'hide_if_variable', 'label' => __('Stock status', 'woocommerce'), 'options' => array('instock' => __('In stock', 'woocommerce'), 'outofstock' => __('Out of stock', 'woocommerce')), 'desc_tip' => true, 'description' => __('Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce')));
        do_action('woocommerce_product_options_stock_status');
        echo '</div>';
        echo '<div class="options_group show_if_simple show_if_variable">';
        // Individual product
        woocommerce_wp_checkbox(array('id' => '_sold_individually', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Sold Individually', 'woocommerce'), 'description' => __('Enable this to only allow one of this item to be bought in a single order', 'woocommerce')));
        do_action('woocommerce_product_options_sold_individually');
        echo '</div>';
        do_action('woocommerce_product_options_inventory_product_data');
        ?>

			</div>

			<div id="shipping_product_data" class="panel woocommerce_options_panel">

				<?php 
        echo '<div class="options_group">';
        // Weight
        if (wc_product_weight_enabled()) {
            woocommerce_wp_text_input(array('id' => '_weight', 'label' => __('Weight', 'woocommerce') . ' (' . get_option('woocommerce_weight_unit') . ')', 'placeholder' => wc_format_localized_decimal(0), 'desc_tip' => 'true', 'description' => __('Weight in decimal form', 'woocommerce'), 'type' => 'text', 'data_type' => 'decimal'));
        }
        // Size fields
        if (wc_product_dimensions_enabled()) {
            ?>
<p class="form-field dimensions_field">
							<label for="product_length"><?php 
            echo __('Dimensions', 'woocommerce') . ' (' . get_option('woocommerce_dimension_unit') . ')';
            ?>
</label>
							<span class="wrap">
								<input id="product_length" placeholder="<?php 
            _e('Length', 'woocommerce');
            ?>
" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_length', true)));
            ?>
" />
								<input placeholder="<?php 
            _e('Width', 'woocommerce');
            ?>
" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_width', true)));
            ?>
" />
								<input placeholder="<?php 
            _e('Height', 'woocommerce');
            ?>
" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_height', true)));
            ?>
" />
							</span>
							<img class="help_tip" data-tip="<?php 
            esc_attr_e('LxWxH in decimal form', 'woocommerce');
            ?>
" src="<?php 
            echo esc_url(WC()->plugin_url());
            ?>
/assets/images/help.png" height="16" width="16" />
						</p><?php 
        }
        do_action('woocommerce_product_options_dimensions');
        echo '</div>';
        echo '<div class="options_group">';
        // Shipping Class
        $classes = get_the_terms($thepostid, 'product_shipping_class');
        if ($classes && !is_wp_error($classes)) {
            $current_shipping_class = current($classes)->term_id;
        } else {
            $current_shipping_class = '';
        }
        $args = array('taxonomy' => 'product_shipping_class', 'hide_empty' => 0, 'show_option_none' => __('No shipping class', 'woocommerce'), 'name' => 'product_shipping_class', 'id' => 'product_shipping_class', 'selected' => $current_shipping_class, 'class' => 'select short');
        ?>
<p class="form-field dimensions_field"><label for="product_shipping_class"><?php 
        _e('Shipping class', 'woocommerce');
        ?>
</label> <?php 
        wp_dropdown_categories($args);
        ?>
 <img class="help_tip" data-tip="<?php 
        esc_attr_e('Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce');
        ?>
" src="<?php 
        echo esc_url(WC()->plugin_url());
        ?>
/assets/images/help.png" height="16" width="16" /></p><?php 
        do_action('woocommerce_product_options_shipping');
        echo '</div>';
        ?>

			</div>

			<div id="product_attributes" class="panel wc-metaboxes-wrapper">
				<div class="product_attributes wc-metaboxes">

					<?php 
        global $wc_product_attributes;
        // Array of defined attribute taxonomies
        $attribute_taxonomies = wc_get_attribute_taxonomies();
        // Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set
        $attributes = maybe_unserialize(get_post_meta($thepostid, '_product_attributes', true));
        // Output All Set Attributes
        if (!empty($attributes)) {
            $attribute_keys = array_keys($attributes);
            $attribute_total = sizeof($attribute_keys);
            for ($i = 0; $i < $attribute_total; $i++) {
                $attribute = $attributes[$attribute_keys[$i]];
                $position = empty($attribute['position']) ? 0 : absint($attribute['position']);
                $taxonomy = '';
                $metabox_class = array();
                if ($attribute['is_taxonomy']) {
                    $taxonomy = $attribute['name'];
                    if (!taxonomy_exists($taxonomy)) {
                        continue;
                    }
                    $attribute_taxonomy = $wc_product_attributes[$taxonomy];
                    $metabox_class[] = 'taxonomy';
                    $metabox_class[] = $taxonomy;
                    $attribute_label = wc_attribute_label($taxonomy);
                } else {
                    $attribute_label = apply_filters('woocommerce_attribute_label', $attribute['name'], $attribute['name']);
                }
                include 'views/html-product-attribute.php';
            }
        }
        ?>
				</div>

				<p class="toolbar">
					<button type="button" class="button button-primary add_attribute"><?php 
        _e('Add', 'woocommerce');
        ?>
</button>
					<select name="attribute_taxonomy" class="attribute_taxonomy">
						<option value=""><?php 
        _e('Custom product attribute', 'woocommerce');
        ?>
</option>
						<?php 
        if ($attribute_taxonomies) {
            foreach ($attribute_taxonomies as $tax) {
                $attribute_taxonomy_name = wc_attribute_taxonomy_name($tax->attribute_name);
                $label = $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name;
                echo '<option value="' . esc_attr($attribute_taxonomy_name) . '">' . esc_html($label) . '</option>';
            }
        }
        ?>
					</select>

					<button type="button" class="button save_attributes"><?php 
        _e('Save attributes', 'woocommerce');
        ?>
</button>
				</p>
				<?php 
        do_action('woocommerce_product_options_attributes');
        ?>
			</div>
			<div id="linked_product_data" class="panel woocommerce_options_panel">

				<div class="options_group">

					<p class="form-field">
						<label for="upsell_ids"><?php 
        _e('Up-Sells', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="upsell_ids" name="upsell_ids" data-placeholder="<?php 
        _e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $product_ids = array_filter(array_map('absint', (array) get_post_meta($post->ID, '_upsell_ids', true)));
        $json_ids = array();
        foreach ($product_ids as $product_id) {
            $product = wc_get_product($product_id);
            if (is_object($product)) {
                $json_ids[$product_id] = wp_kses_post(html_entity_decode($product->get_formatted_name()));
            }
        }
        echo esc_attr(json_encode($json_ids));
        ?>
" value="<?php 
        echo implode(',', array_keys($json_ids));
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>

					<p class="form-field">
						<label for="crosssell_ids"><?php 
        _e('Cross-Sells', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="crosssell_ids" name="crosssell_ids" data-placeholder="<?php 
        _e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $product_ids = array_filter(array_map('absint', (array) get_post_meta($post->ID, '_crosssell_ids', true)));
        $json_ids = array();
        foreach ($product_ids as $product_id) {
            $product = wc_get_product($product_id);
            if (is_object($product)) {
                $json_ids[$product_id] = wp_kses_post(html_entity_decode($product->get_formatted_name()));
            }
        }
        echo esc_attr(json_encode($json_ids));
        ?>
" value="<?php 
        echo implode(',', array_keys($json_ids));
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>
				</div>

				<div class="options_group grouping show_if_simple show_if_external">

					<p class="form-field">
						<label for="parent_id"><?php 
        _e('Grouping', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="parent_id" name="parent_id" data-placeholder="<?php 
        _e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_grouped_products" data-allow_clear="true" data-multiple="false" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $parent_id = absint($post->post_parent);
        if ($parent_id) {
            $parent = wc_get_product($parent_id);
            if (is_object($parent)) {
                $parent_title = wp_kses_post(html_entity_decode($parent->get_formatted_name()));
            }
            echo esc_attr($parent_title);
        }
        ?>
" value="<?php 
        echo $parent_id ? $parent_id : '';
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Set this option to make this product part of a grouped product.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>

					<?php 
        woocommerce_wp_hidden_input(array('id' => 'previous_parent_id', 'value' => absint($post->post_parent)));
        do_action('woocommerce_product_options_grouping');
        ?>
				</div>

				<?php 
        do_action('woocommerce_product_options_related');
        ?>
			</div>

			<div id="advanced_product_data" class="panel woocommerce_options_panel">

				<div class="options_group hide_if_external">
					<?php 
        // Purchase note
        woocommerce_wp_textarea_input(array('id' => '_purchase_note', 'label' => __('Purchase Note', 'woocommerce'), 'desc_tip' => 'true', 'description' => __('Enter an optional note to send the customer after purchase.', 'woocommerce')));
        ?>
				</div>

				<div class="options_group">
					<?php 
        // menu_order
        woocommerce_wp_text_input(array('id' => 'menu_order', 'label' => __('Menu order', 'woocommerce'), 'desc_tip' => 'true', 'description' => __('Custom ordering position.', 'woocommerce'), 'value' => intval($post->menu_order), 'type' => 'number', 'custom_attributes' => array('step' => '1')));
        ?>
				</div>

				<div class="options_group reviews">
					<?php 
        woocommerce_wp_checkbox(array('id' => 'comment_status', 'label' => __('Enable reviews', 'woocommerce'), 'cbvalue' => 'open', 'value' => esc_attr($post->comment_status)));
        do_action('woocommerce_product_options_reviews');
        ?>
				</div>

				<?php 
        do_action('woocommerce_product_options_advanced');
        ?>

			</div>

			<?php 
        self::output_variations();
        do_action('woocommerce_product_data_panels');
        do_action('woocommerce_product_write_panels');
        // _deprecated
        ?>

			<div class="clear"></div>

		</div>
		<?php 
    }
/**
 * Format a weight for display.
 *
 * @since  2.7.0
 * @param  float $weight Weight.
 * @return string
 */
function wc_format_weight($weight)
{
    $weight_string = wc_format_localized_decimal($weight);
    if (!empty($weight_string)) {
        $weight_string .= ' ' . get_option('woocommerce_weight_unit');
    } else {
        $weight_string = __('N/A', 'woocommerce');
    }
    return apply_filters('woocommerce_format_weight', $weight_string, $weight);
}