Skip to content

Commit

Permalink
add min/max price to variable meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed May 19, 2023
1 parent e10b552 commit c1719c1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
25 changes: 25 additions & 0 deletions includes/API/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@ public function product_response( WP_REST_Response $response, WC_Data $product,
Logger::log( "Product ID {$product->get_id()} has a response size of {$response_size} bytes, exceeding the limit of {$max_response_size} bytes." );
}

/**
* If product is variable, add the max and min prices and add them to the meta data
* @TODO - only need to update if there is a change
*/
if ( $product->is_type( 'variable' ) ) {
$product->update_meta_data( '_woocommerce_pos_variable_prices', wp_json_encode(
array(
'price' => array(
'min' => $product->get_variation_price(),
'max' => $product->get_variation_price( 'max' ),
),
'regular_price' => array(
'min' => $product->get_variation_regular_price(),
'max' => $product->get_variation_regular_price( 'max' ),
),
'sale_price' => array(
'min' => $product->get_variation_sale_price(),
'max' => $product->get_variation_sale_price( 'max' ),
),
)
) );
$product->save_meta_data();
$data['meta_data'] = $product->get_meta_data();
}

/**
* Reset the new response data
*/
Expand Down
2 changes: 2 additions & 0 deletions includes/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public function rest_pre_serve_request( bool $served, WP_HTTP_Response $result,
/**
* Allow HEAD checks for WP API Link URL and server uptime
* Fires once the requested HTTP headers for caching, content type, etc. have been sent.
*
* FIXME: Why is Link header not exposed sometimes on my development machine?
*/
public function send_headers(): void {
// some server convert HEAD to GET method, so use this query param instead
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.0.2",
"version": "1.1.0",
"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.2
Stable tag: 1.0.2
Stable tag: 1.1.0
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.1.0 - 2023/05/19 =
* Fix: disable Lite Speed Cache for POS page
* Fix: add id audit for product categories and tags
* Fix: add min/max price to variable meta data

= 1.0.2 - 2023/05/05 =
* No change, just messed up the release to WordPress.org.

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.0.2
* Version: 1.1.0
* Author: kilbot
* Author URI: http://wcpos.com
* Text Domain: woocommerce-pos
Expand All @@ -23,7 +23,7 @@
use Dotenv\Dotenv;

// Define plugin constants.
const VERSION = '1.0.2';
const VERSION = '1.1.0';
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 c1719c1

Please sign in to comment.