Skip to content
Permalink
Browse files

New: add cashier to receipt data

  • Loading branch information...
kilbot committed Aug 22, 2015
1 parent 5e34449 commit c4caa8df78d9f255445f370854fbb3e466b46b4e
@@ -18,15 +18,6 @@ module.exports = Collection.extend({
this._isNew = false;
},

range: function(attr){
var attrs = this.compact( this.pluck(attr)), min = 0, max = 0;
if( !_.isEmpty(attrs) ) {
min = _(attrs).min();
max = _(attrs).max();
}
return _.uniq([min, max]);
},

/**
* same as _.compact
* except allows 0
@@ -45,7 +36,16 @@ module.exports = Collection.extend({
}
}
return result;
}
},
/* jshint +W074 */

range: function(attr){
var attrs = this.compact( this.pluck(attr)), min = 0, max = 0;
if( !_.isEmpty(attrs) ) {
min = _(attrs).min();
max = _(attrs).max();
}
return _.uniq([min, max]);
}

});
@@ -208,7 +208,7 @@ var View = FormView.extend({
e.preventDefault();
var key = $(e.currentTarget).data('key');
this.model.set('active', 'percentage');
this.model._set('percentage', key.replace('%', ''));
this.model.set('percentage', key.replace('%', ''));
this.ui.toggle.addClass('toggle');
},

@@ -369,8 +369,11 @@ public function update_post_metadata($null, $order_id, $meta_key, $meta_value, $
*/
public function create_order( $order_id ){
// pos meta
global $current_user;
get_currentuserinfo();
update_post_meta( $order_id, '_pos', 1 );
update_post_meta( $order_id, '_pos_user', get_current_user_id() );
update_post_meta( $order_id, '_pos_user', $current_user->ID );
update_post_meta( $order_id, '_pos_user_name', $current_user->user_firstname . ' ' . $current_user->user_lastname );
// payment
do_action( 'woocommerce_pos_process_payment', $order_id, $this->data);
@@ -528,14 +531,18 @@ public function payment_complete( $order_id ) {
*/
public function order_response( $order_data, $order, $fields, $server ) {
// add cashier data
$cashier_data = isset( $order_data['cashier'] ) ? $order_data['cashier'] : array();
$order_data['cashier'] = $this->add_cashier_data( $order->id, $cashier_data );
// add pos payment info
$order_data['payment_details']['result'] = get_post_meta( $order->id, '_pos_payment_result', true );
$order_data['payment_details']['message'] = get_post_meta( $order->id, '_pos_payment_message', true );
$order_data['payment_details']['redirect'] = get_post_meta( $order->id, '_pos_payment_redirect', true );
// addresses
$order_data['billing_address'] = $this->filter_address($order_data['billing_address'], $order);
$order_data['shipping_address'] = $this->filter_address($order_data['shipping_address'], $order, 'shipping');
// $order_data['billing_address'] = $this->filter_address($order_data['billing_address'], $order);
// $order_data['shipping_address'] = $this->filter_address($order_data['shipping_address'], $order, 'shipping');
// allow decimal quantity
// fixed in WC 2.4+
@@ -566,6 +573,25 @@ public function order_response( $order_data, $order, $fields, $server ) {
return $order_data;
}
/**
* @param $order_id
* @param array $cashier
* @return array
*/
private function add_cashier_data( $order_id, array $cashier = array() ){
$cashier['id'] = get_post_meta( $order_id, '_pos_user', true);
$first_name = get_post_meta( $order_id, '_pos_user_first_name', true);
$last_name = get_post_meta( $order_id, '_pos_user_last_name', true);
if( !$first_name && !$last_name ) {
$user_info = get_userdata( $cashier['id'] );
$first_name = $user_info->first_name;
$last_name = $user_info->last_name;
}
$cashier['first_name'] = $first_name;
$cashier['last_name'] = $last_name;
return $cashier;
}
/**
* Adds support for custom address fields
* @param $address
@@ -575,7 +601,7 @@ public function order_response( $order_data, $order, $fields, $server ) {
*/
private function filter_address( $address, $order, $type = 'billing' ){
$fields = apply_filters('woocommerce_admin_'.$type.'_fields', false);
if($fields){
if( $fields ){
$address = array();
foreach($fields as $key => $value){
$address[$key] = $order->{$type.'_'.$key};
@@ -121,6 +121,12 @@
<th><?php _e( 'Order Date', 'woocommerce-pos' ); ?></th>
<td>{{formatDate completed_at format="MMMM Do YYYY, h:mm:ss a"}}</td>
</tr>
{{#if cashier}}
<tr>
<th><?php _e( 'Cashier', 'woocommerce-pos' ); ?></th>
<td>{{cashier.first_name}} {{cashier.last_name}}</td>
</tr>
{{/if}}
<tr>
<th><?php _e( 'Payment Method', 'woocommerce-pos' ); ?></th>
<td>{{payment_details.method_title}}</td>
@@ -80,12 +80,14 @@ Bugs can be reported on the [WooCommerce POS GitHub repository](https://github.c
= 0.4.2 =
* New: local storage will now clear on version change - commit [85ec411](https://github.com/kilbot/WooCommerce-POS/commit/85ec411a58600988b811272be6d151cb11161f4f)
* New: option to automatically print receipt after checkout - commit [16fba05](https://github.com/kilbot/WooCommerce-POS/commit/16fba054593e118be6c567ce4d87f8d0b91acaa5)
* New: add cashier to receipt data - commit []()
* Fix: variation display and select issues - commit [91c7ec1](https://github.com/kilbot/WooCommerce-POS/commit/91c7ec13e737f820d84feb7890d7b6d027a79792), [b3d6543](https://github.com/kilbot/WooCommerce-POS/commit/b3d6543b86140df62ff90f3a7b7e734d73ae59ab)
* Fix: variation barcode search for products in queue - commit [3fda531](https://github.com/kilbot/WooCommerce-POS/commit/3fda5317ef580f6b6d70e24ba235d2b7e69c5ee4)
* Fix: variation stock adjustment after sale - commit [26978fd](https://github.com/kilbot/WooCommerce-POS/commit/26978fd0e74cfb9cf28ef2bb4bc5222820a77d38)
* Fix: populate order addresses from customer id - commit [b86bc56](https://github.com/kilbot/WooCommerce-POS/commit/b86bc5650a2bf41d7744bf07cda34407e8fa3dd5)
* Fix: compatibility fix for WC 2.4 SSL authentication - commit [525671b](https://github.com/kilbot/WooCommerce-POS/commit/525671b7613b20864366aebf426f14d07b37bfa4)
* Fix: modal CSS conflict in WP Admin - commit [837b918](https://github.com/kilbot/WooCommerce-POS/commit/837b918e5bae4de6c1cee1492d390ade1b2e7f45)
* Fix: numpad discount bug introduced in 0.4.1
* Tweak: WP Admin CSS - commit [c5a38c7](https://github.com/kilbot/WooCommerce-POS/commit/c5a38c7f889a7788e3eaa633c28620d2e80ac2ee)

= 0.4.1 =
@@ -657,4 +657,5 @@ public function test_order_with_shipping_change_tax_class(){
$this->assertEquals(0.5, $data['order']['total_tax']);
}
}

0 comments on commit c4caa8d

Please sign in to comment.
You can’t perform that action at this time.