Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
fix decimal display
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Jun 9, 2015
1 parent 76e430c commit 358d95f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion includes/admin/class-wc-pos-settings.php
Expand Up @@ -208,7 +208,7 @@ public function enqueue_admin_scripts() {
);

$scripts = apply_filters( 'woocommerce_pos_admin_enqueue_scripts', array() );
if( $scripts['locale'] ) {
if( isset( $scripts['locale'] ) ) {
wp_enqueue_script(
WC_POS_PLUGIN_NAME . '-js-locale',
$scripts['locale'],
Expand Down
10 changes: 9 additions & 1 deletion includes/api/class-wc-pos-products.php
Expand Up @@ -18,6 +18,12 @@ class WC_POS_API_Products extends WC_POS_API_Abstract {
public function __construct() {
add_filter( 'woocommerce_api_product_response', array( $this, 'product_response' ), 10, 4 );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );

$general_settings = new WC_POS_Admin_Settings_General();
if( $general_settings->get_data('decimal_qty') ){
remove_filter('woocommerce_stock_amount', 'intval');
add_filter( 'woocommerce_stock_amount', 'floatval' );
}
}

/**
Expand All @@ -32,7 +38,6 @@ public function __construct() {
* @return array modified data array $product_data
*/
public function product_response( $product_data, $product, $fields, $server ) {

// remove some unnecessary keys
// - saves storage space in IndexedDB
// - saves bandwidth transferring the data
Expand Down Expand Up @@ -64,6 +69,9 @@ public function product_response( $product_data, $product, $fields, $server ) {
unset($product_data[$key]);
}

// allow decimal stock quantities
$product_data['stock_quantity'] = $product->get_stock_quantity();

// use thumbnails for images
if( $thumb_id = get_post_thumbnail_id( $product_data['id'] ) ) {
$image = wp_get_attachment_image_src( $thumb_id, 'shop_thumbnail' );
Expand Down
4 changes: 3 additions & 1 deletion includes/class-wc-pos-ajax.php
Expand Up @@ -164,6 +164,9 @@ public function email_receipt() {
'result' => 'success',
'message' => __( 'Email sent', 'woocommerce-pos')
);

// hook for third party plugins
do_action( 'woocommerce_pos_email_receipt', $email, $order_id, $order );
} else {
$response = array(
'result' => 'error',
Expand All @@ -177,7 +180,6 @@ public function email_receipt() {
*
*/
public function send_support_email() {

$headers[] = 'From: '. $_POST['name'] .' <'. $_POST['email'] .'>';
$message = $_POST['message'] . "\n\n" . $_POST['status'];
$support = apply_filters( 'woocommerce_pos_support_email', 'support@woopos.com.au' );
Expand Down
2 changes: 1 addition & 1 deletion includes/views/pos/products.php
Expand Up @@ -54,7 +54,7 @@
</dl>
{{/is}}
{{#if managing_stock}}
<small><?php /* translators: woocommerce */ printf( __( '%s in stock', 'woocommerce' ), '{{stock_quantity}}' ); ?></small>
<small><?php /* translators: woocommerce */ printf( __( '%s in stock', 'woocommerce' ), '{{number stock_quantity precision="auto"}}' ); ?></small>
{{/if}}
</div>
<div class="price">
Expand Down
2 changes: 1 addition & 1 deletion includes/views/pos/receipt.php
Expand Up @@ -20,7 +20,7 @@
<script type="text/x-handlebars-template" id="tmpl-receipt-items">
{{#each line_items}}
<li>
<div class="qty">{{quantity}}</div>
<div class="qty">{{number quantity precision="auto"}}</div>
<div class="title">
{{name}}
{{#with meta}}
Expand Down
2 changes: 1 addition & 1 deletion includes/views/print/receipt.php
Expand Up @@ -160,7 +160,7 @@
</dl>
{{/with}}
</td>
<td class="qty">{{quantity}}</td>
<td class="qty">{{number quantity precision="auto"}}</td>
<td class="price">
{{#if on_sale}}
<del>{{{money subtotal}}}</del>
Expand Down
9 changes: 9 additions & 0 deletions readme.txt
Expand Up @@ -77,6 +77,15 @@ Bugs can be reported on the [WooCommerce POS GitHub repository](https://github.c

== Changelog ==

= 0.4.1 =
* New: added woocommerce_pos_email_receipt hook
* Improve: editing a product title in cart
* Improve: css tweaks for Firefox
* Fix: create_order error for WC version 2.2.x
* Fix: Internal Server Error for PHP 5.2.x
* Fix: parse $HTTP_RAW_POST_DATA global to array
* Fix: decimal quantity display

= 0.4 =
* Note: this is a major code refactor, almost every line of code has been rewritten
* Please check your POS admin after upgrade as many settings have changed
Expand Down

0 comments on commit 358d95f

Please sign in to comment.