Skip to content

Commit

Permalink
v1.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Jan 18, 2024
1 parent 3bb2e7e commit 471dba2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 30 deletions.
10 changes: 5 additions & 5 deletions includes/Admin/Orders/HPOS_List_Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ public function orders_custom_column_content( string $column_name, $order ): voi
}
}

public function query_args($args) {
public function query_args( $args ) {
$pos_order_filter = $_GET['pos_order'] ?? '';

if ($pos_order_filter) {
if ( ! isset($args['field_query'])) {
if ( $pos_order_filter ) {
if ( ! isset( $args['field_query'] ) ) {
$args['field_query'] = array();
}

if ('yes' === $pos_order_filter) {
if ( 'yes' === $pos_order_filter ) {
$args['field_query'][] = array(
'field' => 'created_via',
'value' => 'woocommerce-pos',
);
}

if ('no' === $pos_order_filter) {
if ( 'no' === $pos_order_filter ) {
$args['field_query'][] = array(
'field' => 'created_via',
'value' => 'woocommerce-pos',
Expand Down
38 changes: 19 additions & 19 deletions includes/Admin/Orders/Single_Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class Single_Order {
public function __construct() {
add_filter( 'wc_order_is_editable', array( $this, 'wc_order_is_editable' ), 10, 2 );
add_action('woocommerce_admin_order_data_after_order_details', array( $this, 'add_cashier_select' ) );
add_action('woocommerce_process_shop_order_meta', array( $this, 'save_cashier_select' ) );
add_action( 'woocommerce_admin_order_data_after_order_details', array( $this, 'add_cashier_select' ) );
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'save_cashier_select' ) );
}

/**
Expand All @@ -32,22 +32,22 @@ public function wc_order_is_editable( bool $is_editable, WC_Order $order ): bool
*/
public function add_cashier_select( WC_Order $order ): void {
// only show if order created by POS
if ( 'woocommerce-pos' !== $order->get_created_via()) {
if ( 'woocommerce-pos' !== $order->get_created_via() ) {
return;
}
$cashier_id = $order->get_meta('_pos_user');

$cashier_id = $order->get_meta( '_pos_user' );

// Create nonce for security
wp_nonce_field('pos_cashier_select_action', 'pos_cashier_select_nonce');
wp_nonce_field( 'pos_cashier_select_action', 'pos_cashier_select_nonce' );

echo '<p class="form-field form-field-wide">';
echo '<label for="_pos_user">' . esc_html__( 'POS Cashier', 'woocommerce-pos' ) . ':</label>';
echo '<select class="wc-customer-search" id="_pos_user" name="_pos_user" data-placeholder="' . esc_attr__('Search for a cashier&hellip;', 'woocommerce-pos') . '" data-allow_clear="true" style="width: 100%;">';
if ($cashier_id) {
$user = get_user_by('id', $cashier_id);
if ($user) {
echo '<option value="' . esc_attr($user->ID) . '"' . selected(true, true, false) . '>' . esc_html($user->display_name . ' (#' . $user->ID . ' &ndash; ' . $user->user_email) . ')</option>';
echo '<select class="wc-customer-search" id="_pos_user" name="_pos_user" data-placeholder="' . esc_attr__( 'Search for a cashier&hellip;', 'woocommerce-pos' ) . '" data-allow_clear="true" style="width: 100%;">';
if ( $cashier_id ) {
$user = get_user_by( 'id', $cashier_id );
if ( $user ) {
echo '<option value="' . esc_attr( $user->ID ) . '"' . selected( true, true, false ) . '>' . esc_html( $user->display_name . ' (#' . $user->ID . ' &ndash; ' . $user->user_email ) . ')</option>';
}
}
echo '</select>';
Expand All @@ -61,19 +61,19 @@ public function add_cashier_select( WC_Order $order ): void {
*/
public function save_cashier_select( $post_id ): void {
// Security checks
if ( ! isset($_POST['pos_cashier_select_nonce']) || ! wp_verify_nonce($_POST['pos_cashier_select_nonce'], 'pos_cashier_select_action')) {
if ( ! isset( $_POST['pos_cashier_select_nonce'] ) || ! wp_verify_nonce( $_POST['pos_cashier_select_nonce'], 'pos_cashier_select_action' ) ) {
return;
}

/**
* NOTE: HPOS adds a second arg for WC_Order, but we will make it backwards compatible.
*/
$order = wc_get_order($post_id);
$order = wc_get_order( $post_id );

// Check if $order is instance of WC_Order and $_POST['_pos_user'] is set
if ( $order instanceof WC_Order && isset($_POST['_pos_user']) ) {
$new_pos_cashier = (int) sanitize_text_field($_POST['_pos_user']);
$current_pos_cashier = (int) $order->get_meta('_pos_user');
if ( $order instanceof WC_Order && isset( $_POST['_pos_user'] ) ) {
$new_pos_cashier = (int) sanitize_text_field( $_POST['_pos_user'] );
$current_pos_cashier = (int) $order->get_meta( '_pos_user' );

// Update meta only if _pos_user has changed
if ( $current_pos_cashier !== $new_pos_cashier ) {
Expand All @@ -85,9 +85,9 @@ public function save_cashier_select( $post_id ): void {
$new_cashier = get_userdata( $new_pos_cashier );
$note = sprintf(
// translators: 1: old POS cashier, 2: new POS cashier
__('POS cashier changed from %1$s to %2$s.', 'woocommerce-pos'),
$current_cashier ? $current_cashier->display_name : __('Unknown', 'woocommerce-pos'),
$new_cashier ? $new_cashier->display_name : __('Unknown', 'woocommerce-pos')
__( 'POS cashier changed from %1$s to %2$s.', 'woocommerce-pos' ),
$current_cashier ? $current_cashier->display_name : __( 'Unknown', 'woocommerce-pos' ),
$new_cashier ? $new_cashier->display_name : __( 'Unknown', 'woocommerce-pos' )
);
$order->add_order_note( $note );
}
Expand Down
4 changes: 2 additions & 2 deletions includes/Templates/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function head(): void {
public function footer(): void {
$development = isset( $_ENV['DEVELOPMENT'] ) && $_ENV['DEVELOPMENT'];
$user = wp_get_current_user();
$github_url = 'https://cdn.jsdelivr.net/gh/wcpos/web-bundle@1.4/';
$github_url = 'https://cdn.jsdelivr.net/gh/wcpos/web-bundle@latest/';
$auth_service = Auth::instance();
$stores = array_map(
function ( $store ) {
Expand Down Expand Up @@ -181,7 +181,7 @@ function getScript(source, callback) {
.then((response) => response.json())
.then((data) => {
var bundle = data.fileMetadata.web.bundle;
var bundleUrl = '{$github_url}' + '/' + bundle;
var bundleUrl = '{$github_url}' + bundle;
getScript(bundleUrl, () => { console.log('done') });
});
</script>" . "\n";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wcpos/woocommerce-pos",
"version": "1.4.6",
"version": "1.4.7",
"description": "A simple front-end for taking WooCommerce orders at the Point of Sale.",
"main": "index.js",
"workspaces": {
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: kilbot
Tags: cart, e-commerce, ecommerce, inventory, point-of-sale, pos, sales, sell, shop, shopify, store, vend, woocommerce, wordpress-ecommerce
Requires at least: 5.6 & WooCommerce 5.3
Tested up to: 6.4
Stable tag: 1.4.6
Stable tag: 1.4.7
License: GPL-3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -63,6 +63,11 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co

== Changelog ==

= 1.4.7 - 2024/01/18 =
* Bump: web application to version 1.4.1
* Fix: scroll-to-top issue when scrolling data tables
* Fix: variations not loading after first 10

= 1.4.6 - 2024/01/16 =
* Fix: decimal quantity for orders
* Fix: load translation files
Expand Down
4 changes: 2 additions & 2 deletions woocommerce-pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce POS
* Plugin URI: https://wordpress.org/plugins/woocommerce-pos/
* Description: A simple front-end for taking WooCommerce orders at the Point of Sale. Requires <a href="http://wordpress.org/plugins/woocommerce/">WooCommerce</a>.
* Version: 1.4.6
* Version: 1.4.7
* Author: kilbot
* Author URI: http://wcpos.com
* Text Domain: woocommerce-pos
Expand All @@ -22,7 +22,7 @@
namespace WCPOS\WooCommercePOS;

// Define plugin constants.
const VERSION = '1.4.6';
const VERSION = '1.4.7';
const PLUGIN_NAME = 'woocommerce-pos';
const SHORT_NAME = 'wcpos';
\define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'
Expand Down

0 comments on commit 471dba2

Please sign in to comment.