Orders panel

This commit is contained in:
Mike Jolley 2011-08-11 23:54:26 +01:00
parent fc7b3d2265
commit c2d3ec4892
5 changed files with 13 additions and 15 deletions

View File

@ -290,7 +290,7 @@ function woocommerce_order_items_meta_box($post) {
</td> </td>
<?php do_action('woocommerce_admin_order_item_values', $_product, $item); ?> <?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="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 including tax e.g. 2.99', 'woothemes'); ?>" value="<?php echo $item['cost']; ?>" /></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="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="center"> <td class="center">
<input type="hidden" name="item_id[]" value="<?php echo $item['id']; ?>" /> <input type="hidden" name="item_id[]" value="<?php echo $item['id']; ?>" />
@ -303,7 +303,7 @@ function woocommerce_order_items_meta_box($post) {
</table> </table>
</div> </div>
<p class="buttons"> <p class="buttons">
<select name="item_id" class="item_id"> <select name="add_item_id" class="item_id">
<?php <?php
echo '<option value="">'.__('Choose an item&hellip;', 'woothemes').'</option>'; echo '<option value="">'.__('Choose an item&hellip;', 'woothemes').'</option>';
@ -502,7 +502,7 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
if (!isset($item_cost[$i])) continue; if (!isset($item_cost[$i])) continue;
if (!isset($item_tax_rate[$i])) continue; if (!isset($item_tax_rate[$i])) continue;
$ex_tax = woocommerce_clean($item_cost[$i]) / ((woocommerce_clean($item_tax_rate[$i])/100)+1); //$ex_tax = woocommerce_clean($item_cost[$i]) / (($item_tax_rate[$i]/100)+1);
$order_items[] = apply_filters('update_order_item', array( $order_items[] = apply_filters('update_order_item', array(
'id' => htmlspecialchars(stripslashes($item_id[$i])), 'id' => htmlspecialchars(stripslashes($item_id[$i])),
@ -510,7 +510,6 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
'name' => htmlspecialchars(stripslashes($item_name[$i])), 'name' => htmlspecialchars(stripslashes($item_name[$i])),
'qty' => (int) $item_quantity[$i], 'qty' => (int) $item_quantity[$i],
'cost' => number_format(woocommerce_clean($item_cost[$i]), 2, '.', ''), 'cost' => number_format(woocommerce_clean($item_cost[$i]), 2, '.', ''),
'cost_ex_tax' => number_format(woocommerce_clean($ex_tax[$i]), 2, '.', ''),
'taxrate' => number_format(woocommerce_clean($item_tax_rate[$i]), 4, '.', ''), 'taxrate' => number_format(woocommerce_clean($item_tax_rate[$i]), 4, '.', ''),
)); ));

View File

@ -58,9 +58,9 @@ jQuery( function($){
if (itemTax && itemTax>0) { if (itemTax && itemTax>0) {
taxRate = itemTax/100 + 1; taxRate = itemTax/100;
itemTaxAmount = ((itemCost - (itemCost / taxRate)) * 100 ); itemTaxAmount = ((itemCost * taxRate) * 100 );
itemTaxAmount = itemTaxAmount.toFixed(2); itemTaxAmount = itemTaxAmount.toFixed(2);
@ -76,7 +76,7 @@ jQuery( function($){
} }
} }
subtotal = itemTotal - tax; subtotal = itemTotal;
total = parseFloat(subtotal) + parseFloat(tax) - parseFloat(discount) + parseFloat(shipping) + parseFloat(shipping_tax); total = parseFloat(subtotal) + parseFloat(tax) - parseFloat(discount) + parseFloat(shipping) + parseFloat(shipping_tax);
@ -93,7 +93,7 @@ jQuery( function($){
jQuery('button.add_shop_order_item').click(function(){ jQuery('button.add_shop_order_item').click(function(){
var item_id = jQuery('select.item_id').val(); var item_id = jQuery('select.add_item_id').val();
if (item_id) { if (item_id) {
@ -101,7 +101,7 @@ jQuery( function($){
var data = { var data = {
action: 'woocommerce_add_order_item', action: 'woocommerce_add_order_item',
item_to_add: jQuery('select.item_id').val(), item_to_add: jQuery('select.add_item_id').val(),
security: params.add_order_item_nonce security: params.add_order_item_nonce
}; };
@ -109,12 +109,12 @@ jQuery( function($){
jQuery('table.woocommerce_order_items tbody#order_items_list').append( response ); jQuery('table.woocommerce_order_items tbody#order_items_list').append( response );
jQuery('table.woocommerce_order_items').unblock(); jQuery('table.woocommerce_order_items').unblock();
jQuery('select.item_id').css('border-color', '').val(''); jQuery('select.add_item_id').css('border-color', '').val('');
}); });
} else { } else {
jQuery('select.item_id').css('border-color', 'red'); jQuery('select.add_item_id').css('border-color', 'red');
} }
}); });

View File

@ -544,8 +544,7 @@ class woocommerce_checkout {
'variation_id' => $values['variation_id'], 'variation_id' => $values['variation_id'],
'name' => $_product->get_title(), 'name' => $_product->get_title(),
'qty' => (int) $values['quantity'], 'qty' => (int) $values['quantity'],
'cost' => $_product->get_price(), 'cost' => $_product->get_price_excluding_tax(),
'cost_ex_tax' => $_product->get_price_excluding_tax(),
'taxrate' => $rate 'taxrate' => $rate
)); ));

View File

@ -192,7 +192,7 @@ class woocommerce_order {
endif; endif;
$return .= ' - ' . strip_tags(woocommerce_price( $item['cost_ex_tax']*$item['qty'], array('ex_tax_label' => 1 ))); $return .= ' - ' . strip_tags(woocommerce_price( $item['cost']*$item['qty'], array('ex_tax_label' => 1 )));
if (isset($_product->variation_data)) : if (isset($_product->variation_data)) :
$return .= PHP_EOL . woocommerce_get_formatted_variation( $_product->variation_data, true ); $return .= PHP_EOL . woocommerce_get_formatted_variation( $_product->variation_data, true );

View File

@ -508,7 +508,7 @@ function woocommerce_view_order() {
echo ' </td> echo ' </td>
<td>'.$item['qty'].'</td> <td>'.$item['qty'].'</td>
<td>'.woocommerce_price( $item['cost_ex_tax']*$item['qty'], array('ex_tax_label' => 1) ).'</td> <td>'.woocommerce_price( $item['cost']*$item['qty'], array('ex_tax_label' => 1) ).'</td>
</tr>'; </tr>';
endforeach; endforeach;
endif; endif;