Overview
  • Namespace
  • Class

Namespaces

  • None
  • WC_POS
    • Admin
      • Settings
        • Receipt
    • API
    • Gateways
    • Integrations
    • Products

Classes

  • WC_POS\Activator
  • WC_POS\Admin
  • WC_POS\Admin\Gateways
  • WC_POS\Admin\Menu
  • WC_POS\Admin\Notices
  • WC_POS\Admin\Orders
  • WC_POS\Admin\Page
  • WC_POS\Admin\Permalink
  • WC_POS\Admin\Plugins
  • WC_POS\Admin\Products
  • WC_POS\Admin\Settings
  • WC_POS\Admin\Settings\Access
  • WC_POS\Admin\Settings\Checkout
  • WC_POS\Admin\Settings\Customers
  • WC_POS\Admin\Settings\Gateways
  • WC_POS\Admin\Settings\General
  • WC_POS\Admin\Settings\HotKeys
  • WC_POS\Admin\Settings\Page
  • WC_POS\Admin\Settings\Receipt\Options
  • WC_POS\Admin\Settings\Receipt\Template
  • WC_POS\Admin\Settings\Receipts
  • WC_POS\Admin\Settings\Status
  • WC_POS\Admin\Settings\Tools
  • WC_POS\Admin\Status
  • WC_POS\Ajax
  • WC_POS\API
  • WC_POS\API\Coupons
  • WC_POS\API\Customers
  • WC_POS\API\Gateways
  • WC_POS\API\i18n
  • WC_POS\API\Orders
  • WC_POS\API\Params
  • WC_POS\API\Payload
  • WC_POS\API\Products
  • WC_POS\API\Settings
  • WC_POS\API\Support
  • WC_POS\API\Templates
  • WC_POS\Customers
  • WC_POS\Deactivator
  • WC_POS\Gateways
  • WC_POS\Gateways\Card
  • WC_POS\Gateways\Cash
  • WC_POS\i18n
  • WC_POS\Integrations\Bookings
  • WC_POS\Products
  • WC_POS\Products\Visibility
  • WC_POS\Setup
  • WC_POS\Status
  • WC_POS\Tax
  • WC_POS\Template

Functions

  • is_pos
  • is_pos_admin
  • wc_pos_get_option
  • wc_pos_json_encode
  • wc_pos_locate_template
  • wc_pos_trim_html_string
  • wc_pos_update_option
  • wc_pos_url
 1 <?php
 2 
 3 /**
 4  * POS Product Class
 5  * duck punches the WC REST API
 6  *
 7  * @class    WC_POS_API_Products
 8  * @package  WooCommerce POS
 9  * @author   Paul Kilmurray <paul@kilbot.com.au>
10  * @link     http://www.woopos.com.au
11  */
12 
13 namespace WC_POS;
14 
15 class Products {
16 
17   /**
18    * Constructor
19    */
20   public function __construct() {
21     add_action( 'woocommerce_product_set_stock', array( $this, 'product_set_stock') );
22     add_action( 'woocommerce_variation_set_stock', array( $this, 'product_set_stock') );
23     $this->init();
24   }
25 
26   /**
27    * Load Product subclasses
28    */
29   private function init() {
30 
31     // pos only products
32     if( wc_pos_get_option( 'general', 'pos_only_products' ) ) {
33       new Products\Visibility();
34     }
35 
36     // decimal quantities
37     if( wc_pos_get_option( 'general', 'decimal_qty' ) ){
38       remove_filter('woocommerce_stock_amount', 'intval');
39       add_filter( 'woocommerce_stock_amount', 'floatval' );
40     }
41 
42   }
43 
44   /**
45    * Bump modified date on stock change
46    * - variation->id = parent id
47    * @param $product
48    */
49   public function product_set_stock( $product ){
50     $post_modified     = current_time( 'mysql' );
51     $post_modified_gmt = current_time( 'mysql', 1 );
52     wp_update_post( array(
53       'ID'                => $product->id,
54       'post_modified'     => $post_modified,
55       'post_modified_gmt' => $post_modified_gmt
56     ));
57   }
58 
59 }
API documentation generated by ApiGen