2012-11-27 16:22:47 +00:00
< ? php
2015-01-14 12:17:09 +00:00
/**
2016-11-02 18:50:42 +00:00
* Outputs a variation for editing .
2015-01-14 12:17:09 +00:00
*
* @ var int $variation_id
* @ var WP_POST $variation
2016-11-02 18:50:42 +00:00
* @ var WP_Product_Variation $variation_object
* @ var array $variation_data array of variation data @ deprecated .
2015-01-14 12:17:09 +00:00
*/
2014-09-20 20:05:06 +00:00
if ( ! defined ( 'ABSPATH' ) ) {
2015-01-14 12:17:09 +00:00
exit ;
2014-09-20 20:05:06 +00:00
}
2012-10-15 10:32:24 +00:00
?>
2012-10-08 08:59:02 +00:00
< div class = " woocommerce_variation wc-metabox closed " >
< h3 >
2015-07-08 22:08:07 +00:00
< a href = " # " class = " remove_variation delete " rel = " <?php echo esc_attr( $variation_id ); ?> " >< ? php _e ( 'Remove' , 'woocommerce' ); ?> </a>
2015-08-05 18:08:15 +00:00
< div class = " handlediv " title = " <?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?> " ></ div >
2015-09-15 16:05:52 +00:00
< div class = " tips sort " data - tip = " <?php esc_attr_e( 'Drag and drop, or click to set admin variation order', 'woocommerce' ); ?> " ></ div >
2016-03-10 11:39:32 +00:00
< strong > #<?php echo esc_html( $variation_id ); ?> </strong>
2012-10-08 08:59:02 +00:00
< ? php
2016-11-02 18:50:42 +00:00
$attribute_values = $variation_object -> get_attributes ();
2012-10-08 08:59:02 +00:00
2016-11-02 18:50:42 +00:00
foreach ( $product_object -> get_attributes () as $attribute ) {
if ( ! $attribute -> get_variation () ) {
2012-10-08 08:59:02 +00:00
continue ;
2013-12-11 00:36:56 +00:00
}
2016-11-02 18:50:42 +00:00
$selected_value = isset ( $attribute_values [ 'attribute_' . sanitize_title ( $attribute -> get_name () ) ] ) ? $attribute_values [ 'attribute_' . sanitize_title ( $attribute -> get_name () ) ] : '' ;
?>
< select name = " attribute_<?php echo sanitize_title( $attribute->get_name () ) . " [{ $loop }] " ; ?> " >
< option value = " " >< ? php echo esc_html ( __ ( 'Any' , 'woocommerce' ) . ' ' . wc_attribute_label ( $attribute -> get_name () ) ); ?> …</option>
< ? php if ( $attribute -> is_taxonomy () ) : ?>
< ? php foreach ( $attribute -> get_terms () as $option ) : ?>
< option < ? php selected ( $selected_value , $option -> slug ); ?> value="<?php echo esc_attr( $option->slug ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option->name ) ); ?></option>
< ? php endforeach ; ?>
< ? php else : ?>
< ? php foreach ( $attribute -> get_options () as $option ) : ?>
< option < ? php selected ( $selected_value , $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ); ?></option>
< ? php endforeach ; ?>
< ? php endif ; ?>
</ select >
< ? php
2012-10-08 08:59:02 +00:00
}
?>
< input type = " hidden " name = " variable_post_id[<?php echo $loop ; ?>] " value = " <?php echo esc_attr( $variation_id ); ?> " />
2016-11-02 18:50:42 +00:00
< input type = " hidden " class = " variation_menu_order " name = " variation_menu_order[<?php echo $loop ; ?>] " value = " <?php echo esc_attr( $variation_object->get_menu_order () ); ?> " />
2012-10-08 08:59:02 +00:00
</ h3 >
2015-07-02 20:42:22 +00:00
< div class = " woocommerce_variable_attributes wc-metabox-content " style = " display: none; " >
2014-10-17 11:17:21 +00:00
< div class = " data " >
2014-10-17 13:42:15 +00:00
< p class = " form-row form-row-first upload_image " >
2016-11-02 18:50:42 +00:00
< a href = " # " class = " upload_image_button tips <?php echo $variation_object->get_image_id () ? 'remove' : ''; ?> " data - tip = " <?php echo $variation_object->get_image_id () ? __( 'Remove this image', 'woocommerce' ) : __( 'Upload an image', 'woocommerce' ); ?> " rel = " <?php echo esc_attr( $variation_id ); ?> " >
< img src = " <?php echo $variation_object->get_image_id () ? esc_url( wp_get_attachment_thumb_url( $variation_object->get_image_id () ) ) : esc_url( wc_placeholder_img_src() ); ?> " />< input type = " hidden " name = " upload_image_id[<?php echo $loop ; ?>] " class = " upload_image_id " value = " <?php echo esc_attr( $variation_object->get_image_id () ); ?> " />
</ a >
2014-10-17 11:17:21 +00:00
</ p >
2016-11-02 18:50:42 +00:00
< ? php
if ( wc_product_sku_enabled () ) {
woocommerce_wp_text_input ( array (
'id' => " variable_sku { $loop } " ,
'name' => " variable_sku[ { $loop } ] " ,
'value' => $variation_object -> get_sku (),
'placeholder' => $product_object -> get_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' ),
'wrapper_class' => 'form-row form-row-last' ,
) );
}
?>
2014-10-17 11:17:21 +00:00
< p class = " form-row form-row-full options " >
2016-11-02 18:50:42 +00:00
< label >
< ? php _e ( 'Enabled' , 'woocommerce' ); ?> :
< input type = " checkbox " class = " checkbox " name = " variable_enabled[<?php echo $loop ; ?>] " < ? php checked ( $variation_object -> get_status (), 'publish' ); ?> />
</ label >
< label class = " tips " data - tip = " <?php _e( 'Enable this option if access is given to a downloadable file upon purchase of a product', 'woocommerce' ); ?> " >
< ? php _e ( 'Downloadable' , 'woocommerce' ); ?> :
< input type = " checkbox " class = " checkbox variable_is_downloadable " name = " variable_is_downloadable[<?php echo $loop ; ?>] " < ? php checked ( $variation_object -> get_downloadable (), true ); ?> />
</ label >
< label class = " tips " data - tip = " <?php _e( 'Enable this option if a product is not shipped or there is no shipping cost', 'woocommerce' ); ?> " >
< ? php _e ( 'Virtual' , 'woocommerce' ); ?> :
< input type = " checkbox " class = " checkbox variable_is_virtual " name = " variable_is_virtual[<?php echo $loop ; ?>] " < ? php checked ( $variation_object -> get_virtual (), true ); ?> />
</ label >
2014-10-17 11:17:21 +00:00
2016-11-02 18:50:42 +00:00
< ? php if ( 'yes' === get_option ( 'woocommerce_manage_stock' ) ) : ?>
< label class = " tips " data - tip = " <?php _e( 'Enable this option to enable stock management at variation level', 'woocommerce' ); ?> " >
< ? php _e ( 'Manage stock?' , 'woocommerce' ); ?>
< input type = " checkbox " class = " checkbox variable_manage_stock " name = " variable_manage_stock[<?php echo $loop ; ?>] " < ? php checked ( $variation_object -> get_manage_stock (), true ); ?> />
</ label >
2014-10-17 11:17:21 +00:00
< ? php endif ; ?>
< ? php do_action ( 'woocommerce_variation_options' , $loop , $variation_data , $variation ); ?>
</ p >
2014-12-23 16:12:12 +00:00
< div class = " variable_pricing " >
2016-11-02 18:50:42 +00:00
< ? php
woocommerce_wp_text_input ( array (
'id' => " variable_regular_price_ { $loop } " ,
'name' => " variable_regular_price[ { $loop } ] " ,
'value' => wc_format_localized_price ( $variation_object -> get_regular_price () ),
'label' => __ ( 'Regular price' , 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol () . ')' ,
'data_type' => 'price' ,
'wrapper_class' => 'form-row form-row-first' ,
) );
2014-10-17 11:17:21 +00:00
2016-11-02 18:50:42 +00:00
woocommerce_wp_text_input ( array (
'id' => " variable_sale_price { $loop } " ,
'name' => " variable_sale_price[ { $loop } ] " ,
'value' => wc_format_localized_price ( $variation_object -> get_sale_price () ),
'data_type' => 'price' ,
'label' => __ ( 'Sale price' , 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol () . ')' . ' <a href="#" class="sale_schedule">' . __ ( 'Schedule' , 'woocommerce' ) . '</a><a href="#" class="cancel_sale_schedule hidden">' . __ ( 'Cancel schedule' , 'woocommerce' ) . '</a>' ,
'wrapper_class' => 'form-row form-row-last' ,
) );
$sale_price_dates_from = ( $date = $variation_object -> get_date_on_sale_from () ) ? date_i18n ( 'Y-m-d' , $date ) : '' ;
$sale_price_dates_to = ( $date = $variation_object -> get_date_on_sale_to () ) ? date_i18n ( 'Y-m-d' , $date ) : '' ;
echo ' < div class = " form-field sale_price_dates_fields hidden " >
< p class = " form-row form-row-first " >
< label > ' . __( ' Sale start date ', ' woocommerce ' ) . ' </ label >
< input type = " text " class = " sale_price_dates_from " name = " variable_sale_price_dates_from[' . $loop . '] " value = " ' . esc_attr( $sale_price_dates_from ) . ' " placeholder = " ' . _x( 'From…', '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]) " />
</ p >
< p class = " form-row form-row-last " >
< label > ' . __( ' Sale end date ', ' woocommerce ' ) . ' </ label >
< input type = " text " class = " sale_price_dates_to " name = " variable_sale_price_dates_to[' . $loop . '] " id = " _sale_price_dates_to " value = " ' . esc_attr( $sale_price_dates_to ) . ' " placeholder = " ' . _x( 'To…', '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]) " />
</ p >
</ div > ' ;
2015-10-01 14:30:02 +00:00
/**
2015-11-03 12:28:01 +00:00
* woocommerce_variation_options_pricing action .
2015-10-01 14:30:02 +00:00
*
* @ since 2.5 . 0
*
* @ param int $loop
* @ param array $variation_data
* @ param WP_Post $variation
*/
do_action ( 'woocommerce_variation_options_pricing' , $loop , $variation_data , $variation );
?>
2014-10-17 11:17:21 +00:00
</ div >
2016-11-02 18:50:42 +00:00
< ? php if ( 'yes' === get_option ( 'woocommerce_manage_stock' ) ) : ?>
2015-01-02 17:07:31 +00:00
< div class = " show_if_variation_manage_stock " style = " display: none; " >
2015-10-01 14:30:02 +00:00
< ? php
2016-11-02 18:50:42 +00:00
woocommerce_wp_text_input ( array (
'id' => " variable_stock { $loop } " ,
'name' => " variable_stock[ { $loop } ] " ,
'value' => $variation_object -> get_stock_quantity (),
'label' => __ ( 'Stock quantity' , 'woocommerce' ),
'desc_tip' => true ,
'description' => __ ( 'Enter a quantity to enable stock management at variation level, or leave blank to use the parent product\'s options.' , 'woocommerce' ),
'type' => 'number' ,
'custom_attributes' => array (
'step' => 'any' ,
),
'data_type' => 'stock' ,
'wrapper_class' => 'form-row form-row-first' ,
) );
woocommerce_wp_select ( array (
'id' => " variable_backorders { $loop } " ,
'name' => " variable_backorders[ { $loop } ] " ,
'value' => $variation_object -> get_backorders (),
'label' => __ ( 'Allow backorders?' , 'woocommerce' ),
'options' => wc_get_product_backorder_options (),
'desc_tip' => true ,
'description' => __ ( 'If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.' , 'woocommerce' ),
'wrapper_class' => 'form-row form-row-last' ,
) );
2015-10-01 14:30:02 +00:00
/**
2015-12-21 05:36:36 +00:00
* woocommerce_variation_options_inventory action .
2015-10-01 14:30:02 +00:00
*
* @ since 2.5 . 0
*
* @ param int $loop
* @ param array $variation_data
* @ param WP_Post $variation
*/
2015-12-21 05:36:36 +00:00
do_action ( 'woocommerce_variation_options_inventory' , $loop , $variation_data , $variation );
2015-10-01 14:30:02 +00:00
?>
2014-10-17 11:17:21 +00:00
</ div >
< ? php endif ; ?>
2016-11-02 18:50:42 +00:00
< div >
< ? php
woocommerce_wp_select ( array (
'id' => " variable_stock_status { $loop } " ,
'name' => " variable_stock_status[ { $loop } ] " ,
'value' => $variation_object -> get_stock_status (),
'label' => __ ( 'Stock status' , 'woocommerce' ),
'options' => wc_get_product_stock_status_options (),
'desc_tip' => true ,
'description' => __ ( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.' , 'woocommerce' ),
'wrapper_class' => 'form-row form-row-full' ,
) );
2015-07-30 14:45:05 +00:00
2016-11-02 18:50:42 +00:00
if ( wc_product_weight_enabled () ) {
woocommerce_wp_text_input ( array (
'id' => " variable_weight { $loop } " ,
'name' => " variable_weight[ { $loop } ] " ,
'value' => wc_format_localized_decimal ( $variation_object -> get_weight () ), // @todo need method to get raw unfiltered values in admin.
'placeholder' => wc_format_localized_decimal ( $product_object -> get_weight () ),
'label' => __ ( 'Weight' , 'woocommerce' ) . ' (' . get_option ( 'woocommerce_weight_unit' ) . ')' ,
'desc_tip' => true ,
'description' => __ ( 'Weight in decimal form' , 'woocommerce' ),
'type' => 'text' ,
'data_type' => 'decimal' ,
'wrapper_class' => 'form-row form-row-first hide_if_variation_virtual' ,
) );
}
if ( wc_product_dimensions_enabled () ) {
?> <p class="form-field form-row dimensions_field hide_if_variation_virtual form-row-last">
< label for = " product_length " >< ? php echo __ ( 'Dimensions' , 'woocommerce' ) . ' (' . get_option ( 'woocommerce_dimension_unit' ) . ')' ; ?> </label>
< ? php echo wc_help_tip ( __ ( 'Length x width x height in decimal form' , 'woocommerce' ) ); ?>
< 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 = " variable_length[<?php echo $loop ; ?>] " value = " <?php echo esc_attr( wc_format_localized_decimal( $variation_object->get_length () ) ); ?> " />
< input placeholder = " <?php esc_attr_e( 'Width', 'woocommerce' ); ?> " 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 () ) ); ?> " />
< 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 () ) ); ?> " />
</ 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 );
?>
</ div >
2015-10-01 14:30:02 +00:00
2014-10-17 11:17:21 +00:00
< div >
2016-03-10 11:39:32 +00:00
< p class = " form-row hide_if_variation_virtual form-row-full " >< label >< ? php _e ( 'Shipping class' , 'woocommerce' ); ?> </label> <?php
2016-11-02 18:50:42 +00:00
wp_dropdown_categories ( array (
'taxonomy' => 'product_shipping_class' ,
'hide_empty' => 0 ,
'show_option_none' => __ ( 'Same as parent' , 'woocommerce' ),
'name' => 'variable_shipping_class[' . $loop . ']' ,
'id' => '' ,
'selected' => $variation_object -> get_shipping_class_id (),
) );
2014-10-17 11:17:21 +00:00
?> </p>
2015-05-29 13:55:54 +00:00
2016-11-02 18:50:42 +00:00
< ? php
if ( wc_tax_enabled () ) {
woocommerce_wp_select ( array (
'id' => " variable_tax_class { $loop } " ,
'name' => " variable_tax_class[ { $loop } ] " ,
'value' => $variation_object -> get_tax_class (),
'label' => __ ( 'Tax class' , 'woocommerce' ),
'options' => array_merge ( array ( 'parent' => __ ( 'Same as parent' , 'woocommerce' ) ), wc_get_product_tax_class_options () ), // @todo rename to inherit - make sure get_tax_class returns this value too.
'desc_tip' => 'true' ,
'description' => __ ( 'Choose a tax class for this product. Tax classes are used to apply different tax rates specific to certain types of product.' , 'woocommerce' ),
'wrapper_class' => 'form-row form-row-full' ,
) );
2015-10-01 14:30:02 +00:00
2016-11-02 18:50:42 +00:00
/**
* woocommerce_variation_options_tax action .
*
* @ since 2.5 . 0
*
* @ param int $loop
* @ param array $variation_data
* @ param WP_Post $variation
*/
do_action ( 'woocommerce_variation_options_tax' , $loop , $variation_data , $variation );
}
?>
2015-11-28 15:20:47 +00:00
</ div >
< div >
2016-11-02 18:50:42 +00:00
< ? php
woocommerce_wp_textarea_input ( array (
'id' => " variable_description { $loop } " ,
'name' => " variable_description[ { $loop } ] " ,
'value' => $variation_object -> get_description (),
'label' => __ ( 'Description' , 'woocommerce' ),
'desc_tip' => true ,
'description' => __ ( 'Enter an optional description for this variation.' , 'woocommerce' ),
'wrapper_class' => 'form-row form-row-full' ,
) );
?>
2014-10-17 11:17:21 +00:00
</ div >
2015-01-02 17:07:31 +00:00
< div class = " show_if_variation_downloadable " style = " display: none; " >
2014-10-17 11:17:21 +00:00
< div class = " form-row form-row-full downloadable_files " >
2016-03-10 11:39:32 +00:00
< label >< ? php _e ( 'Downloadable files' , 'woocommerce' ); ?> </label>
2014-10-17 11:17:21 +00:00
< table class = " widefat " >
< thead >
< div >
2015-10-23 15:09:08 +00:00
< th >< ? php _e ( 'Name' , 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th>
< th colspan = " 2 " >< ? php _e ( 'File URL' , 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th>
2014-10-17 11:17:21 +00:00
< th >& nbsp ; </ th >
</ div >
</ thead >
< tbody >
< ? php
2016-11-02 18:50:42 +00:00
if ( $downloads = $variation_object -> get_downloads () ) {
foreach ( $downloads as $key => $file ) {
2014-10-17 11:17:21 +00:00
if ( ! is_array ( $file ) ) {
$file = array (
'file' => $file ,
2016-08-27 01:46:45 +00:00
'name' => '' ,
2014-10-17 11:17:21 +00:00
);
}
include ( 'html-product-variation-download.php' );
}
}
?>
</ tbody >
< tfoot >
< div >
< th colspan = " 4 " >
< a href = " # " class = " button insert " data - row = " <?php
$file = array (
'file' => '' ,
2016-08-27 01:46:45 +00:00
'name' => '' ,
2014-10-17 11:17:21 +00:00
);
ob_start ();
include ( 'html-product-variation-download.php' );
echo esc_attr ( ob_get_clean () );
?> "><?php _e( 'Add File', 'woocommerce' ); ?></a>
</ th >
</ div >
</ tfoot >
</ table >
</ div >
</ div >
2015-01-02 17:07:31 +00:00
< div class = " show_if_variation_downloadable " style = " display: none; " >
2015-10-01 14:30:02 +00:00
< ? php
2016-11-02 18:50:42 +00:00
woocommerce_wp_text_input ( array (
'id' => " variable_download_limit { $loop } " ,
'name' => " variable_download_limit[ { $loop } ] " ,
'value' => $variation_object -> get_download_limit () < 0 ? '' : $variation_object -> get_download_limit (),
'label' => __ ( 'Download limit' , 'woocommerce' ),
'placeholder' => __ ( 'Unlimited' , 'woocommerce' ),
'description' => __ ( 'Leave blank for unlimited re-downloads.' , 'woocommerce' ),
'type' => 'number' ,
'desc_tip' => true ,
'custom_attributes' => array (
'step' => '1' ,
'min' => '0' ,
),
'wrapper_class' => 'form-row form-row-first' ,
) );
woocommerce_wp_text_input ( array (
'id' => " variable_download_expiry { $loop } " ,
'name' => " variable_download_expiry[ { $loop } ] " ,
'value' => $variation_object -> get_download_expiry () < 0 ? '' : $variation_object -> get_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' ,
'desc_tip' => true ,
'custom_attributes' => array (
'step' => '1' ,
'min' => '0' ,
),
'wrapper_class' => 'form-row form-row-last' ,
) );
2015-10-01 14:30:02 +00:00
/**
2015-12-21 05:36:36 +00:00
* woocommerce_variation_options_download action .
2015-10-01 14:30:02 +00:00
*
* @ since 2.5 . 0
*
* @ param int $loop
* @ param array $variation_data
* @ param WP_Post $variation
*/
2015-12-21 05:36:36 +00:00
do_action ( 'woocommerce_variation_options_download' , $loop , $variation_data , $variation );
2015-10-01 14:30:02 +00:00
?>
2014-10-17 11:17:21 +00:00
</ div >
< ? php do_action ( 'woocommerce_product_after_variable_attributes' , $loop , $variation_data , $variation ); ?>
</ div >
</ div >
2012-10-08 08:59:02 +00:00
</ div >