2011-08-10 17:11:11 +00:00
< ? php
/**
* Product Data
*
* Function for displaying the product data meta boxes
*
* @ author WooThemes
* @ category Admin Write Panels
* @ package WooCommerce
*/
2011-11-05 19:03:03 +00:00
require_once ( 'writepanel-product-type-variable.php' );
2011-08-10 17:11:11 +00:00
/**
* Product data box
*
* Displays the product data box , tabbed , with several panels covering price , stock etc
*/
function woocommerce_product_data_box () {
2011-09-06 11:11:22 +00:00
global $post , $wpdb , $thepostid , $woocommerce ;
2011-08-10 17:11:11 +00:00
add_action ( 'admin_footer' , 'woocommerce_meta_scripts' );
wp_nonce_field ( 'woocommerce_save_data' , 'woocommerce_meta_nonce' );
$thepostid = $post -> ID ;
2011-08-17 23:42:07 +00:00
$product_custom_fields = get_post_custom ( $thepostid );
2011-08-10 17:11:11 +00:00
?>
< div class = " panel-wrap product_data " >
< ul class = " product_data_tabs tabs " style = " display:none; " >
2011-11-05 19:03:03 +00:00
2011-11-08 16:15:36 +00:00
< li class = " active show_if_simple show_if_variable show_if_external " >< a href = " #general_product_data " >< ? php _e ( 'General' , 'woothemes' ); ?> </a></li>
2011-11-05 19:03:03 +00:00
< li class = " tax_tab show_if_simple show_if_variable " >< a href = " #tax_product_data " >< ? php _e ( 'Tax' , 'woothemes' ); ?> </a></li>
2011-11-08 16:15:36 +00:00
< ? php if ( get_option ( 'woocommerce_manage_stock' ) == 'yes' ) : ?> <li class="inventory_tab show_if_simple show_if_variable show_if_grouped"><a href="#inventory_product_data"><?php _e('Inventory', 'woothemes'); ?></a></li><?php endif; ?>
2011-11-05 19:03:03 +00:00
< li class = " upsells_and_crosssells_tab " >< a href = " #upsells_and_crosssells_product_data " >< ? php _e ( 'Up-sells & Cross-sells' , 'woothemes' ); ?> </a></li>
2011-11-04 01:46:20 +00:00
< li class = " attributes_tab " >< a href = " #woocommerce_attributes " >< ? php _e ( 'Attributes' , 'woothemes' ); ?> </a></li>
2011-11-05 19:03:03 +00:00
2011-11-06 13:45:18 +00:00
< li class = " grouping_tab show_if_simple " >< a href = " #grouping_product_data " >< ? php _e ( 'Grouping' , 'woothemes' ); ?> </a></li>
2011-11-05 19:03:03 +00:00
2011-11-06 13:45:18 +00:00
< li class = " downloads_tab show_if_downloadable " >< a href = " #downloadable_product_data " >< ? php _e ( 'Downloads' , 'woothemes' ); ?> </a></li>
2011-11-05 19:03:03 +00:00
2011-09-21 15:43:37 +00:00
< ? php do_action ( 'woocommerce_product_write_panel_tabs' ); ?>
2011-08-10 17:11:11 +00:00
</ ul >
< div id = " general_product_data " class = " panel woocommerce_options_panel " >< ? php
2011-08-21 13:28:54 +00:00
echo '<div class="options_group">' ;
2011-08-10 17:11:11 +00:00
2011-08-21 13:28:54 +00:00
// SKU
if ( get_option ( 'woocommerce_enable_sku' , true ) !== 'no' ) :
woocommerce_wp_text_input ( array ( 'id' => 'sku' , 'label' => __ ( 'SKU' , 'woothemes' ), 'placeholder' => $post -> ID ) );
else :
echo '<input type="hidden" name="sku" value="' . get_post_meta ( $thepostid , 'sku' , true ) . '" />' ;
endif ;
2011-09-05 11:56:26 +00:00
do_action ( 'woocommerce_product_options_sku' );
2011-08-10 17:11:11 +00:00
2011-08-21 13:28:54 +00:00
echo '</div>' ;
2011-11-08 16:15:36 +00:00
echo '<div class="options_group show_if_external">' ;
// External URL
woocommerce_wp_text_input ( array ( 'id' => 'product_url' , 'label' => __ ( 'Product URL' , 'woothemes' ), 'placeholder' => 'http://' , 'description' => __ ( 'Enter the external URL to the product.' , 'woothemes' ) ) );
echo '</div>' ;
echo '<div class="options_group pricing show_if_simple show_if_external">' ;
2011-08-10 17:11:11 +00:00
2011-08-21 13:28:54 +00:00
// Price
2011-11-06 13:45:18 +00:00
woocommerce_wp_text_input ( array ( 'id' => 'regular_price' , 'label' => __ ( 'Regular Price' , 'woothemes' ) . ' (' . get_woocommerce_currency_symbol () . ')' ) );
2011-08-21 13:28:54 +00:00
// Special Price
2011-11-06 13:45:18 +00:00
woocommerce_wp_text_input ( array ( 'id' => 'sale_price' , 'label' => __ ( 'Sale Price' , 'woothemes' ) . ' (' . get_woocommerce_currency_symbol () . ')' ) );
2011-08-21 13:28:54 +00:00
// Special Price date range
$field = array ( 'id' => 'sale_price_dates' , 'label' => __ ( 'Sale Price Dates' , 'woothemes' ) );
$sale_price_dates_from = get_post_meta ( $thepostid , 'sale_price_dates_from' , true );
$sale_price_dates_to = get_post_meta ( $thepostid , 'sale_price_dates_to' , true );
2011-09-23 11:04:51 +00:00
echo ' < p class = " form-field sale_price_dates_fields " >
2011-11-06 13:45:18 +00:00
< label for = " '. $field['id'] .'_from " > '.$field[' label '].' </ label >
2011-09-20 15:05:07 +00:00
< input type = " text " class = " short " name = " '. $field['id'] .'_from " id = " '. $field['id'] .'_from " value = " ';
2011-08-21 13:28:54 +00:00
if ( $sale_price_dates_from ) echo date ( 'Y-m-d' , $sale_price_dates_from );
echo '" placeholder="' . __ ( 'From…' , 'woothemes' ) . ' " maxlength= " 10 " />
2011-09-20 15:05:07 +00:00
< input type = " text " class = " short " name = " '. $field['id'] .'_to " id = " '. $field['id'] .'_to " value = " ';
2011-08-21 13:28:54 +00:00
if ( $sale_price_dates_to ) echo date ( 'Y-m-d' , $sale_price_dates_to );
echo '" placeholder="' . __ ( 'To…' , 'woothemes' ) . ' " maxlength= " 10 " />
< span class = " description " > ' . __(' Date format ', ' woothemes ') . ' : < code > YYYY - MM - DD </ code ></ span >
</ p > ' ;
2011-09-05 11:56:26 +00:00
do_action ( 'woocommerce_product_options_pricing' );
2011-08-21 13:28:54 +00:00
echo '</div>' ;
2011-08-10 17:11:11 +00:00
2011-08-21 13:28:54 +00:00
echo '<div class="options_group">' ;
2011-08-10 17:11:11 +00:00
2011-08-21 13:28:54 +00:00
// Weight
if ( get_option ( 'woocommerce_enable_weight' , true ) !== 'no' ) :
woocommerce_wp_text_input ( array ( 'id' => 'weight' , 'label' => __ ( 'Weight' , 'woothemes' ) . ' (' . get_option ( 'woocommerce_weight_unit' ) . ')' , 'placeholder' => '0.00' ) );
else :
echo '<input type="hidden" name="weight" value="' . get_post_meta ( $thepostid , 'weight' , true ) . '" />' ;
endif ;
2011-09-05 11:56:26 +00:00
2011-10-08 11:57:04 +00:00
// Size fields
if ( get_option ( 'woocommerce_enable_dimensions' , true ) !== 'no' ) :
?> <p class="form-field dimensions_field">
< label for " product_length " >< ? php echo __ ( 'Dimensions' , 'woothemes' ) . ' (' . get_option ( 'woocommerce_dimension_unit' ) . ')' ; ?> </label>
< input id = " product_length " placeholder = " <?php _e('Length', 'woothemes'); ?> " class = " input-text sized " size = " 6 " type = " text " name = " length " value = " <?php echo get_post_meta( $thepostid , 'length', true ); ?> " />
< input placeholder = " <?php _e('Width', 'woothemes'); ?> " class = " input-text sized " size = " 6 " type = " text " name = " width " value = " <?php echo get_post_meta( $thepostid , 'width', true ); ?> " />
< input placeholder = " <?php _e('Height', 'woothemes'); ?> " class = " input-text sized " size = " 6 " type = " text " name = " height " value = " <?php echo get_post_meta( $thepostid , 'height', true ); ?> " />
</ p >< ? php
else :
echo '<input type="hidden" name="length" value="' . get_post_meta ( $thepostid , 'length' , true ) . '" />' ;
echo '<input type="hidden" name="width" value="' . get_post_meta ( $thepostid , 'width' , true ) . '" />' ;
echo '<input type="hidden" name="height" value="' . get_post_meta ( $thepostid , 'height' , true ) . '" />' ;
endif ;
do_action ( 'woocommerce_product_options_dimensions' );
2011-08-10 17:11:11 +00:00
2011-08-21 13:28:54 +00:00
echo '</div>' ;
2011-09-05 11:56:26 +00:00
do_action ( 'woocommerce_product_options_general_product_data' );
2011-08-17 23:42:07 +00:00
2011-08-10 17:11:11 +00:00
?>
</ div >
2011-08-21 13:28:54 +00:00
< div id = " tax_product_data " class = " panel woocommerce_options_panel " >
2011-08-10 17:11:11 +00:00
< ? php
2011-08-21 13:28:54 +00:00
2011-08-10 17:11:11 +00:00
// Tax
2011-08-17 23:42:07 +00:00
woocommerce_wp_select ( array ( 'id' => 'tax_status' , 'label' => __ ( 'Tax Status' , 'woothemes' ), 'options' => array (
'taxable' => __ ( 'Taxable' , 'woothemes' ),
'shipping' => __ ( 'Shipping only' , 'woothemes' ),
'none' => __ ( 'None' , 'woothemes' )
) ) );
2011-08-10 17:11:11 +00:00
2011-12-11 01:08:33 +00:00
$tax_classes = array_filter ( array_map ( 'trim' , explode ( " \n " , get_option ( 'woocommerce_tax_classes' ))));
2011-08-17 23:42:07 +00:00
$classes_options = array ();
$classes_options [ '' ] = __ ( 'Standard' , 'woothemes' );
2011-08-10 17:11:11 +00:00
if ( $tax_classes ) foreach ( $tax_classes as $class ) :
2011-08-17 23:42:07 +00:00
$classes_options [ sanitize_title ( $class )] = $class ;
2011-08-10 17:11:11 +00:00
endforeach ;
2011-08-17 23:42:07 +00:00
woocommerce_wp_select ( array ( 'id' => 'tax_class' , 'label' => __ ( 'Tax Class' , 'woothemes' ), 'options' => $classes_options ) );
2011-09-05 11:56:26 +00:00
do_action ( 'woocommerce_product_options_tax' );
2011-08-10 17:11:11 +00:00
?>
</ div >
< ? php if ( get_option ( 'woocommerce_manage_stock' ) == 'yes' ) : ?>
< div id = " inventory_product_data " class = " panel woocommerce_options_panel " >
< ? php
// manage stock
2011-11-05 19:03:03 +00:00
woocommerce_wp_checkbox ( array ( 'id' => 'manage_stock' , 'wrapper_class' => 'show_if_simple show_if_variable' , 'label' => __ ( 'Manage stock?' , 'woothemes' ) ) );
2011-08-10 17:11:11 +00:00
// Stock status
2011-08-17 23:42:07 +00:00
woocommerce_wp_select ( array ( 'id' => 'stock_status' , 'label' => __ ( 'Stock status' , 'woothemes' ), 'options' => array (
'instock' => __ ( 'In stock' , 'woothemes' ),
'outofstock' => __ ( 'Out of stock' , 'woothemes' )
) ) );
2011-08-10 17:11:11 +00:00
2011-09-05 11:56:26 +00:00
do_action ( 'woocommerce_product_options_stock' );
2011-11-05 19:03:03 +00:00
echo '<div class="stock_fields show_if_simple show_if_variable">' ;
2011-08-10 17:11:11 +00:00
// Stock
2011-08-17 23:42:07 +00:00
woocommerce_wp_text_input ( array ( 'id' => 'stock' , 'label' => __ ( 'Stock Qty' , 'woothemes' ) ) );
2011-08-10 17:11:11 +00:00
// Backorders?
2011-08-17 23:42:07 +00:00
woocommerce_wp_select ( array ( 'id' => 'backorders' , 'label' => __ ( 'Allow Backorders?' , 'woothemes' ), 'options' => array (
'no' => __ ( 'Do not allow' , 'woothemes' ),
'notify' => __ ( 'Allow, but notify customer' , 'woothemes' ),
'yes' => __ ( 'Allow' , 'woothemes' )
) ) );
2011-08-10 17:11:11 +00:00
2011-09-05 11:56:26 +00:00
do_action ( 'woocommerce_product_options_stock_fields' );
2011-08-10 17:11:11 +00:00
echo '</div>' ;
?>
</ div >
< ? php endif ; ?>
< div id = " woocommerce_attributes " class = " panel " >
< div class = " woocommerce_attributes_wrapper " >
< table cellpadding = " 0 " cellspacing = " 0 " class = " woocommerce_attributes " >
< thead >
< tr >
2011-11-07 14:13:04 +00:00
< th >& nbsp ; </ th >
2011-09-11 13:28:15 +00:00
< th width = " 180 " >< ? php _e ( 'Attribute Name' , 'woothemes' ); ?> </th>
< th >< ? php _e ( 'Value(s)' , 'woothemes' ); ?> <a class="tips" tip="<?php _e('Add multiple attributes for text attributes by pipe (|) separating values.', 'woothemes'); ?>" href="#">[?]</a></th>
< th class = " center " width = " 1% " >< ? php _e ( 'Visible?' , 'woothemes' ); ?> <a class="tips" tip="<?php _e('Enable this to show the attribute on the product page.', 'woothemes'); ?>" href="#">[?]</a></th>
2011-11-05 19:03:03 +00:00
< th class = " center enable_variation show_if_variable " width = " 1% " >< ? php _e ( 'Variation?' , 'woothemes' ); ?> <a class="tips" tip="<?php _e('Enable to use this attribute for variations.', 'woothemes'); ?>" href="#">[?]</a></th>
2011-08-10 17:11:11 +00:00
< th class = " center " width = " 1% " >< ? php _e ( 'Remove' , 'woothemes' ); ?> </th>
</ tr >
</ thead >
< tbody id = " attributes_list " >
< ? php
2011-09-11 13:28:15 +00:00
$attribute_taxonomies = $woocommerce -> get_attribute_taxonomies (); // Array of defined attribute taxonomies
$attributes = maybe_unserialize ( get_post_meta ( $thepostid , 'product_attributes' , true ) ); // Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set
2011-08-10 17:11:11 +00:00
$i = - 1 ;
// Taxonomies
if ( $attribute_taxonomies ) :
foreach ( $attribute_taxonomies as $tax ) : $i ++ ;
2011-09-11 13:28:15 +00:00
// Get name of taxonomy we're now outputting (pa_xxx)
$attribute_taxonomy_name = $woocommerce -> attribute_taxonomy_name ( $tax -> attribute_name );
// Ensure it exists
if ( ! taxonomy_exists ( $attribute_taxonomy_name )) continue ;
// Get product data values for current taxonomy - this contains ordering and visibility data
if ( isset ( $attributes [ $attribute_taxonomy_name ])) $attribute = $attributes [ $attribute_taxonomy_name ];
$position = ( isset ( $attribute [ 'position' ])) ? $attribute [ 'position' ] : 0 ;
// Get terms of this taxonomy associated with current product
$post_terms = wp_get_post_terms ( $thepostid , $attribute_taxonomy_name );
2011-08-10 17:11:11 +00:00
2011-09-11 13:28:15 +00:00
// Any set?
$has_terms = ( is_wp_error ( $post_terms ) || ! $post_terms || sizeof ( $post_terms ) == 0 ) ? 0 : 1 ;
?> <tr class="taxonomy <?php echo $attribute_taxonomy_name; ?>" rel="<?php echo $position; ?>" <?php if (!$has_terms) echo 'style="display:none"'; ?>>
2011-11-07 14:13:04 +00:00
< td class = " handle " ></ td >
2011-08-10 17:11:11 +00:00
< td class = " name " >
2011-09-11 13:28:15 +00:00
< ? php echo ( $tax -> attribute_label ) ? $tax -> attribute_label : $tax -> attribute_name ; ?>
2011-09-19 06:01:26 +00:00
< input type = " hidden " name = " attribute_names[<?php echo $i ; ?>] " value = " <?php echo esc_attr( $attribute_taxonomy_name ); ?> " />
2011-09-19 14:32:53 +00:00
< input type = " hidden " name = " attribute_position[<?php echo $i ; ?>] " class = " attribute_position " value = " <?php echo esc_attr( $position ); ?> " />
2011-08-10 17:11:11 +00:00
< input type = " hidden " name = " attribute_is_taxonomy[<?php echo $i ; ?>] " value = " 1 " />
</ td >
2011-09-11 17:33:26 +00:00
< td class = " values " >
2011-09-11 13:28:15 +00:00
< ? php if ( $tax -> attribute_type == " select " ) : ?>
2011-11-23 17:28:58 +00:00
< select multiple = " multiple " data - placeholder = " <?php _e('Select terms', 'woothemes'); ?> " class = " multiselect " name = " attribute_values[<?php echo $i ; ?>][] " >
2011-08-10 17:11:11 +00:00
< ? php
2011-09-11 13:28:15 +00:00
$all_terms = get_terms ( $attribute_taxonomy_name , 'orderby=name&hide_empty=0' );
if ( $all_terms ) :
foreach ( $all_terms as $term ) :
$has_term = ( has_term ( $term -> slug , $attribute_taxonomy_name , $thepostid ) ) ? 1 : 0 ;
echo '<option value="' . $term -> slug . '" ' . selected ( $has_term , 1 , false ) . '>' . $term -> name . '</option>' ;
endforeach ;
2011-08-10 17:11:11 +00:00
endif ;
?>
</ select >
< ? php elseif ( $tax -> attribute_type == " text " ) : ?>
2011-08-26 21:28:55 +00:00
< input type = " text " name = " attribute_values[<?php echo $i ; ?>] " value = " <?php
2011-09-11 13:28:15 +00:00
// Text attributes should list terms pipe separated
if ( $post_terms ) :
$values = array ();
foreach ( $post_terms as $term ) :
$values [] = $term -> name ;
endforeach ;
echo implode ( '|' , $values );
2011-08-26 21:28:55 +00:00
endif ;
2011-09-11 13:28:15 +00:00
?> " placeholder="<?php _e('Pipe separate terms', 'woothemes'); ?>" />
2011-08-10 17:11:11 +00:00
< ? php endif ; ?>
</ td >
2011-09-28 09:49:23 +00:00
< td class = " center " >< input type = " checkbox " < ? php if ( isset ( $attribute [ 'is_visible' ])) checked ( $attribute [ 'is_visible' ], 1 ); ?> name="attribute_visibility[<?php echo $i; ?>]" value="1" /></td>
2011-11-05 19:03:03 +00:00
< td class = " center enable_variation show_if_variable " >< input type = " checkbox " < ? php if ( isset ( $attribute [ 'is_variation' ])) checked ( $attribute [ 'is_variation' ], 1 ); ?> name="attribute_variation[<?php echo $i; ?>]" value="1" /></td>
2011-08-10 17:11:11 +00:00
< td class = " center " >< button type = " button " class = " hide_row button " >& times ; </ button ></ td >
</ tr >< ? php
endforeach ;
endif ;
2011-09-11 13:28:15 +00:00
// Custom Attributes
2011-08-10 17:11:11 +00:00
if ( $attributes && sizeof ( $attributes ) > 0 ) foreach ( $attributes as $attribute ) :
2011-09-10 20:21:44 +00:00
if ( $attribute [ 'is_taxonomy' ]) continue ;
2011-08-10 17:11:11 +00:00
$i ++ ;
2011-09-11 13:28:15 +00:00
$position = ( isset ( $attribute [ 'position' ])) ? $attribute [ 'position' ] : 0 ;
2011-08-10 17:11:11 +00:00
?> <tr rel="<?php if (isset($attribute['position'])) echo $attribute['position']; else echo '0'; ?>">
2011-11-07 14:13:04 +00:00
< td class = " handle " ></ td >
2011-08-10 17:11:11 +00:00
< td >
2011-09-19 06:01:26 +00:00
< input type = " text " name = " attribute_names[<?php echo $i ; ?>] " value = " <?php echo esc_attr( $attribute['name'] ); ?> " />
2011-09-19 14:32:53 +00:00
< input type = " hidden " name = " attribute_position[<?php echo $i ; ?>] " class = " attribute_position " value = " <?php echo esc_attr( $position ); ?> " />
2011-08-10 17:11:11 +00:00
< input type = " hidden " name = " attribute_is_taxonomy[<?php echo $i ; ?>] " value = " 0 " />
</ td >
2011-11-28 10:29:23 +00:00
< td >< textarea name = " attribute_values[<?php echo $i ; ?>] " cols = " 5 " rows = " 2 " >< ? php echo esc_textarea ( $attribute [ 'value' ] ); ?> </textarea></td>
2011-09-10 20:21:44 +00:00
< td class = " center " >< input type = " checkbox " < ? php checked ( $attribute [ 'is_visible' ], 1 ); ?> name="attribute_visibility[<?php echo $i; ?>]" value="1" /></td>
2011-11-05 19:03:03 +00:00
< td class = " center enable_variation show_if_variable " >< input type = " checkbox " < ? php checked ( $attribute [ 'is_variation' ], 1 ); ?> name="attribute_variation[<?php echo $i; ?>]" value="1" /></td>
2011-08-10 17:11:11 +00:00
< td class = " center " >< button type = " button " class = " remove_row button " >& times ; </ button ></ td >
</ tr >< ? php
endforeach ;
?>
</ tbody >
</ table >
</ div >
< button type = " button " class = " button button-primary add_attribute " >< ? php _e ( 'Add' , 'woothemes' ); ?> </button>
< select name = " attribute_taxonomy " class = " attribute_taxonomy " >
< option value = " " >< ? php _e ( 'Custom product attribute' , 'woothemes' ); ?> </option>
< ? php
if ( $attribute_taxonomies ) :
foreach ( $attribute_taxonomies as $tax ) :
2011-09-11 13:28:15 +00:00
$attribute_taxonomy_name = $woocommerce -> attribute_taxonomy_name ( $tax -> attribute_name );
$label = ( $tax -> attribute_label ) ? $tax -> attribute_label : $tax -> attribute_name ;
echo '<option value="' . $attribute_taxonomy_name . '">' . $label . '</option>' ;
2011-08-10 17:11:11 +00:00
endforeach ;
endif ;
?>
</ select >
< div class = " clear " ></ div >
</ div >
2011-11-05 19:03:03 +00:00
< div id = " upsells_and_crosssells_product_data " class = " panel woocommerce_options_panel " >
< div class = " multi_select_products_wrapper " >< h4 >< ? php _e ( 'Products' , 'woothemes' ); ?> </h4>
2011-08-11 10:51:33 +00:00
< ul class = " multi_select_products multi_select_products_source " >
< li class = " product_search " >< input type = " search " rel = " upsell_ids " name = " product_search " id = " product_search " placeholder = " <?php _e('Search for product', 'woothemes'); ?> " />< div class = " clear " ></ div ></ li >
</ ul >
</ div >
2011-11-05 19:03:03 +00:00
< div class = " multi_select_products_wrapper multi_select_products_wrapper-alt " >
2011-08-11 10:51:33 +00:00
2011-11-05 19:03:03 +00:00
< h4 >< ? php _e ( 'Up-Sells' , 'woothemes' ); ?> </h4>
< ? 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.' , 'woothemes' ); ?>
< ul class = " multi_select_products multi_select_products_target_upsell " >
< ? php
$upsell_ids = get_post_meta ( $thepostid , 'upsell_ids' , true );
if ( ! $upsell_ids ) $upsell_ids = array ( 0 );
woocommerce_product_selection_list_remove ( $upsell_ids , 'upsell_ids' );
?>
2011-08-11 10:51:33 +00:00
</ ul >
2011-11-05 19:03:03 +00:00
< h4 >< ? php _e ( 'Cross-Sells' , 'woothemes' ); ?> </h4>
< ? php _e ( 'Cross-sells are products which you promote in the cart, based on the current product.' , 'woothemes' ); ?>
< ul class = " multi_select_products multi_select_products_target_crosssell " >
2011-08-11 10:51:33 +00:00
< ? php
2011-08-17 23:42:07 +00:00
$crosssell_ids = get_post_meta ( $thepostid , 'crosssell_ids' , true );
if ( ! $crosssell_ids ) $crosssell_ids = array ( 0 );
2011-08-11 10:51:33 +00:00
woocommerce_product_selection_list_remove ( $crosssell_ids , 'crosssell_ids' );
?>
2011-11-05 19:03:03 +00:00
</ ul >
2011-08-11 10:51:33 +00:00
</ div >
2011-11-05 19:03:03 +00:00
< div class = " clear " ></ div >
</ div >
< div id = " grouping_product_data " class = " panel woocommerce_options_panel " >
< ? php
echo '<div class="options_group grouping">' ;
// List Grouped products
$post_parents = array ();
$post_parents [ '' ] = __ ( 'Choose a grouped product…' , 'woothemes' );
$posts_in = array_unique (( array ) get_objects_in_term ( get_term_by ( 'slug' , 'grouped' , 'product_type' ) -> term_id , 'product_type' ));
if ( sizeof ( $posts_in ) > 0 ) :
$args = array (
'post_type' => 'product' ,
'post_status' => 'publish' ,
'numberposts' => - 1 ,
'orderby' => 'title' ,
'order' => 'asc' ,
'post_parent' => 0 ,
'include' => $posts_in ,
);
$grouped_products = get_posts ( $args );
$loop = 0 ;
if ( $grouped_products ) : foreach ( $grouped_products as $product ) :
if ( $product -> ID == $post -> ID ) continue ;
$post_parents [ $product -> ID ] = $product -> post_title ;
endforeach ; endif ;
endif ;
woocommerce_wp_select ( array ( 'id' => 'parent_id' , 'label' => __ ( 'Grouping' , 'woothemes' ), 'value' => $post -> post_parent , 'options' => $post_parents ) );
// Ordering
woocommerce_wp_text_input ( array ( 'id' => 'menu_order' , 'label' => _x ( 'Sort Order' , 'ordering' , 'woothemes' ), 'value' => $post -> menu_order ) );
do_action ( 'woocommerce_product_options_grouping' );
echo '</div>' ;
?>
</ div >
< div id = " downloadable_product_data " class = " panel woocommerce_options_panel " >
< ? php
// File URL
$file_path = get_post_meta ( $post -> ID , 'file_path' , true );
$field = array ( 'id' => 'file_path' , 'label' => __ ( 'File path' , 'woothemes' ) );
echo '<p class="form-field"><label for="' . $field [ 'id' ] . '">' . $field [ 'label' ] . ' :</ label >
2011-11-09 23:06:17 +00:00
< input type = " text " class = " short file_path " name = " '. $field['id'] .' " id = " '. $field['id'] .' " value = " '. $file_path .' " placeholder = " '.__('File path/URL', 'woothemes').' " />
2011-11-05 19:03:03 +00:00
< input type = " button " class = " upload_file_button button " value = " '.__('Upload a file', 'woothemes').' " />
</ p > ' ;
// Download Limit
$download_limit = get_post_meta ( $post -> ID , 'download_limit' , true );
$field = array ( 'id' => 'download_limit' , 'label' => __ ( 'Download Limit' , 'woothemes' ) );
echo ' < p class = " form-field " >
< label for = " '. $field['id'] .' " > '.$field[' label '].' :</ label >
2011-11-09 23:06:17 +00:00
< input type = " text " class = " short " name = " '. $field['id'] .' " id = " '. $field['id'] .' " value = " '. $download_limit .' " placeholder = " '.__('Unlimited', 'woothemes').' " /> < span class = " description " > ' . __(' Leave blank for unlimited re - downloads . ', ' woothemes ') . ' </ span ></ p > ' ;
2011-11-05 19:03:03 +00:00
?>
</ div >
2011-08-10 17:11:11 +00:00
2011-09-21 15:43:37 +00:00
< ? php do_action ( 'woocommerce_product_write_panels' ); ?>
2011-08-10 17:11:11 +00:00
</ div >
< ? php
}
/**
* Product Data Save
*
* Function for processing and storing all product data .
*/
add_action ( 'woocommerce_process_product_meta' , 'woocommerce_process_product_meta' , 1 , 2 );
function woocommerce_process_product_meta ( $post_id , $post ) {
2011-09-06 11:11:22 +00:00
global $wpdb , $woocommerce ;
2011-08-10 17:11:11 +00:00
$woocommerce_errors = array ();
2011-08-17 23:42:07 +00:00
// Update post meta
update_post_meta ( $post_id , 'regular_price' , stripslashes ( $_POST [ 'regular_price' ] ) );
update_post_meta ( $post_id , 'sale_price' , stripslashes ( $_POST [ 'sale_price' ] ) );
update_post_meta ( $post_id , 'weight' , stripslashes ( $_POST [ 'weight' ] ) );
2011-10-08 11:57:04 +00:00
update_post_meta ( $post_id , 'length' , stripslashes ( $_POST [ 'length' ] ) );
update_post_meta ( $post_id , 'width' , stripslashes ( $_POST [ 'width' ] ) );
update_post_meta ( $post_id , 'height' , stripslashes ( $_POST [ 'height' ] ) );
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'tax_status' , stripslashes ( $_POST [ 'tax_status' ] ) );
update_post_meta ( $post_id , 'tax_class' , stripslashes ( $_POST [ 'tax_class' ] ) );
2011-08-18 23:14:35 +00:00
update_post_meta ( $post_id , 'stock_status' , stripslashes ( $_POST [ 'stock_status' ] ) );
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'visibility' , stripslashes ( $_POST [ 'visibility' ] ) );
2011-11-05 19:03:03 +00:00
if ( isset ( $_POST [ 'featured' ])) update_post_meta ( $post_id , 'featured' , 'yes' ); else update_post_meta ( $post_id , 'featured' , 'no' );
2011-08-10 17:11:11 +00:00
2011-08-17 23:42:07 +00:00
// Unique SKU
$sku = get_post_meta ( $post_id , 'sku' , true );
$new_sku = stripslashes ( $_POST [ 'sku' ] );
if ( $new_sku !== $sku ) :
if ( $new_sku && ! empty ( $new_sku )) :
2011-10-01 22:58:04 +00:00
if (
$wpdb -> get_var ( $wpdb -> prepare ( " SELECT * FROM $wpdb->postmeta WHERE meta_key='sku' AND meta_value='%s'; " , $new_sku )) ||
$wpdb -> get_var ( $wpdb -> prepare ( " SELECT * FROM $wpdb->posts WHERE ID='%s' AND ID!='%s' AND post_type='product'; " , $new_sku , $post_id ))
) :
2011-08-17 23:42:07 +00:00
$woocommerce_errors [] = __ ( 'Product SKU must be unique.' , 'woothemes' );
2011-08-10 17:11:11 +00:00
else :
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'sku' , $new_sku );
2011-08-10 17:11:11 +00:00
endif ;
2011-08-17 23:42:07 +00:00
else :
update_post_meta ( $post_id , 'sku' , '' );
2011-08-10 17:11:11 +00:00
endif ;
2011-08-17 23:42:07 +00:00
endif ;
2011-08-10 17:11:11 +00:00
2011-09-11 13:28:15 +00:00
// Save Attributes
2011-08-17 23:42:07 +00:00
$attributes = array ();
2011-08-10 17:11:11 +00:00
2011-08-17 23:42:07 +00:00
if ( isset ( $_POST [ 'attribute_names' ])) :
$attribute_names = $_POST [ 'attribute_names' ];
$attribute_values = $_POST [ 'attribute_values' ];
if ( isset ( $_POST [ 'attribute_visibility' ])) $attribute_visibility = $_POST [ 'attribute_visibility' ];
if ( isset ( $_POST [ 'attribute_variation' ])) $attribute_variation = $_POST [ 'attribute_variation' ];
$attribute_is_taxonomy = $_POST [ 'attribute_is_taxonomy' ];
$attribute_position = $_POST [ 'attribute_position' ];
for ( $i = 0 ; $i < sizeof ( $attribute_names ); $i ++ ) :
if ( ! ( $attribute_names [ $i ])) continue ;
2011-09-10 20:21:44 +00:00
$is_visible = ( isset ( $attribute_visibility [ $i ])) ? 1 : 0 ;
$is_variation = ( isset ( $attribute_variation [ $i ])) ? 1 : 0 ;
2011-08-17 23:42:07 +00:00
2011-09-11 13:28:15 +00:00
$is_taxonomy = ( $attribute_is_taxonomy [ $i ]) ? 1 : 0 ;
2011-08-17 23:42:07 +00:00
2011-09-10 20:21:44 +00:00
if ( $is_taxonomy ) :
2011-09-11 13:28:15 +00:00
// Format values
if ( is_array ( $attribute_values [ $i ])) :
$values = array_map ( 'htmlspecialchars' , array_map ( 'stripslashes' , $attribute_values [ $i ]));
else :
$values = htmlspecialchars ( stripslashes ( $attribute_values [ $i ]));
// Text based, separate by pipe
$values = explode ( '|' , $values );
$values = array_map ( 'trim' , $values );
endif ;
2011-10-01 22:21:44 +00:00
// Remove empty items in the array
$values = array_filter ( $values );
2011-09-11 13:28:15 +00:00
2011-08-17 23:42:07 +00:00
// Update post terms
2011-09-11 13:28:15 +00:00
if ( taxonomy_exists ( $attribute_names [ $i ] )) :
wp_set_object_terms ( $post_id , $values , $attribute_names [ $i ] );
2011-08-17 23:42:07 +00:00
endif ;
2011-10-01 22:21:44 +00:00
if ( $values ) :
// Add attribute to array, but don't set values
$attributes [ sanitize_title ( $attribute_names [ $i ] ) ] = array (
'name' => htmlspecialchars ( stripslashes ( $attribute_names [ $i ])),
'value' => '' ,
'position' => $attribute_position [ $i ],
'is_visible' => $is_visible ,
'is_variation' => $is_variation ,
'is_taxonomy' => $is_taxonomy
);
endif ;
2011-09-11 13:28:15 +00:00
else :
// Format values
2011-11-18 17:27:45 +00:00
$values = esc_html ( stripslashes ( $attribute_values [ $i ]));
2011-09-27 19:05:02 +00:00
// Text based, separate by pipe
$values = explode ( '|' , $values );
$values = array_map ( 'trim' , $values );
$values = implode ( '|' , $values );
2011-09-11 13:28:15 +00:00
// Custom attribute - Add attribute to array and set the values
$attributes [ sanitize_title ( $attribute_names [ $i ] ) ] = array (
'name' => htmlspecialchars ( stripslashes ( $attribute_names [ $i ])),
'value' => $values ,
'position' => $attribute_position [ $i ],
'is_visible' => $is_visible ,
'is_variation' => $is_variation ,
'is_taxonomy' => $is_taxonomy
);
2011-08-17 23:42:07 +00:00
endif ;
endfor ;
endif ;
2011-08-10 17:11:11 +00:00
2011-08-17 23:42:07 +00:00
if ( ! function_exists ( 'attributes_cmp' )) {
function attributes_cmp ( $a , $b ) {
2011-11-05 19:03:03 +00:00
if ( $a [ 'position' ] == $b [ 'position' ]) return 0 ;
2011-08-17 23:42:07 +00:00
return ( $a [ 'position' ] < $b [ 'position' ]) ? - 1 : 1 ;
}
}
uasort ( $attributes , 'attributes_cmp' );
update_post_meta ( $post_id , 'product_attributes' , $attributes );
2011-11-05 19:03:03 +00:00
// Product type + Downloadable/Virtual
2011-08-17 23:42:07 +00:00
$product_type = sanitize_title ( stripslashes ( $_POST [ 'product-type' ] ) );
2011-11-05 19:03:03 +00:00
$is_downloadable = ( isset ( $_POST [ 'downloadable' ])) ? 'yes' : 'no' ;
$is_virtual = ( isset ( $_POST [ 'virtual' ])) ? 'yes' : 'no' ;
2011-08-17 23:42:07 +00:00
if ( ! $product_type ) $product_type = 'simple' ;
wp_set_object_terms ( $post_id , $product_type , 'product_type' );
2011-11-05 19:03:03 +00:00
update_post_meta ( $post_id , 'downloadable' , $is_downloadable );
update_post_meta ( $post_id , 'virtual' , $is_virtual );
2011-11-13 02:15:00 +00:00
// Set transient for product type
set_transient ( 'woocommerce_product_type_' . $post_id , $product_type );
2011-08-17 23:42:07 +00:00
// Sales and prices
2011-11-08 16:15:36 +00:00
if ( $product_type == 'simple' || $product_type == 'external' ) :
2011-08-17 23:42:07 +00:00
$date_from = ( isset ( $_POST [ 'sale_price_dates_from' ])) ? $_POST [ 'sale_price_dates_from' ] : '' ;
$date_to = ( isset ( $_POST [ 'sale_price_dates_to' ])) ? $_POST [ 'sale_price_dates_to' ] : '' ;
2011-08-10 17:11:11 +00:00
2011-08-17 23:42:07 +00:00
// Dates
if ( $date_from ) :
update_post_meta ( $post_id , 'sale_price_dates_from' , strtotime ( $date_from ) );
2011-08-10 17:11:11 +00:00
else :
update_post_meta ( $post_id , 'sale_price_dates_from' , '' );
endif ;
2011-08-17 23:42:07 +00:00
if ( $date_to ) :
update_post_meta ( $post_id , 'sale_price_dates_to' , strtotime ( $date_to ) );
else :
update_post_meta ( $post_id , 'sale_price_dates_to' , '' );
endif ;
2011-08-10 17:11:11 +00:00
2011-08-17 23:42:07 +00:00
if ( $date_to && ! $date_from ) :
2011-12-03 16:50:51 +00:00
update_post_meta ( $post_id , 'sale_price_dates_from' , strtotime ( 'NOW' , current_time ( 'timestamp' )) );
2011-08-17 23:42:07 +00:00
endif ;
2011-08-10 17:11:11 +00:00
2011-08-17 23:42:07 +00:00
// Update price if on sale
2011-12-03 16:50:51 +00:00
if ( $_POST [ 'sale_price' ] != '' && $date_to == '' && $date_from == '' ) :
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'price' , stripslashes ( $_POST [ 'sale_price' ]) );
else :
update_post_meta ( $post_id , 'price' , stripslashes ( $_POST [ 'regular_price' ]) );
endif ;
2011-12-03 16:50:51 +00:00
if ( $date_from && strtotime ( $date_from ) < strtotime ( 'NOW' , current_time ( 'timestamp' ))) :
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'price' , stripslashes ( $_POST [ 'sale_price' ]) );
2011-08-10 17:11:11 +00:00
endif ;
2011-12-03 16:50:51 +00:00
if ( $date_to && strtotime ( $date_to ) < strtotime ( 'NOW' , current_time ( 'timestamp' ))) :
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'price' , stripslashes ( $_POST [ 'regular_price' ]) );
update_post_meta ( $post_id , 'sale_price_dates_from' , '' );
update_post_meta ( $post_id , 'sale_price_dates_to' , '' );
2011-08-11 10:51:33 +00:00
endif ;
2011-09-23 11:04:51 +00:00
2011-08-17 23:42:07 +00:00
else :
2011-08-11 10:51:33 +00:00
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'regular_price' , '' );
update_post_meta ( $post_id , 'sale_price' , '' );
update_post_meta ( $post_id , 'sale_price_dates_from' , '' );
update_post_meta ( $post_id , 'sale_price_dates_to' , '' );
update_post_meta ( $post_id , 'price' , '' );
2011-08-11 10:51:33 +00:00
2011-08-17 23:42:07 +00:00
endif ;
2011-09-23 11:04:51 +00:00
// Update parent if grouped so price sorting works and stays in sync with the cheapest child
if ( $post -> post_parent > 0 || $product_type == 'grouped' ) :
2011-09-23 08:38:09 +00:00
$post_parent = ( $post -> post_parent > 0 ) ? $post -> post_parent : $post_id ;
2011-09-03 22:37:16 +00:00
$children_by_price = get_posts ( array (
'post_parent' => $post_parent ,
2011-11-18 12:32:59 +00:00
'orderby' => 'meta_value_num' ,
'order' => 'asc' ,
'meta_key' => 'price' ,
'posts_per_page' => 1 ,
2011-09-23 08:38:09 +00:00
'post_type' => 'product' ,
'fields' => 'ids'
2011-09-03 22:37:16 +00:00
));
if ( $children_by_price ) :
2011-09-23 08:38:09 +00:00
foreach ( $children_by_price as $child ) :
$child_price = get_post_meta ( $child , 'price' , true );
update_post_meta ( $post_parent , 'price' , $child_price );
endforeach ;
2011-08-11 10:51:33 +00:00
endif ;
2011-11-18 01:19:24 +00:00
// Clear cache/transients
$woocommerce -> clear_product_transients ( $post_parent );
2011-08-17 23:42:07 +00:00
endif ;
// Stock Data
if ( get_option ( 'woocommerce_manage_stock' ) == 'yes' ) :
// Manage Stock Checkbox
if ( $product_type !== 'grouped' && isset ( $_POST [ 'manage_stock' ]) && $_POST [ 'manage_stock' ]) :
update_post_meta ( $post_id , 'stock' , $_POST [ 'stock' ] );
update_post_meta ( $post_id , 'manage_stock' , 'yes' );
update_post_meta ( $post_id , 'backorders' , stripslashes ( $_POST [ 'backorders' ] ) );
2011-08-21 13:28:54 +00:00
if ( $product_type !== 'variable' && $_POST [ 'backorders' ] == 'no' && $_POST [ 'stock' ] < 1 ) :
2011-08-18 23:14:35 +00:00
update_post_meta ( $post_id , 'stock_status' , 'outofstock' );
endif ;
2011-11-08 16:15:36 +00:00
elseif ( $product_type !== 'external' ) :
2011-08-17 23:42:07 +00:00
update_post_meta ( $post_id , 'stock' , '0' );
update_post_meta ( $post_id , 'manage_stock' , 'no' );
update_post_meta ( $post_id , 'backorders' , 'no' );
2011-11-08 16:15:36 +00:00
else :
update_post_meta ( $post_id , 'stock_status' , 'instock' );
update_post_meta ( $post_id , 'stock' , '0' );
update_post_meta ( $post_id , 'manage_stock' , 'no' );
update_post_meta ( $post_id , 'backorders' , 'no' );
2011-08-17 23:42:07 +00:00
endif ;
endif ;
// Upsells
if ( isset ( $_POST [ 'upsell_ids' ])) :
$upsells = array ();
$ids = $_POST [ 'upsell_ids' ];
foreach ( $ids as $id ) :
if ( $id && $id > 0 ) $upsells [] = $id ;
endforeach ;
update_post_meta ( $post_id , 'upsell_ids' , $upsells );
2011-10-22 12:14:31 +00:00
else :
delete_post_meta ( $post_id , 'upsell_ids' );
2011-08-17 23:42:07 +00:00
endif ;
// Cross sells
if ( isset ( $_POST [ 'crosssell_ids' ])) :
$crosssells = array ();
$ids = $_POST [ 'crosssell_ids' ];
foreach ( $ids as $id ) :
if ( $id && $id > 0 ) $crosssells [] = $id ;
endforeach ;
update_post_meta ( $post_id , 'crosssell_ids' , $crosssells );
2011-10-22 12:14:31 +00:00
else :
delete_post_meta ( $post_id , 'crosssell_ids' );
2011-08-17 23:42:07 +00:00
endif ;
2011-11-05 19:03:03 +00:00
// Downloadable options
if ( $is_downloadable == 'yes' ) :
2011-11-08 16:15:36 +00:00
if ( isset ( $_POST [ 'file_path' ]) && $_POST [ 'file_path' ]) update_post_meta ( $post_id , 'file_path' , esc_attr ( $_POST [ 'file_path' ]) );
if ( isset ( $_POST [ 'download_limit' ])) update_post_meta ( $post_id , 'download_limit' , esc_attr ( $_POST [ 'download_limit' ]) );
endif ;
// Product url
if ( $product_type == 'external' ) :
if ( isset ( $_POST [ 'product_url' ]) && $_POST [ 'product_url' ]) update_post_meta ( $post_id , 'product_url' , esc_attr ( $_POST [ 'product_url' ]) );
2011-11-05 19:03:03 +00:00
endif ;
2011-09-23 11:04:51 +00:00
2011-08-17 23:42:07 +00:00
// Do action for product type
2011-09-21 15:43:37 +00:00
do_action ( 'woocommerce_process_product_meta_' . $product_type , $post_id );
2011-11-04 20:46:06 +00:00
// Clear cache/transients
2011-11-13 12:07:29 +00:00
$woocommerce -> clear_product_transients ( $post_id );
2011-08-10 17:11:11 +00:00
2011-08-17 23:42:07 +00:00
// Save errors
2011-08-10 17:11:11 +00:00
update_option ( 'woocommerce_errors' , $woocommerce_errors );
2011-08-11 10:51:33 +00:00
}
/**
* Outputs product list in selection boxes
**/
function woocommerce_product_selection_list_remove ( $posts_to_display , $name ) {
global $thepostid ;
$args = array (
'post_type' => 'product' ,
'post_status' => 'publish' ,
'numberposts' => - 1 ,
'orderby' => 'title' ,
'order' => 'asc' ,
'include' => $posts_to_display ,
);
$related_posts = get_posts ( $args );
$loop = 0 ;
if ( $related_posts ) : foreach ( $related_posts as $related_post ) :
if ( $related_post -> ID == $thepostid ) continue ;
2011-08-17 23:42:07 +00:00
$SKU = get_post_meta ( $related_post -> ID , 'sku' , true );
2011-08-11 10:51:33 +00:00
2011-11-06 13:45:18 +00:00
?> <li rel="<?php echo $related_post->ID; ?>"><button type="button" name="Remove" class="button remove" title="Remove">×</button><strong><?php echo $related_post->post_title; ?></strong> – #<?php echo $related_post->ID; ?> <?php if (isset($SKU) && $SKU) echo 'SKU: '.$SKU; ?><input type="hidden" name="<?php echo esc_attr( $name ); ?>[]" value="<?php echo esc_attr( $related_post->ID ); ?>" /></li><?php
2011-08-11 10:51:33 +00:00
endforeach ; endif ;
2011-08-21 13:28:54 +00:00
}
/**
* Procuct type panel
**/
function woocommerce_product_type_box () {
global $post , $thepostid ;
$thepostid = $post -> ID ;
echo '<div class="woocommerce_options_panel">' ;
// Product Type
if ( $terms = wp_get_object_terms ( $thepostid , 'product_type' )) $product_type = current ( $terms ) -> slug ; else $product_type = 'simple' ;
woocommerce_wp_select ( array ( 'id' => 'product-type' , 'label' => __ ( 'Product Type' , 'woothemes' ), 'value' => $product_type , 'options' => apply_filters ( 'product_type_selector' , array (
2011-11-05 19:03:03 +00:00
'simple' => __ ( 'Simple product' , 'woothemes' ),
2011-11-08 16:15:36 +00:00
'grouped' => __ ( 'Grouped product' , 'woothemes' ),
'external' => __ ( 'External/Affiliate product' , 'woothemes' )
2011-08-21 13:28:54 +00:00
), $product_type ) ) );
// Visibility
2011-11-05 19:03:03 +00:00
woocommerce_wp_select ( array ( 'id' => 'visibility' , 'label' => __ ( 'Product visibility' , 'woothemes' ), 'options' => array (
2011-08-21 13:28:54 +00:00
'visible' => __ ( 'Catalog & Search' , 'woothemes' ),
'catalog' => __ ( 'Catalog' , 'woothemes' ),
'search' => __ ( 'Search' , 'woothemes' ),
'hidden' => __ ( 'Hidden' , 'woothemes' )
) ) );
2011-11-09 23:06:17 +00:00
woocommerce_wp_checkbox ( array ( 'id' => 'virtual' , 'wrapper_class' => 'show_if_simple' , 'label' => __ ( 'Virtual' , 'woothemes' ), 'description' => __ ( 'Enable this option if a product is not shipped or there is no shipping cost' , 'woothemes' ) ) );
2011-11-05 19:03:03 +00:00
2011-11-09 23:06:17 +00:00
woocommerce_wp_checkbox ( array ( 'id' => 'downloadable' , 'wrapper_class' => 'show_if_simple' , 'label' => __ ( 'Downloadable' , 'woothemes' ), 'description' => __ ( 'Enable this option if access is given to a downloadable file upon purchase of a product' , 'woothemes' ) ) );
2011-11-05 19:03:03 +00:00
2011-08-21 13:28:54 +00:00
// Featured
2011-11-05 19:03:03 +00:00
woocommerce_wp_checkbox ( array ( 'id' => 'featured' , 'label' => __ ( 'Featured' , 'woothemes' ), 'description' => __ ( 'Enable this option to feature this product' , 'woothemes' ) ) );
2011-08-21 13:28:54 +00:00
echo '</div>' ;
2011-11-05 19:03:03 +00:00
}
/**
2011-11-09 23:06:17 +00:00
* Change label for insert buttons
2011-11-05 19:03:03 +00:00
*/
add_filter ( 'gettext' , 'woocommerce_change_insert_into_post' , null , 2 );
function woocommerce_change_insert_into_post ( $translation , $original ) {
if ( ! isset ( $_REQUEST [ 'from' ] ) ) return $translation ;
if ( $_REQUEST [ 'from' ] == 'wc01' && $original == 'Insert into Post' ) return __ ( 'Insert into URL field' , 'woothemes' );
return $translation ;
2011-08-10 17:11:11 +00:00
}