order meta, loop visibility

This commit is contained in:
Mike Jolley 2011-08-19 21:11:04 +01:00
parent e286b11ff5
commit 8c4e69f707
14 changed files with 184 additions and 209 deletions

View File

@ -21,7 +21,7 @@ $options_settings = apply_filters('woocommerce_options_settings', array(
array( 'type' => 'tab', 'tabname' => __('General', 'woothemes') ),
array( 'name' => 'General settings', 'type' => 'title', 'desc' => '' ),
array( 'name' => 'General Options', 'type' => 'title', 'desc' => '' ),
array(
'name' => __('Base Country/Region', 'woothemes'),
@ -213,7 +213,7 @@ $options_settings = apply_filters('woocommerce_options_settings', array(
array( 'type' => 'tab', 'tabname' => __('Catalog', 'woothemes') ),
array( 'name' => __('Catalog Settings', 'woothemes'), 'type' => 'title','desc' => '', 'id' => '' ),
array( 'name' => __('Catalog Options', 'woothemes'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Product fields', 'woothemes'),
@ -255,7 +255,7 @@ $options_settings = apply_filters('woocommerce_options_settings', array(
array( 'type' => 'sectionend'),
array( 'name' => __('Pricing Settings', 'woothemes'), 'type' => 'title','desc' => '', 'id' => '' ),
array( 'name' => __('Pricing Options', 'woothemes'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Currency', 'woothemes'),
@ -341,7 +341,7 @@ $options_settings = apply_filters('woocommerce_options_settings', array(
array( 'type' => 'sectionend'),
array( 'name' => __('Inventory Settings', 'woothemes'), 'type' => 'title','desc' => '', 'id' => '' ),
array( 'name' => __('Inventory Options', 'woothemes'), 'type' => 'title','desc' => '', 'id' => '' ),
array(
'name' => __('Manage stock', 'woothemes'),
@ -430,8 +430,14 @@ $options_settings = apply_filters('woocommerce_options_settings', array(
array( 'type' => 'sectionend'),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Shipping Methods', 'woothemes') ),
array( 'type' => 'shipping_options'),
array( 'type' => 'sectionend'),
array( 'type' => 'tabend'),
array( 'type' => 'tab', 'tabname' => __('Tax', 'woothemes') ),
@ -822,11 +828,27 @@ function woocommerce_admin_fields($options) {
break;
case "shipping_options" :
$links = array();
foreach (woocommerce_shipping::$shipping_methods as $method) :
$method->admin_options();
$title = ($method->title) ? ucwords($method->title) : ucwords($method->id);
endforeach;
$links[] = '<a href="#shipping-'.$method->id.'">'.$title.'</a>';
endforeach;
echo '<div class="subsubsub_section"><ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />';
foreach (woocommerce_shipping::$shipping_methods as $method) :
echo '<div class="section" id="shipping-'.$method->id.'">';
$method->admin_options();
echo '</div>';
endforeach;
echo '</div>';
break;
case "gateway_options" :
@ -885,6 +907,7 @@ function woocommerce_admin_fields($options) {
jQuery(this).addClass('current');
jQuery('.section', jQuery(this).closest('.subsubsub_section')).hide();
jQuery( jQuery(this).attr('href') ).show();
return false;
});
jQuery('ul.subsubsub').each(function(){
jQuery('li a:eq(0)', jQuery(this)).click();

View File

@ -59,7 +59,6 @@ function woocommerce_order_data_meta_box($post) {
else :
$order_title = $post->post_title;
endif;
?>
<style type="text/css">
#titlediv, #major-publishing-actions, #minor-publishing-actions { display:none }
@ -67,17 +66,11 @@ function woocommerce_order_data_meta_box($post) {
<div class="panel-wrap woocommerce">
<input name="post_title" type="hidden" value="<?php echo $order_title; ?>" />
<input name="post_status" type="hidden" value="publish" />
<ul class="product_data_tabs tabs" style="display:none;">
<li class="active"><a href="#order_data"><?php _e('Order', 'woothemes'); ?></a></li>
<li><a href="#order_customer_billing_data"><?php _e('Customer Billing Address', 'woothemes'); ?></a></li>
<li><a href="#order_customer_shipping_data"><?php _e('Customer Shipping Address', 'woothemes'); ?></a></li>
</ul>
<div id="order_data" class="panel woocommerce_options_panel">
<p class="form-field"><label for="order_status"><?php _e('Order status:', 'woothemes') ?></label>
@ -96,14 +89,10 @@ function woocommerce_order_data_meta_box($post) {
<select id="customer_user" name="customer_user">
<option value=""><?php _e('Guest', 'woothemes') ?></option>
<?php
$users = $wpdb->get_results( $wpdb->prepare("SELECT $wpdb->users.ID, $wpdb->users.user_email, $wpdb->users.display_name FROM $wpdb->users ORDER BY %s ASC", 'display_name' ));
foreach ( $users as $user ) :
echo '<option value="'.$user->ID.'" ';
selected($data['customer_user'], $user->ID);
echo '>' . $user->display_name . ' ('.$user->user_email.')</option>';
$users = new WP_User_Query( array( 'orderby' => 'display_name' ) );
$users = $users->get_results();
if ($users) foreach ( $users as $user ) :
echo '<option value="'.$user->ID.'" '; selected($data['customer_user'], $user->ID); echo '>' . $user->display_name . ' ('.$user->user_email.')</option>';
endforeach;
?>
</select></p>
@ -111,122 +100,34 @@ function woocommerce_order_data_meta_box($post) {
<p class="form-field"><label for="excerpt"><?php _e('Customer Note:', 'woothemes') ?></label>
<textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php _e('Customer\'s notes about the order', 'woothemes'); ?>"><?php echo $post->post_excerpt; ?></textarea></p>
</div>
<div id="order_customer_billing_data" class="panel woocommerce_options_panel"><?php
// First Name
$field = array( 'id' => 'billing_first_name', 'label' => 'First Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Last Name
$field = array( 'id' => 'billing_last_name', 'label' => 'Last Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Company
$field = array( 'id' => 'billing_company', 'label' => 'Company:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 1
$field = array( 'id' => 'billing_address_1', 'label' => 'Address 1:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 2
$field = array( 'id' => 'billing_address_2', 'label' => 'Address 2:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// City
$field = array( 'id' => 'billing_city', 'label' => 'City:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Postcode
$field = array( 'id' => 'billing_postcode', 'label' => 'Postcode:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Country
$field = array( 'id' => 'billing_country', 'label' => 'Country:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// State
$field = array( 'id' => 'billing_state', 'label' => 'State/County:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Email
$field = array( 'id' => 'billing_email', 'label' => 'Email Address:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Tel
$field = array( 'id' => 'billing_phone', 'label' => 'Tel:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
?>
</div>
woocommerce_wp_text_input( array( 'id' => 'billing_first_name', 'label' => __('First Name', 'woothemes'), 'value' => $data['billing_first_name'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_last_name', 'label' => __('Last Name', 'woothemes'), 'value' => $data['billing_last_name'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_company', 'label' => __('Company', 'woothemes'), 'value' => $data['billing_company'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_address_1', 'label' => __('Address 1', 'woothemes'), 'value' => $data['billing_address_1'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_address_2', 'label' => __('Address 2', 'woothemes'), 'value' => $data['billing_address_2'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_city', 'label' => __('City', 'woothemes'), 'value' => $data['billing_city'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_postcode', 'label' => __('Postcode', 'woothemes'), 'value' => $data['billing_postcode'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_country', 'label' => __('Country', 'woothemes'), 'value' => $data['billing_country'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_state', 'label' => __('State/County', 'woothemes'), 'value' => $data['billing_state'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_email', 'label' => __('Email Address', 'woothemes'), 'value' => $data['billing_email'] ) );
woocommerce_wp_text_input( array( 'id' => 'billing_phone', 'label' => __('Tel', 'woothemes'), 'value' => $data['billing_phone'] ) );
?></div>
<div id="order_customer_shipping_data" class="panel woocommerce_options_panel">
<p class="form-field"><button class="button billing-same-as-shipping"><?php _e('Copy billing address to shipping address', 'woothemes'); ?></button></p>
<?php
// First Name
$field = array( 'id' => 'shipping_first_name', 'label' => 'First Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Last Name
$field = array( 'id' => 'shipping_last_name', 'label' => 'Last Name:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Company
$field = array( 'id' => 'shipping_company', 'label' => 'Company:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 1
$field = array( 'id' => 'shipping_address_1', 'label' => 'Address 1:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Address 2
$field = array( 'id' => 'shipping_address_2', 'label' => 'Address 2:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// City
$field = array( 'id' => 'shipping_city', 'label' => 'City:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Postcode
$field = array( 'id' => 'shipping_postcode', 'label' => 'Postcode:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// Country
$field = array( 'id' => 'shipping_country', 'label' => 'Country:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
// State
$field = array( 'id' => 'shipping_state', 'label' => 'State/County:' );
echo '<p class="form-field"><label for="'.$field['id'].'">'.$field['label'].'</label>
<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$data[$field['id']].'" /></p>';
?>
</div>
<p class="form-field"><button class="button billing-same-as-shipping"><?php _e('Copy billing address to shipping address', 'woothemes'); ?></button></p><?php
woocommerce_wp_text_input( array( 'id' => 'shipping_first_name', 'label' => __('First Name', 'woothemes'), 'value' => $data['shipping_first_name'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_last_name', 'label' => __('Last Name', 'woothemes'), 'value' => $data['shipping_last_name'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_company', 'label' => __('Company', 'woothemes'), 'value' => $data['shipping_company'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_address_1', 'label' => __('Address 1', 'woothemes'), 'value' => $data['shipping_address_1'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_address_2', 'label' => __('Address 2', 'woothemes'), 'value' => $data['shipping_address_2'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_city', 'label' => __('City', 'woothemes'), 'value' => $data['shipping_city'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_postcode', 'label' => __('Postcode', 'woothemes'), 'value' => $data['shipping_postcode'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_country', 'label' => __('Country', 'woothemes'), 'value' => $data['shipping_country'] ) );
woocommerce_wp_text_input( array( 'id' => 'shipping_state', 'label' => __('State/County', 'woothemes'), 'value' => $data['shipping_state'] ) );
?></div>
</div>
<?php
}
/**
@ -242,22 +143,22 @@ function woocommerce_order_items_meta_box($post) {
<table cellpadding="0" cellspacing="0" class="woocommerce_order_items">
<thead>
<tr>
<th class="product-id"><?php _e('ID', 'woothemes'); ?></th>
<th class="variation-id"><?php _e('Variation ID', 'woothemes'); ?></th>
<th class="product-sku"><?php _e('sku', 'woothemes'); ?></th>
<th class="product-id" width="1%"><?php _e('ID', 'woothemes'); ?></th>
<th class="variation-id" width="1%"><?php _e('Variation&nbsp;ID', 'woothemes'); ?></th>
<th class="product-sku" width="1%"><?php _e('SKU', 'woothemes'); ?></th>
<th class="name"><?php _e('Name', 'woothemes'); ?></th>
<th class="variation"><?php _e('Variation', 'woothemes'); ?></th>
<th class="meta"><?php _e('Order Item Meta', 'woothemes'); ?></th>
<?php do_action('woocommerce_admin_order_item_headers'); ?>
<th class="quantity"><?php _e('Quantity', 'woothemes'); ?></th>
<th class="cost"><?php _e('Cost', 'woothemes'); ?></th>
<th class="tax"><?php _e('Tax Rate', 'woothemes'); ?></th>
<th class="quantity" style="width:72px"><?php _e('Quantity', 'woothemes'); ?></th>
<th class="cost" style="width:72px"><?php _e('Cost', 'woothemes'); ?></th>
<th class="tax" style="width:72px"><?php _e('Tax Rate', 'woothemes'); ?></th>
<th class="center" width="1%"><?php _e('Remove', 'woothemes'); ?></th>
</tr>
</thead>
<tbody id="order_items_list">
<?php if (sizeof($order_items)>0 && isset($order_items[0]['id'])) foreach ($order_items as $item) :
<?php $loop = 0; if (sizeof($order_items)>0 && isset($order_items[0]['id'])) foreach ($order_items as $item) :
if (isset($item['variation_id']) && $item['variation_id'] > 0) :
$_product = &new woocommerce_product_variation( $item['variation_id'] );
@ -266,7 +167,7 @@ function woocommerce_order_items_meta_box($post) {
endif;
?>
<tr class="item">
<tr class="item" rel="<?php echo $loop; ?>">
<td class="product-id"><?php echo $item['id']; ?></td>
<td class="variation-id"><?php if ($item['variation_id']) echo $item['variation_id']; else echo '-'; ?></td>
<td class="product-sku"><?php if ($_product->sku) echo $_product->sku; else echo '-'; ?></td>
@ -282,23 +183,29 @@ function woocommerce_order_items_meta_box($post) {
<table class="meta" cellspacing="0">
<tfoot>
<tr>
<td colspan="3"><button class="add_meta button"><?php _e('Add&nbsp;meta', 'woothemes'); ?></button></td>
<td colspan="4"><button class="add_meta button"><?php _e('Add&nbsp;meta', 'woothemes'); ?></button></td>
</tr>
</tfoot>
<tbody></tbody>
<tbody class="meta_items">
<?php
if (isset($item['item_meta']) && is_array($item['item_meta'])) foreach ($item['item_meta'] as $key => $value) :
echo '<tr><td><input type="text" name="meta_name['.$loop.'][]" value="'.$key.'" /></td><td><input type="text" name="meta_value['.$loop.'][]" value="'.$value.'" /></td><td><button class="remove_meta button">&times;</button></td></tr>';
endforeach;
?>
</tbody>
</table>
</td>
<?php do_action('woocommerce_admin_order_item_values', $_product, $item); ?>
<td class="quantity"><input type="text" name="item_quantity[]" placeholder="<?php _e('Quantity e.g. 2', 'woothemes'); ?>" value="<?php echo $item['qty']; ?>" /></td>
<td class="cost"><input type="text" name="item_cost[]" placeholder="<?php _e('Cost per unit ex. tax e.g. 2.99', 'woothemes'); ?>" value="<?php echo $item['cost']; ?>" /></td>
<td class="tax"><input type="text" name="item_tax_rate[]" placeholder="<?php _e('Tax Rate e.g. 20.0000', 'woothemes'); ?>" value="<?php echo $item['taxrate']; ?>" /></td>
<td class="quantity"><input type="text" name="item_quantity[<?php echo $loop; ?>]" placeholder="<?php _e('Quantity e.g. 2', 'woothemes'); ?>" value="<?php echo $item['qty']; ?>" /></td>
<td class="cost"><input type="text" name="item_cost[<?php echo $loop; ?>]" placeholder="<?php _e('Cost per unit ex. tax e.g. 2.99', 'woothemes'); ?>" value="<?php echo $item['cost']; ?>" /></td>
<td class="tax"><input type="text" name="item_tax_rate[<?php echo $loop; ?>]" placeholder="<?php _e('Tax Rate e.g. 20.0000', 'woothemes'); ?>" value="<?php echo $item['taxrate']; ?>" /></td>
<td class="center">
<input type="hidden" name="item_id[]" value="<?php echo $item['id']; ?>" />
<input type="hidden" name="item_name[]" value="<?php echo $item['name']; ?>" />
<input type="hidden" name="item_id[<?php echo $loop; ?>]" value="<?php echo $item['id']; ?>" />
<input type="hidden" name="item_name[<?php echo $loop; ?>]" value="<?php echo $item['name']; ?>" />
<button type="button" class="remove_row button">&times;</button>
</td>
</tr>
<?php endforeach; ?>
<?php $loop++; endforeach; ?>
</tbody>
</table>
</div>
@ -487,23 +394,36 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
$order_items = array();
if (isset($_POST['item_id'])) :
$item_id = $_POST['item_id'];
$item_variation= $_POST['item_variation'];
$item_name = $_POST['item_name'];
$item_quantity = $_POST['item_quantity'];
$item_cost = $_POST['item_cost'];
$item_tax_rate = $_POST['item_tax_rate'];
$item_id = $_POST['item_id'];
$item_variation = $_POST['item_variation'];
$item_name = $_POST['item_name'];
$item_quantity = $_POST['item_quantity'];
$item_cost = $_POST['item_cost'];
$item_tax_rate = $_POST['item_tax_rate'];
$item_meta_names = $_POST['meta_name'];
$item_meta_values = $_POST['meta_value'];
for ($i=0; $i<sizeof($item_id); $i++) :
if (!isset($item_id[$i])) continue;
if (!isset($item_id[$i]) || !$item_id[$i]) continue;
if (!isset($item_name[$i])) continue;
if (!isset($item_quantity[$i])) continue;
if (!isset($item_quantity[$i]) || $item_quantity[$i] < 1) continue;
if (!isset($item_cost[$i])) continue;
if (!isset($item_tax_rate[$i])) continue;
//$ex_tax = woocommerce_clean($item_cost[$i]) / (($item_tax_rate[$i]/100)+1);
// Meta
$item_meta = array();
$meta_names = $item_meta_names[$i];
$meta_values = $item_meta_values[$i];
for ($ii=0; $ii<sizeof($meta_names); $ii++) :
$key = sanitize_title($meta_names[$ii]);
if ($key && $meta_values[$ii]) :
$item_meta[$key] = woocommerce_clean( $meta_values[$ii] );
endif;
endfor;
// Add to array
$order_items[] = apply_filters('update_order_item', array(
'id' => htmlspecialchars(stripslashes($item_id[$i])),
'variation_id' => (int) $item_variation[$i],
@ -511,6 +431,7 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
'qty' => (int) $item_quantity[$i],
'cost' => number_format(woocommerce_clean($item_cost[$i]), 2, '.', ''),
'taxrate' => number_format(woocommerce_clean($item_tax_rate[$i]), 4, '.', ''),
'item_meta' => $item_meta
));
endfor;

View File

@ -22,7 +22,7 @@ function variable_product_type_options() {
?>
<div id="variable_product_options" class="panel">
<div class="woocommerce_configurations">
<div class="woocommerce_variations">
<?php
$args = array(
'post_type' => 'product_variation',
@ -44,7 +44,7 @@ function variable_product_type_options() {
if (!$image) $image = woocommerce::plugin_url().'/assets/images/placeholder.png';
?>
<div class="woocommerce_configuration">
<div class="woocommerce_variation">
<p>
<button type="button" class="remove_variation button" rel="<?php echo $variation->ID; ?>"><?php _e('Remove', 'woothemes'); ?></button>
<strong>#<?php echo $variation->ID; ?> &mdash; <?php _e('Variation:', 'woothemes'); ?></strong>
@ -115,7 +115,7 @@ function variable_product_write_panel_js() {
jQuery('button.add_configuration').live('click', function(){
jQuery('.woocommerce_configurations').block({ message: null, overlayCSS: { background: '#fff url(<?php echo woocommerce::plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
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 data = {
action: 'woocommerce_add_variation',
@ -127,9 +127,9 @@ function variable_product_write_panel_js() {
var variation_id = parseInt(response);
var loop = jQuery('.woocommerce_configuration').size();
var loop = jQuery('.woocommerce_variation').size();
jQuery('.woocommerce_configurations').append('<div class="woocommerce_configuration">\
jQuery('.woocommerce_variations').append('<div class="woocommerce_variation">\
<p>\
<button type="button" class="remove_variation button"><?php _e('Remove', 'woothemes'); ?></button>\
<strong><?php _e('Variation:', 'woothemes'); ?></strong>\
@ -166,7 +166,7 @@ function variable_product_write_panel_js() {
</table>\
</div>');
jQuery('.woocommerce_configurations').unblock();
jQuery('.woocommerce_variations').unblock();
});

View File

@ -37,7 +37,7 @@
.icon32-posts-shop_order {
background-position: -127px -6px !important;
}
.icon32-attributes, .icon32-posts-product_variation {
.icon32-attributes {
background-position: -185px -6px !important;
}
.icon32-woocommerce-settings {
@ -46,6 +46,9 @@
.icon32-posts-shop_coupon {
background-position: -475px -6px !important;
}
.icon32-posts-product_variation {
background-position: -533px -6px !important;
}
/* Orders */
.order_actions {
color: #999;
@ -130,7 +133,8 @@ dl.totals dd input.last {
.woocommerce_order_items_wrapper table.woocommerce_order_items td {
padding: 8px 10px;
text-align: left;
vertical-align: middle;
line-height: 26px;
vertical-align: top;
border-bottom: 1px dotted #ececec;
}
.woocommerce_order_items_wrapper table.woocommerce_order_items td input, .woocommerce_order_items_wrapper table.woocommerce_order_items td textarea {
@ -708,23 +712,23 @@ div.multi_select_products_wrapper {
padding: 0;
margin: 0;
}
.woocommerce_configuration {
.woocommerce_variation {
background: #ececec;
border: 1px solid #ececec;
margin: 0 0 8px;
}
.woocommerce_configuration p {
.woocommerce_variation p {
margin: 0 !important;
}
.woocommerce_configuration p button {
.woocommerce_variation p button {
float: right;
}
.woocommerce_configuration table td {
.woocommerce_variation table td {
background: #fff;
padding: 6px 6px;
vertical-align: middle;
}
.woocommerce_configuration table td label {
.woocommerce_variation table td label {
color: #999;
font-size: 10px;
text-transform: uppercase;
@ -732,20 +736,20 @@ div.multi_select_products_wrapper {
display: block;
line-height: 16px;
}
.woocommerce_configuration table td input {
.woocommerce_variation table td input {
float: left;
width: 100%;
}
.woocommerce_configuration table td.upload_image {
.woocommerce_variation table td.upload_image {
width: 1%;
white-space: nowrap;
}
.woocommerce_configuration table td.upload_image img {
.woocommerce_variation table td.upload_image img {
float: none;
margin-right: 6px;
vertical-align: middle;
}
.woocommerce_configuration table td.upload_image .button {
.woocommerce_variation table td.upload_image .button {
margin: 0;
padding: 4px 10px;
width: auto;

View File

@ -39,7 +39,7 @@
.icon32-posts-shop_order {
background-position: -127px -6px !important;
}
.icon32-attributes, .icon32-posts-product_variation {
.icon32-attributes {
background-position: -185px -6px !important;
}
.icon32-woocommerce-settings {
@ -48,6 +48,9 @@
.icon32-posts-shop_coupon {
background-position: -475px -6px !important;
}
.icon32-posts-product_variation {
background-position: -533px -6px !important;
}
/* Orders */
.order_actions {
@ -133,7 +136,8 @@ dl.totals {
td {
padding: 8px 10px;
text-align: left;
vertical-align: middle;
line-height: 26px;
vertical-align: top;
border-bottom: 1px dotted #ececec;
input, textarea {
width: 100%;
@ -771,7 +775,7 @@ div.multi_select_products_wrapper {
margin: 0;
}
}
.woocommerce_configuration {
.woocommerce_variation {
background: #ececec;
border: 1px solid #ececec;
margin: 0 0 8px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -27,7 +27,7 @@ jQuery(function(){
jQuery('body').trigger('adding_to_cart');
// Block widget
jQuery('.widget_shopping_cart').block({ message: null, overlayCSS: { background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
jQuery('.widget_shopping_cart, .shop_table.cart').block({ message: null, overlayCSS: { background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
jQuery.post( params.ajax_url, data, function(response) {
@ -40,6 +40,12 @@ jQuery(function(){
jQuery('.widget_shopping_cart').unblock();
} );
// Cart load
jQuery('.shop_table.cart').load( window.location + ' .shop_table.cart:eq(0) > *', function() {
jQuery("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
jQuery('.shop_table.cart').unblock();
} );
// Trigger event so themes can refresh other areas
jQuery('body').trigger('added_to_cart');
@ -124,8 +130,9 @@ jQuery(function(){
});
// Quantity buttons
jQuery("div.quantity, td.quantity").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
jQuery(".plus").click(function()
jQuery("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
jQuery(".plus").live('click', function()
{
var currentVal = parseInt(jQuery(this).prev(".qty").val());
@ -134,7 +141,7 @@ jQuery(function(){
jQuery(this).prev(".qty").val(currentVal + 1);
});
jQuery(".minus").click(function()
jQuery(".minus").live('click', function()
{
var currentVal = parseInt(jQuery(this).next(".qty").val());
if (currentVal == "NaN") currentVal = 0;

View File

@ -19,7 +19,8 @@ jQuery( function($){
jQuery('#order_items_list button.remove_row').live('click', function(){
var answer = confirm(params.remove_item_notice);
if (answer){
jQuery(this).parent().parent().remove();
jQuery(this).closest('tr.item').hide();
jQuery('input', jQuery(this).closest('tr.item')).val('');
}
return false;
});
@ -96,12 +97,15 @@ jQuery( function($){
var add_item_id = jQuery('select.add_item_id').val();
if (add_item_id) {
jQuery('table.woocommerce_order_items').block({ message: null, overlayCSS: { background: '#fff url(' + params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
var size = jQuery('table.woocommerce_order_items tbody tr.item').size();
var data = {
action: 'woocommerce_add_order_item',
item_to_add: jQuery('select.add_item_id').val(),
index: size,
security: params.add_order_item_nonce
};
@ -121,8 +125,20 @@ jQuery( function($){
jQuery('button.add_meta').live('click', function(){
jQuery(this).parent().parent().parent().parent().append('<tr><td><input type="text" name="meta_name[][]" placeholder="' + params.meta_name + '" /></td><td><input type="text" name="meta_value[][]" placeholder="' + params.meta_value + '" /></td></tr>');
var index = jQuery(this).closest('tr.item').attr('rel');
jQuery(this).closest('table.meta').find('.meta_items').append('<tr><td><input type="text" name="meta_name[' + index + '][]" placeholder="' + params.meta_name + '" /></td><td><input type="text" name="meta_value[' + index + '][]" placeholder="' + params.meta_value + '" /></td><td><button class="remove_meta button">&times;</button></td></tr>');
return false;
});
jQuery('button.remove_meta').live('click', function(){
var answer = confirm("Remove this meta key?")
if (answer){
jQuery(this).closest('tr').remove();
}
return false;
});
jQuery('button.billing-same-as-shipping').live('click', function(){

View File

@ -467,12 +467,12 @@ class woocommerce_product {
/** Returns the upsell product ids */
function get_upsells() {
return (array) $this->upsell_ids;
return (array) maybe_unserialize( $this->upsell_ids );
}
/** Returns the crosssell product ids */
function get_cross_sells() {
return (array) $this->crosssell_ids;
return (array) maybe_unserialize( $this->crosssell_ids );
}
/** Returns the product categories */

View File

@ -87,7 +87,7 @@ class flat_rate extends woocommerce_shipping_method {
<h3><?php _e('Flat Rates', 'woothemes'); ?></h3>
<p><?php _e('Flat rates let you define a standard rate per item, or per order.', 'woothemes'); ?></p>
<table class="form-table">
<tr valign="top" class="option_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Enable/disable', 'woothemes') ?></th>
<td class="forminp">
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable/disable', 'woothemes') ?></span></legend>
@ -96,13 +96,13 @@ class flat_rate extends woocommerce_shipping_method {
</fieldset>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Method Title', 'woothemes') ?></th>
<td class="forminp">
<input type="text" name="woocommerce_flat_rate_title" id="woocommerce_flat_rate_title" style="min-width:50px;" value="<?php if ($value = get_option('woocommerce_flat_rate_title')) echo $value; else echo 'Flat Rate'; ?>" /> <span class="description"><?php _e('This controls the title which the user sees during checkout.', 'woothemes') ?></span>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Type', 'woothemes') ?></th>
<td class="forminp">
<select name="woocommerce_flat_rate_type" id="woocommerce_flat_rate_type" style="min-width:100px;">
@ -112,7 +112,7 @@ class flat_rate extends woocommerce_shipping_method {
</td>
</tr>
<?php $_tax = new woocommerce_tax(); ?>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Tax Status', 'woothemes') ?></th>
<td class="forminp">
<select name="woocommerce_flat_rate_tax_status">
@ -121,19 +121,19 @@ class flat_rate extends woocommerce_shipping_method {
</select>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Cost', 'woothemes') ?></th>
<td class="forminp">
<input type="text" name="woocommerce_flat_rate_cost" id="woocommerce_flat_rate_cost" style="min-width:50px;" value="<?php if ($value = get_option('woocommerce_flat_rate_cost')) echo $value; ?>" /> <span class="description"><?php _e('Cost excluding tax. Enter an amount, e.g. 2.50.', 'woothemes') ?></span>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Handling Fee', 'woothemes') ?></th>
<td class="forminp">
<input type="text" name="woocommerce_flat_rate_handling_fee" id="woocommerce_flat_rate_handling_fee" style="min-width:50px;" value="<?php if ($value = get_option('woocommerce_flat_rate_handling_fee')) echo $value; ?>" /> <span class="description"><?php _e('Fee excluding tax. Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woothemes') ?></span>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Method availability', 'woothemes') ?></th>
<td class="forminp">
<select name="woocommerce_flat_rate_availability" id="woocommerce_flat_rate_availability" style="min-width:100px;">

View File

@ -35,7 +35,7 @@ class free_shipping extends woocommerce_shipping_method {
?>
<h3><?php _e('Free Shipping', 'woothemes'); ?></h3>
<table class="form-table">
<tr valign="top" class="option_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Enable/disable', 'woothemes') ?></th>
<td class="forminp">
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable/disable', 'woothemes') ?></span></legend>
@ -44,19 +44,19 @@ class free_shipping extends woocommerce_shipping_method {
</fieldset>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Method Title', 'woothemes') ?></th>
<td class="forminp">
<input type="text" name="woocommerce_free_shipping_title" id="woocommerce_free_shipping_title" style="min-width:50px;" value="<?php if ($value = get_option('woocommerce_free_shipping_title')) echo $value; else echo 'Free Shipping'; ?>" /> <span class="description"><?php _e('This controls the title which the user sees during checkout.', 'woothemes') ?></span>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Minimum Order Amount', 'woothemes') ?></th>
<td class="forminp">
<input type="text" name="woocommerce_free_shipping_minimum_amount" id="woocommerce_free_shipping_minimum_amount" style="min-width:50px;" value="<?php if ($value = get_option('woocommerce_free_shipping_minimum_amount')) echo $value; else echo 'Free Shipping'; ?>" /> <span class="description"><?php _e('Users will need to spend this amount to get free shipping. Leave blank to disable.', 'woothemes') ?></span>
</td>
</tr>
<tr valign="top" class="hidden_unless_enabled">
<tr valign="top">
<th scope="row" class="titledesc"><?php _e('Method availability', 'woothemes') ?></th>
<td class="forminp">
<select name="woocommerce_free_shipping_availability" id="woocommerce_free_shipping_availability" style="min-width:100px;">

View File

@ -13,7 +13,7 @@ if ($per_page !== get_option('posts_per_page')) query_posts( array_merge( $wp_qu
ob_start();
if (have_posts()) : while (have_posts()) : the_post(); $_product = &new woocommerce_product( $post->ID ); $loop++;
if (have_posts()) : while (have_posts()) : the_post(); $_product = &new woocommerce_product( $post->ID ); if (!$_product->is_visible()) continue; $loop++;
?>
<li class="product <?php if ($loop%$columns==0) echo 'last'; if (($loop-1)%$columns==0) echo 'first'; ?>">

View File

@ -6,6 +6,7 @@
*
* - AJAX update order review on checkout
* - AJAX add to cart
* - AJAX add to cart fragments
* - Increase coupon usage count
* - Get variation
* - Add order item
@ -77,7 +78,6 @@ function woocommerce_ajax_add_to_cart() {
echo json_encode( $fragments );
die();
}
@ -156,6 +156,7 @@ function woocommerce_add_order_item() {
global $wpdb;
$index = trim(stripslashes($_POST['index']));
$item_to_add = trim(stripslashes($_POST['item_to_add']));
$post = '';
@ -188,11 +189,9 @@ function woocommerce_add_order_item() {
else :
$_product = &new woocommerce_product_variation( $post->ID );
endif;
$loop = 0;
?>
<tr class="item">
<td class="product-id">#<?php echo $_product->id; ?></td>
<tr class="item" rel="<?php echo $index; ?>">
<td class="product-id"><?php echo $_product->id; ?></td>
<td class="variation-id"><?php if (isset($_product->variation_id)) echo $_product->variation_id; else echo '-'; ?></td>
<td class="product-sku"><?php if ($_product->sku) echo $_product->sku; ?></td>
<td class="name"><a href="<?php echo admin_url('post.php?post='. $_product->id .'&action=edit'); ?>"><?php echo $_product->get_title(); ?></a></td>
@ -210,16 +209,16 @@ function woocommerce_add_order_item() {
<td colspan="3"><button class="add_meta button"><?php _e('Add meta', 'woothemes'); ?></button></td>
</tr>
</tfoot>
<tbody></tbody>
<tbody class="meta_items"></tbody>
</table>
</td>
<?php do_action('woocommerce_admin_order_item_values', $_product); ?>
<td class="quantity"><input type="text" name="item_quantity[]" placeholder="<?php _e('Quantity e.g. 2', 'woothemes'); ?>" value="1" /></td>
<td class="cost"><input type="text" name="item_cost[]" placeholder="<?php _e('Cost per unit ex. tax e.g. 2.99', 'woothemes'); ?>" value="<?php echo $_product->get_price_excluding_tax(); ?>" /></td>
<td class="tax"><input type="text" name="item_tax_rate[]" placeholder="<?php _e('Tax Rate e.g. 20.0000', 'woothemes'); ?>" value="<?php echo $_product->get_tax_base_rate(); ?>" /></td>
<td class="quantity"><input type="text" name="item_quantity[<?php echo $index; ?>]" placeholder="<?php _e('Quantity e.g. 2', 'woothemes'); ?>" value="1" /></td>
<td class="cost"><input type="text" name="item_cost[<?php echo $index; ?>]" placeholder="<?php _e('Cost per unit ex. tax e.g. 2.99', 'woothemes'); ?>" value="<?php echo $_product->get_price_excluding_tax(); ?>" /></td>
<td class="tax"><input type="text" name="item_tax_rate[<?php echo $index; ?>]" placeholder="<?php _e('Tax Rate e.g. 20.0000', 'woothemes'); ?>" value="<?php echo $_product->get_tax_base_rate(); ?>" /></td>
<td class="center">
<input type="hidden" name="item_id[]" value="<?php echo $_product->id; ?>" />
<input type="hidden" name="item_name[]" value="<?php echo $_product->get_title(); ?>" />
<input type="hidden" name="item_id[<?php echo $index; ?>]" value="<?php echo $_product->id; ?>" />
<input type="hidden" name="item_name[<?php echo $index; ?>]" value="<?php echo $_product->get_title(); ?>" />
<button type="button" class="remove_row button">&times;</button>
</td>
</tr>

View File

@ -851,6 +851,7 @@ function woocommerce_cross_sell_display() {
global $columns;
$columns = 2;
$crosssells = woocommerce_cart::get_cross_sells();
if (sizeof($crosssells)>0) :
echo '<div class="cross-sells"><h2>'.__('You may be interested in&hellip;', 'woothemes').'</h2>';
$args = array(