Plugin Directory

Changeset 2926151


Ignore:
Timestamp:
06/14/2023 07:49:39 PM (3 years ago)
Author:
foosales
Message:

Release 1.34.0

Location:
foosales
Files:
367 added
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • foosales/trunk/classes/class-foosales-rest-api.php

    r2919862 r2926151  
    363363            $result = fsfwc_do_update_product( json_decode( $request->get_param( 'param2' ), true ), $platform );
    364364
    365             if ( false !== $result && is_array( $result ) ) {
     365            if ( ! empty( $result ) ) {
    366366                $updated_product  = $result['updated_product'];
    367367                $sale_product_ids = $result['sale_product_ids'];
     
    11561156     * @since 1.31.0
    11571157     * @param boolean              $purchasable Whether the variation is purchasable.
    1158      * @param WC_Product_Variation $product The product variation.
     1158     * @param WC_Product_Variation $wc_product_variation The product variation.
    11591159     *
    11601160     * @return boolean
    11611161     */
    1162     public function fsfwc_variation_is_purchasable( $purchasable, $product ) {
     1162    public function fsfwc_variation_is_purchasable( $purchasable, $wc_product_variation ) {
    11631163        return true;
    11641164    }
  • foosales/trunk/classes/class-foosales-xmlrpc.php

    r2921885 r2926151  
    194194    $result = fsfwc_do_update_product( $product_data );
    195195
    196     if ( false !== $result && is_array( $result ) ) {
     196    if ( ! empty( $result ) ) {
    197197        $updated_product  = $result['updated_product'];
    198198        $sale_product_ids = $result['sale_product_ids'];
     
    215215 */
    216216function fsfwc_create_order( $args ) {
    217     fsfwc_create_update_order( $args );
     217    $this->fsfwc_create_update_order( $args );
    218218}
    219219
     
    243243    $existing_order_id           = $args[15];
    244244
    245     $new_order = fsfwc_do_create_update_order(
     245    $created_updated_order = fsfwc_do_create_update_order(
    246246        array(
    247247            $order_date,
     
    264264    $response = array(
    265265        'status' => 'success',
    266         'order'  => fsfwc_do_get_single_order( $new_order ),
     266        'order'  => fsfwc_do_get_single_order( $created_updated_order ),
    267267    );
    268268
  • foosales/trunk/classes/class-foosales.php

    r2919862 r2926151  
    8989        add_filter( 'woocommerce_email_enabled_new_order', array( $this, 'fsfwc_conditionally_send_wc_email' ), 10, 2 );
    9090
     91        // WooCommerce HPOS.
     92        add_filter( 'woocommerce_order_list_table_prepare_items_query_args', array( $this, 'fsfwc_filter_order_results_hpos' ) );
     93        add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $this, 'fsfwc_order_column' ), 20 );
     94        add_action( 'woocommerce_order_list_table_restrict_manage_orders', array( $this, 'fsfwc_filter_orders_payment_method' ), 9999 );
     95        add_action( 'woocommerce_order_list_table_restrict_manage_orders', array( $this, 'fsfwc_filter_orders_cashier' ), 9999 );
     96        add_action( 'manage_woocommerce_page_wc-orders_custom_column', array( $this, 'fsfwc_order_column_content' ), 20, 2 );
     97
     98        // Traditional CPT-based orders.
    9199        add_filter( 'parse_query', array( $this, 'fsfwc_filter_order_results' ) );
    92100        add_filter( 'manage_edit-shop_order_columns', array( $this, 'fsfwc_order_column' ), 20 );
    93         add_action( 'restrict_manage_posts', array( $this, 'fsfwc_filter_orders_payment_method' ) );
    94         add_action( 'restrict_manage_posts', array( $this, 'fsfwc_filter_orders_cashier' ) );
    95         add_action( 'manage_shop_order_posts_custom_column', array( $this, 'fsfwc_order_column_content' ) );
     101        add_action( 'restrict_manage_posts', array( $this, 'fsfwc_filter_orders_payment_method' ), 9999 );
     102        add_action( 'restrict_manage_posts', array( $this, 'fsfwc_filter_orders_cashier' ), 9999 );
     103        add_action( 'manage_shop_order_posts_custom_column', array( $this, 'fsfwc_order_column_content' ), 20, 2 );
     104
    96105        add_action( 'woocommerce_admin_order_data_after_order_details', array( $this, 'fsfwc_order_meta_general' ) );
    97         add_action( 'save_post', array( $this, 'fsfwc_order_meta_save_cashier' ) );
     106        add_action( 'woocommerce_process_shop_order_meta', array( $this, 'fsfwc_order_meta_save_cashier' ) );
    98107        add_action( 'woocommerce_checkout_create_order', array( $this, 'fsfwc_before_checkout_create_order' ), 20, 2 );
    99108        add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'fsfwc_update_order_meta' ) );
     
    950959        return $links;
    951960
     961    }
     962
     963    /**
     964     * Filter WooCommerce orders listing based on FooSales filter selection.
     965     *
     966     * @since 1.34.0
     967     * @param array $args The query arguments used in the (Custom Order Table-powered) order list.
     968     *
     969     * @return array
     970     */
     971    public function fsfwc_filter_order_results_hpos( $args ) {
     972
     973        global $pagenow;
     974
     975        if ( is_admin() && 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'wc-orders' === $_GET['page'] && 'shop_order' === $args['type'] && isset( $_GET['foosales_payment_method_filter'] ) && isset( $_GET['foosales_cashier_filter'] ) && ( '' !== sanitize_text_field( wp_unslash( $_GET['foosales_payment_method_filter'] ) ) || '' !== sanitize_text_field( wp_unslash( $_GET['foosales_cashier_filter'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     976
     977            if ( ! empty( $args['meta_query'] ) ) {
     978                $args['meta_query']['relation'] = 'AND';
     979            } else {
     980                $args['meta_query'] = array( // phpcs:ignore WordPress.DB.SlowDBQuery
     981                    'relation' => 'AND',
     982                );
     983            }
     984
     985            if ( '' !== sanitize_text_field( wp_unslash( $_GET['foosales_payment_method_filter'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     986                $foosales_payment_method_filter = sanitize_text_field( wp_unslash( $_GET['foosales_payment_method_filter'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     987                $payment_method_options         = array(
     988                    'pos-cash'                 => 'foosales_cash',
     989                    'pos-card'                 => 'foosales_card',
     990                    'pos-direct-bank-transfer' => 'foosales_direct_bank_transfer',
     991                    'pos-check-payment'        => 'foosales_check_payment',
     992                    'pos-cash-on-delivery'     => 'foosales_cash_on_delivery',
     993                    'pos-square-manual'        => 'foosales_square_manual',
     994                    'pos-square-terminal'      => 'foosales_square_terminal',
     995                    'pos-square-reader'        => 'foosales_square_reader',
     996                    'pos-stripe-manual'        => 'foosales_stripe_manual',
     997                    'pos-stripe-reader'        => 'foosales_stripe_reader',
     998                    'pos-stripe-chipper'       => 'foosales_stripe_chipper',
     999                    'pos-stripe-wisepad'       => 'foosales_stripe_wisepad',
     1000                    'pos-stripe-reader-m2'     => 'foosales_stripe_reader_m2',
     1001                    'pos-other'                => 'foosales_other',
     1002                );
     1003
     1004                if ( in_array( $foosales_payment_method_filter, array_keys( $payment_method_options ), true ) ) {
     1005                    if ( 'pos-square-reader' === $foosales_payment_method_filter ) {
     1006                        $args['meta_query'][] = array( // phpcs:ignore WordPress.DB.SlowDBQuery
     1007                            'relation' => 'OR',
     1008                            array(
     1009                                'key'   => '_foosales_payment_method',
     1010                                'value' => 'foosales_square_reader',
     1011                            ),
     1012                            array(
     1013                                'key'   => '_foosales_payment_method',
     1014                                'value' => 'foosales_square',
     1015                            ),
     1016                        );
     1017                    } else {
     1018                        $args['meta_query'][] = array( // phpcs:ignore WordPress.DB.SlowDBQuery
     1019                            'key'   => '_foosales_payment_method',
     1020                            'value' => $payment_method_options[ $foosales_payment_method_filter ],
     1021                        );
     1022                    }
     1023                } else {
     1024                    switch ( $foosales_payment_method_filter ) {
     1025                        case 'pos-all':
     1026                            // All FooSales payments.
     1027                            $args['meta_query'][] = array( // phpcs:ignore WordPress.DB.SlowDBQuery
     1028                                'key'   => '_foosales_order_source',
     1029                                'value' => 'foosales_app',
     1030                            );
     1031
     1032                            break;
     1033                        case 'pos-none':
     1034                            // Online orders only.
     1035                            $args['meta_query'][] = array( // phpcs:ignore WordPress.DB.SlowDBQuery
     1036                                'relation' => 'OR',
     1037                                array(
     1038                                    'key'     => '_foosales_payment_method',
     1039                                    'compare' => 'NOT EXISTS',
     1040                                ),
     1041                                array(
     1042                                    'key'     => '_foosales_payment_method',
     1043                                    'value'   => '',
     1044                                    'compare' => '=',
     1045                                ),
     1046                            );
     1047
     1048                            break;
     1049                    }
     1050                }
     1051            }
     1052
     1053            if ( '' !== sanitize_text_field( wp_unslash( $_GET['foosales_cashier_filter'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     1054                $foosales_cashier_filter = sanitize_text_field( wp_unslash( $_GET['foosales_cashier_filter'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     1055
     1056                $args['meta_query'][] = array( // phpcs:ignore WordPress.DB.SlowDBQuery
     1057                    'key'     => '_foosales_user_id',
     1058                    'value'   => $foosales_cashier_filter,
     1059                    'compare' => '=',
     1060                );
     1061            }
     1062        }
     1063
     1064        return $args;
    9521065    }
    9531066
     
    10571170     *
    10581171     * @since 1.10.0
    1059      */
    1060     public function fsfwc_filter_orders_payment_method() {
    1061 
    1062         global $wpdb, $post_type;
     1172     * @param string $post_type The post type.
     1173     */
     1174    public function fsfwc_filter_orders_payment_method( $post_type ) {
    10631175
    10641176        if ( 'shop_order' === $post_type ) {
     
    11291241     *
    11301242     * @since 1.22.0
    1131      */
    1132     public function fsfwc_filter_orders_cashier() {
    1133 
    1134         global $wpdb, $post_type, $wp_roles;
     1243     * @param string $post_type The post type.
     1244     */
     1245    public function fsfwc_filter_orders_cashier( $post_type ) {
     1246
     1247        global $wp_roles;
    11351248
    11361249        if ( 'shop_order' === $post_type ) {
     
    12261339     * @since 1.10.0
    12271340     * @param string $column The column for which content should be added.
    1228      */
    1229     public function fsfwc_order_column_content( $column ) {
    1230         global $post;
     1341     * @param int    $order_id The ID of the current order.
     1342     */
     1343    public function fsfwc_order_column_content( $column, $order_id ) {
     1344        $order = wc_get_order( $order_id );
    12311345
    12321346        if ( 'foosales_column_cashier' === $column ) {
    12331347
    1234             $foosales_user_id = get_post_meta( $post->ID, '_foosales_user_id', true );
     1348            $foosales_user_id = $order->get_meta( '_foosales_user_id', true );
    12351349
    12361350            if ( '' !== $foosales_user_id ) {
     
    12441358        } elseif ( 'foosales_column_type' === $column ) {
    12451359
    1246             $foosales_order_type = get_post_meta( $post->ID, '_foosales_payment_method', true );
     1360            $foosales_order_type = $order->get_meta( '_foosales_payment_method', true );
    12471361
    12481362            $payment_methods            = fsfwc_do_get_all_payment_methods( true );
     
    12901404    public function fsfwc_order_meta_general( $order ) {
    12911405
    1292         $foosales_source             = get_post_meta( $order->get_id(), '_foosales_order_source', true );
    1293         $foosales_payment_method     = get_post_meta( $order->get_id(), '_foosales_payment_method', true );
    1294         $foosales_payment_method_pub = get_post_meta( $order->get_id(), 'Order Payment Method', true );
    1295         $foosales_user_id            = get_post_meta( $order->get_id(), '_foosales_user_id', true );
     1406        $foosales_source             = $order->get_meta( '_foosales_order_source', true );
     1407        $foosales_payment_method     = $order->get_meta( '_foosales_payment_method', true );
     1408        $foosales_payment_method_pub = $order->get_meta( 'Order Payment Method', true );
     1409        $foosales_user_id            = $order->get_meta( '_foosales_user_id', true );
    12961410
    12971411        if ( '' !== $foosales_user_id ) {
     
    13331447
    13341448            echo "<br class='clear' />";
    1335             echo '<p class="form-field form-field-wide">';
    1336             echo '<label for="_foosales_user_id">' . esc_html( $this->foosales_phrases['label_order_cashier'] ) . ':';
    1337 
    1338             if ( '' !== $foosales_user_id ) {
    1339                 echo '<a href="' . esc_attr( admin_url( 'edit.php?post_type=shop_order&foosales_payment_method_filter&foosales_cashier_filter=' . $foosales_user_id ) ) . '" class="foosales-right-link" target="_blank">' . esc_html( $this->foosales_phrases['text_view_other_orders'] ) . '&nbsp;&rarr;</a>';
    1340             }
    1341 
    1342             echo '</label>';
    1343             ?>
    1344             <select id="_foosales_user_id" name="_foosales_user_id">
    1345                 <option value="">(<?php echo esc_html( $this->foosales_phrases['filter_none'] ); ?>)</option>
    1346                 <?php
    1347                 foreach ( $foosales_users as $foosales_user ) {
    1348                     echo '<option value="' . esc_attr( $foosales_user->ID ) . '" ';
    1349 
    1350                     if ( strval( $foosales_user->ID ) === $foosales_user_id ) {
    1351                         echo ' selected ';
    1352                     }
    1353 
    1354                     echo ' >' . esc_html( $foosales_user->display_name ) . '</option>';
    1355                 }
    1356                 ?>
    1357             </select>
    1358             <?php
    1359             wp_nonce_field( '_foosales_save_order_cashier_' . $order->get_id(), '_foosales_order_cashier_nonce' );
    1360 
    1361             echo '</p>';
     1449
     1450            $cashier_options = array( '' => '(' . $this->foosales_phrases['filter_none'] . ')' );
     1451
     1452            foreach ( $foosales_users as $foosales_user ) {
     1453                $cashier_options[ (string) $foosales_user->ID ] = $foosales_user->display_name;
     1454            }
     1455
     1456            woocommerce_wp_select(
     1457                array(
     1458                    'id'            => '_foosales_user_id',
     1459                    'label'         => $this->foosales_phrases['label_order_cashier'] . ':' . ( '' !== $foosales_user_id ? '<a href="' . esc_attr( admin_url( 'edit.php?post_type=shop_order&foosales_payment_method_filter&foosales_cashier_filter=' . $foosales_user_id ) ) . '" class="foosales-right-link" target="_blank">' . esc_html( $this->foosales_phrases['text_view_other_orders'] ) . '&nbsp;&rarr;</a>' : '' ),
     1460                    'value'         => (string) $foosales_user_id,
     1461                    'options'       => $cashier_options,
     1462                    'wrapper_class' => 'form-field-wide',
     1463                )
     1464            );
     1465
    13621466            echo "<br class='clear' />";
    13631467            echo '<h3>' . esc_html( $this->foosales_phrases['title_payment_details'] ) . '</h3>';
     
    13831487            ) ) {
    13841488
    1385                 $square_order_id = get_post_meta( $order->get_id(), '_foosales_square_order_id', true );
     1489                $square_order_id = $order->get_meta( '_foosales_square_order_id', true );
    13861490
    13871491                if ( '' !== $square_order_id ) {
    13881492
    1389                     $square_auto_refund = get_post_meta( $order->get_id(), '_foosales_square_order_auto_refund', true );
     1493                    $square_auto_refund = $order->get_meta( '_foosales_square_order_auto_refund', true );
    13901494
    13911495                    echo '<br/>';
     
    14151519            ) ) {
    14161520
    1417                 $stripe_payment_id = get_post_meta( $order->get_id(), '_foosales_stripe_payment_id', true );
     1521                $stripe_payment_id = $order->get_meta( '_foosales_stripe_payment_id', true );
    14181522
    14191523                if ( '' !== $stripe_payment_id ) {
     
    14471551     *
    14481552     * @since 1.27.0
    1449      * @param int $post_id The post ID.
    1450      */
    1451     public function fsfwc_order_meta_save_cashier( $post_id ) {
    1452 
    1453         // Do not save if this is an autosave or the form has not been submitted.
    1454         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
    1455             return;
    1456         }
    1457 
    1458         if ( isset( $_POST['_foosales_order_cashier_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_foosales_order_cashier_nonce'] ) ), '_foosales_save_order_cashier_' . $post_id ) ) {
    1459             // Check that the user has appropriate permissions.
    1460             if ( isset( $_POST['post_type'] ) && 'shop_order' === $_POST['post_type'] ) {
    1461                 if ( current_user_can( 'edit_shop_order', $post_id ) ) {
    1462                     if ( isset( $_POST['_foosales_user_id'] ) ) {
    1463                         update_post_meta( $post_id, '_foosales_user_id', sanitize_text_field( wp_unslash( $_POST['_foosales_user_id'] ) ) );
    1464                     }
    1465                 }
    1466             }
     1553     * @param int $order_id The order ID.
     1554     */
     1555    public function fsfwc_order_meta_save_cashier( $order_id ) {
     1556        if ( isset( $_POST['_foosales_user_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
     1557            $order = wc_get_order( $order_id );
     1558            $order->update_meta_data( '_foosales_user_id', sanitize_text_field( wp_unslash( $_POST['_foosales_user_id'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
     1559            $order->save();
    14671560        }
    14681561    }
     
    15741667    public function fsfwc_conditionally_send_wc_email( $whether_enabled, $order ) {
    15751668
    1576         if ( ! empty( $order ) && 'foosales_app' === get_post_meta( $order->get_id(), '_foosales_order_source', true ) ) {
     1669        if ( ! empty( $order ) && 'foosales_app' === $order->get_meta( '_foosales_order_source', true ) ) {
    15771670
    15781671            $disable_new_order_emails = 'yes' === get_option( 'globalFooSalesDisableNewOrderEmails', '' );
     
    16861779    public function fsfwc_update_order_meta( $order_id ) {
    16871780
    1688         update_post_meta( $order_id, '_foosales_order_source', 'online' );
     1781        $order = wc_get_order( $order_id );
     1782
     1783        $order->update_meta_data( '_foosales_order_source', 'online' );
     1784        $order->update_meta_data( '_foosales_payment_method', '' );
     1785
     1786        $order->save();
    16891787
    16901788    }
     
    18051903        global $foosales_products_default_cart_quantity_step;
    18061904        global $foosales_products_default_cart_quantity_unit;
     1905
     1906        $wc_product = wc_get_product( $post->ID );
    18071907
    18081908        echo '<div class="options_group">';
     
    18491949        );
    18501950
    1851         $foosales_product_override_default_cart_quantity_unit = get_post_meta( $post->ID, 'foosales_product_override_default_cart_quantity_unit', true );
     1951        $foosales_product_override_default_cart_quantity_unit = $wc_product->get_meta( 'foosales_product_override_default_cart_quantity_unit', true );
    18521952
    18531953        $foosales_product_cart_quantity_unit_args = array(
     
    18641964        woocommerce_wp_text_input( $foosales_product_cart_quantity_unit_args );
    18651965
    1866         wp_nonce_field( '_foosales_save_product_decimal_quantity_meta_' . $post->ID, '_foosales_product_decimal_quantity_meta_nonce' );
     1966        wp_nonce_field( '_foosales_save_product_decimal_quantity_meta_' . $wc_product->get_id(), '_foosales_product_decimal_quantity_meta_nonce' );
    18671967
    18681968        echo '</div>';
     
    18731973     *
    18741974     * @since 1.27.0
    1875      * @param int $post_id The current product post ID.
    1876      */
    1877     public function fsfwc_woocommerce_process_product_cart_minimum_step_field( $post_id ) {
     1975     * @param int $product_id The current product ID.
     1976     */
     1977    public function fsfwc_woocommerce_process_product_cart_minimum_step_field( $product_id ) {
    18781978        global $foosales_products_default_minimum_cart_quantity;
    18791979        global $foosales_products_default_cart_quantity_step;
    18801980        global $foosales_products_default_cart_quantity_unit;
     1981
     1982        $wc_product = wc_get_product( $product_id );
    18811983
    18821984        $new_minimum_cart_quantity       = $foosales_products_default_minimum_cart_quantity;
     
    18851987        $new_cart_quantity_unit          = $foosales_products_default_cart_quantity_unit;
    18861988
    1887         if ( isset( $_POST['_foosales_product_decimal_quantity_meta_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_foosales_product_decimal_quantity_meta_nonce'] ) ), '_foosales_save_product_decimal_quantity_meta_' . $post_id ) ) {
     1989        if ( isset( $_POST['_foosales_product_decimal_quantity_meta_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_foosales_product_decimal_quantity_meta_nonce'] ) ), '_foosales_save_product_decimal_quantity_meta_' . $product_id ) ) {
    18881990            if ( isset( $_POST['foosales_product_minimum_cart_quantity'] ) ) {
    18891991                $new_minimum_cart_quantity = sanitize_text_field( wp_unslash( $_POST['foosales_product_minimum_cart_quantity'] ) );
     
    19032005        }
    19042006
    1905         update_post_meta( $post_id, 'foosales_product_minimum_cart_quantity', $new_minimum_cart_quantity );
    1906         update_post_meta( $post_id, 'foosales_product_cart_quantity_step', $new_cart_quantity_step );
    1907         update_post_meta( $post_id, 'foosales_product_override_default_cart_quantity_unit', $new_override_cart_quantity_unit );
    1908         update_post_meta( $post_id, 'foosales_product_cart_quantity_unit', $new_cart_quantity_unit );
     2007        $wc_product->update_meta_data( 'foosales_product_minimum_cart_quantity', $new_minimum_cart_quantity );
     2008        $wc_product->update_meta_data( 'foosales_product_cart_quantity_step', $new_cart_quantity_step );
     2009        $wc_product->update_meta_data( 'foosales_product_override_default_cart_quantity_unit', $new_override_cart_quantity_unit );
     2010        $wc_product->update_meta_data( 'foosales_product_cart_quantity_unit', $new_cart_quantity_unit );
     2011        $wc_product->save();
    19092012    }
    19102013
     
    19142017     * @since 1.27.0
    19152018     * @param float      $min The current minimum cart quantity amount.
    1916      * @param WC_Product $product The current WooCommerce cart product.
    1917      */
    1918     public function fsfwc_product_quantity_input_min( $min, $product ) {
     2019     * @param WC_Product $wc_product The current WooCommerce cart product.
     2020     */
     2021    public function fsfwc_product_quantity_input_min( $min, $wc_product ) {
    19192022        global $foosales_products_default_minimum_cart_quantity;
    19202023
    1921         if ( false !== $product ) {
    1922             $product_id = $product->get_id();
    1923 
    1924             $foosales_product_minimum_cart_quantity = get_post_meta( $product_id, 'foosales_product_minimum_cart_quantity', true );
     2024        if ( false !== $wc_product ) {
     2025            $foosales_product_minimum_cart_quantity = $wc_product->get_meta( 'foosales_product_minimum_cart_quantity', true );
    19252026
    19262027            if ( '' === $foosales_product_minimum_cart_quantity ) {
     
    19392040     * @since 1.27.0
    19402041     * @param float      $step The current cart quantity step amount.
    1941      * @param WC_Product $product The current WooCommerce cart product.
    1942      */
    1943     public function fsfwc_product_quantity_input_step( $step, $product ) {
     2042     * @param WC_Product $wc_product The current WooCommerce cart product.
     2043     */
     2044    public function fsfwc_product_quantity_input_step( $step, $wc_product ) {
    19442045        global $foosales_products_default_cart_quantity_step;
    19452046
    1946         if ( false !== $product ) {
    1947             $product_id = $product->get_id();
    1948 
    1949             $foosales_product_cart_quantity_step = get_post_meta( $product_id, 'foosales_product_cart_quantity_step', true );
     2047        if ( false !== $wc_product ) {
     2048            $foosales_product_cart_quantity_step = $wc_product->get_meta( 'foosales_product_cart_quantity_step', true );
    19502049
    19512050            if ( '' === $foosales_product_cart_quantity_step ) {
     
    19642063     * @since 1.27.0
    19652064     * @param array      $args The product's input arguments.
    1966      * @param WC_Product $product The current WooCommerce product.
    1967      */
    1968     public function fsfwc_product_quantity_input_args( $args, $product ) {
     2065     * @param WC_Product $wc_product The current WooCommerce product.
     2066     */
     2067    public function fsfwc_product_quantity_input_args( $args, $wc_product ) {
    19692068        global $foosales_products_default_minimum_cart_quantity;
    19702069        global $foosales_products_default_cart_quantity_step;
    19712070
    1972         $product_id        = $product->get_id();
    1973         $product_parent_id = $product->get_parent_id();
     2071        $product_id        = $wc_product->get_id();
     2072        $product_parent_id = $wc_product->get_parent_id();
    19742073
    19752074        if ( $product_parent_id > 0 ) {
     
    19772076        }
    19782077
    1979         $foosales_product_minimum_cart_quantity = get_post_meta( $product_id, 'foosales_product_minimum_cart_quantity', true );
     2078        $temp_product = wc_get_product( $product_id );
     2079
     2080        $foosales_product_minimum_cart_quantity = $temp_product->get_meta( 'foosales_product_minimum_cart_quantity', true );
    19802081
    19812082        if ( '' === $foosales_product_minimum_cart_quantity ) {
     
    19972098        }
    19982099
    1999         $foosales_product_cart_quantity_step = get_post_meta( $product_id, 'foosales_product_cart_quantity_step', true );
     2100        $foosales_product_cart_quantity_step = $temp_product->get_meta( 'foosales_product_cart_quantity_step', true );
    20002101
    20012102        if ( '' === $foosales_product_cart_quantity_step ) {
     
    20132114     *
    20142115     * @since 1.27.0
    2015      * @param array                $args The product variation's arguments.
    2016      * @param WC_Product           $product The current WooCommerce product.
    2017      * @param WC_Product_Variation $variation The current WooCommerce product variation.
    2018      */
    2019     public function fsfwc_product_available_variation( $args, $product, $variation ) {
     2116     * @param array               $args The product variation's arguments.
     2117     * @param WC_Product_Variable $wc_product The current WooCommerce product.
     2118     * @param WC_Product          $wc_product_variation The current WooCommerce product variation.
     2119     */
     2120    public function fsfwc_product_available_variation( $args, $wc_product, $wc_product_variation ) {
    20202121        global $foosales_products_default_minimum_cart_quantity;
    20212122
    2022         $product_id = $product->get_id();
    2023 
    2024         $foosales_product_minimum_cart_quantity = get_post_meta( $product_id, 'foosales_product_minimum_cart_quantity', true );
     2123        $foosales_product_minimum_cart_quantity = $wc_product->get_meta( 'foosales_product_minimum_cart_quantity', true );
    20252124
    20262125        if ( '' === $foosales_product_minimum_cart_quantity ) {
     
    20592158
    20602159        foreach ( $products as $product_id => $qty ) {
    2061             $foosales_product_minimum_cart_quantity = get_post_meta( $product_id, 'foosales_product_minimum_cart_quantity', true );
     2160            $wc_product = wc_get_product( $product_id );
     2161
     2162            $foosales_product_minimum_cart_quantity = $wc_product->get_meta( 'foosales_product_minimum_cart_quantity', true );
    20622163
    20632164            if ( '' === $foosales_product_minimum_cart_quantity ) {
     
    20652166            }
    20662167
    2067             $foosales_product_cart_quantity_step = get_post_meta( $product_id, 'foosales_product_cart_quantity_step', true );
     2168            $foosales_product_cart_quantity_step = $wc_product->get_meta( 'foosales_product_cart_quantity_step', true );
    20682169
    20692170            if ( '' === $foosales_product_cart_quantity_step ) {
     
    20712172            }
    20722173
    2073             $foosales_product_override_default_cart_quantity_unit = get_post_meta( $product_id, 'foosales_product_override_default_cart_quantity_unit', true );
     2174            $foosales_product_override_default_cart_quantity_unit = $wc_product->get_meta( 'foosales_product_override_default_cart_quantity_unit', true );
    20742175
    20752176            if ( 'yes' === $foosales_product_override_default_cart_quantity_unit ) {
    2076                 $foosales_product_cart_quantity_unit = get_post_meta( $product_id, 'foosales_product_cart_quantity_unit', true );
     2177                $foosales_product_cart_quantity_unit = $wc_product->get_meta( 'foosales_product_cart_quantity_unit', true );
    20772178            } else {
    20782179                $foosales_product_cart_quantity_unit = $foosales_products_default_cart_quantity_unit;
     
    21122213            global $foosales_products_default_minimum_cart_quantity;
    21132214
    2114             $foosales_product_minimum_cart_quantity = get_post_meta( $product_id, 'foosales_product_minimum_cart_quantity', true );
     2215            $wc_product = wc_get_product( $product_id );
     2216
     2217            $foosales_product_minimum_cart_quantity = $wc_product->get_meta( 'foosales_product_minimum_cart_quantity', true );
    21152218
    21162219            if ( ! $foosales_product_minimum_cart_quantity ) {
     
    21462249        global $post;
    21472250
     2251        $wc_product = wc_get_product( $post->ID );
     2252
    21482253        if ( ! function_exists( 'is_plugin_active' ) || ! function_exists( 'is_plugin_active_for_network' ) ) {
    21492254
     
    21552260
    21562261        // POS Settings.
    2157         $foosales_product_show_in_pos = get_post_meta( $post->ID, 'foosales_product_show_in_pos', true );
    2158         $foosales_product_pin_in_pos  = get_post_meta( $post->ID, 'foosales_product_pin_in_pos', true );
     2262        $foosales_product_show_in_pos = $wc_product->get_meta( 'foosales_product_show_in_pos', true );
     2263        $foosales_product_pin_in_pos  = $wc_product->get_meta( 'foosales_product_pin_in_pos', true );
    21592264
    21602265        $pos_settings = array(
     
    21662271
    21672272            // Event Settings.
    2168             $fooevents_pos_attendee_details     = get_post_meta( $post->ID, 'WooCommerceEventsPOSAttendeeDetails', true );
    2169             $fooevents_pos_attendee_email       = get_post_meta( $post->ID, 'WooCommerceEventsPOSAttendeeEmail', true );
    2170             $fooevents_pos_attendee_telephone   = get_post_meta( $post->ID, 'WooCommerceEventsPOSAttendeeTelephone', true );
    2171             $fooevents_pos_attendee_company     = get_post_meta( $post->ID, 'WooCommerceEventsPOSAttendeeCompany', true );
    2172             $fooevents_pos_attendee_designation = get_post_meta( $post->ID, 'WooCommerceEventsPOSAttendeeDesignation', true );
     2273            $fooevents_pos_attendee_details     = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeDetails', true );
     2274            $fooevents_pos_attendee_email       = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeEmail', true );
     2275            $fooevents_pos_attendee_telephone   = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeTelephone', true );
     2276            $fooevents_pos_attendee_company     = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeCompany', true );
     2277            $fooevents_pos_attendee_designation = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeDesignation', true );
    21732278
    21742279            ob_start();
    21752280
    2176             require_once $this->foosales_config->template_path . 'template-product-pos-settings-required-attendee-fields.php';
     2281            require plugin_dir_path( __FILE__ ) . 'templates/product-pos-settings-required-attendee-fields.php';
    21772282
    21782283            $required_attende_fields = ob_get_clean();
     
    21832288        }
    21842289
    2185         require_once $this->foosales_config->template_path . 'template-product-pos-settings.php';
     2290        require_once plugin_dir_path( __FILE__ ) . 'templates/product-pos-settings.php';
    21862291
    21872292    }
     
    21912296     *
    21922297     * @global object $woocommerce_errors
    2193      * @param int $post_id The post ID.
    2194      */
    2195     public function fsfwc_process_product_pos_settings_options( $post_id ) {
     2298     * @param int $product_id The product ID.
     2299     */
     2300    public function fsfwc_process_product_pos_settings_options( $product_id ) {
    21962301
    21972302        global $woocommerce_errors;
    21982303
    2199         if ( isset( $_POST['_foosales_pos_settings_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_foosales_pos_settings_nonce'] ) ), '_foosales_save_pos_settings_' . $post_id ) ) {
     2304        if ( isset( $_POST['_foosales_pos_settings_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_foosales_pos_settings_nonce'] ) ), '_foosales_save_pos_settings_' . $product_id ) ) {
     2305
     2306            $wc_product = wc_get_product( $product_id );
    22002307
    22012308            $foosales_product_show_in_pos = isset( $_POST['foosales_product_show_in_pos'] ) ? 'yes' : 'no';
    22022309
    2203             update_post_meta( $post_id, 'foosales_product_show_in_pos', $foosales_product_show_in_pos );
     2310            $wc_product->update_meta_data( 'foosales_product_show_in_pos', $foosales_product_show_in_pos );
    22042311
    22052312            $foosales_product_pin_in_pos = isset( $_POST['foosales_product_pin_in_pos'] ) ? 'yes' : 'no';
    22062313
    2207             update_post_meta( $post_id, 'foosales_product_pin_in_pos', $foosales_product_pin_in_pos );
     2314            $wc_product->update_meta_data( 'foosales_product_pin_in_pos', $foosales_product_pin_in_pos );
    22082315
    22092316            if ( isset( $_POST['WooCommerceEventsPOSAttendeeDetails'] ) ) {
    22102317
    22112318                $fooevents_pos_attendee_details = sanitize_text_field( wp_unslash( $_POST['WooCommerceEventsPOSAttendeeDetails'] ) );
    2212                 update_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeDetails', $fooevents_pos_attendee_details );
     2319                $wc_product->update_meta_data( 'WooCommerceEventsPOSAttendeeDetails', $fooevents_pos_attendee_details );
    22132320
    22142321            }
     
    22172324
    22182325                $fooevents_pos_attendee_email = sanitize_text_field( wp_unslash( $_POST['WooCommerceEventsPOSAttendeeEmail'] ) );
    2219                 update_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeEmail', $fooevents_pos_attendee_email );
     2326                $wc_product->update_meta_data( 'WooCommerceEventsPOSAttendeeEmail', $fooevents_pos_attendee_email );
    22202327
    22212328            }
     
    22242331
    22252332                $fooevents_pos_attendee_telephone = sanitize_text_field( wp_unslash( $_POST['WooCommerceEventsPOSAttendeeTelephone'] ) );
    2226                 update_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeTelephone', $fooevents_pos_attendee_telephone );
     2333                $wc_product->update_meta_data( 'WooCommerceEventsPOSAttendeeTelephone', $fooevents_pos_attendee_telephone );
    22272334
    22282335            }
     
    22312338
    22322339                $fooevents_pos_attendee_company = sanitize_text_field( wp_unslash( $_POST['WooCommerceEventsPOSAttendeeCompany'] ) );
    2233                 update_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeCompany', $fooevents_pos_attendee_company );
     2340                $wc_product->update_meta_data( 'WooCommerceEventsPOSAttendeeCompany', $fooevents_pos_attendee_company );
    22342341
    22352342            }
     
    22382345
    22392346                $fooevents_pos_attendee_designation = sanitize_text_field( wp_unslash( $_POST['WooCommerceEventsPOSAttendeeDesignation'] ) );
    2240                 update_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeDesignation', $fooevents_pos_attendee_designation );
    2241 
    2242             }
     2347                $wc_product->update_meta_data( 'WooCommerceEventsPOSAttendeeDesignation', $fooevents_pos_attendee_designation );
     2348
     2349            }
     2350
     2351            $wc_product->save();
    22432352        }
    22442353
     
    22512360     * @param string  $loop The WordPress loop.
    22522361     * @param array   $variation_data The variation data.
    2253      * @param WP_Post $post The post object.
    2254      */
    2255     public function fsfwc_add_variation_options( $loop, $variation_data, $post ) {
     2362     * @param WP_Post $variation The variation post object.
     2363     */
     2364    public function fsfwc_add_variation_options( $loop, $variation_data, $variation ) {
    22562365
    22572366        // Show variation in POS.
    2258         $foosales_variation_show_in_pos = get_post_meta( $post->ID, 'foosales_variation_show_in_pos', true );
     2367        $foosales_variation_show_in_pos = get_post_meta( $variation->ID, 'foosales_variation_show_in_pos', true );
    22592368
    22602369        woocommerce_wp_checkbox(
     
    22692378        );
    22702379
    2271         wp_nonce_field( '_foosales_add_variation_options_' . $post->ID, '_foosales_add_variation_options_nonce_' . $post->ID );
     2380        wp_nonce_field( '_foosales_add_variation_options_' . $variation->ID, '_foosales_add_variation_options_nonce_' . $variation->ID );
    22722381    }
    22732382
     
    22852394            $foosales_variation_show_in_pos = isset( $_POST['foosales_variation_show_in_pos'][ $index ] ) ? 'yes' : 'no';
    22862395
    2287             update_post_meta( $variation_id, 'foosales_variation_show_in_pos', $foosales_variation_show_in_pos );
     2396            $wc_product_variation = wc_get_product( $variation_id );
     2397
     2398            $wc_product_variation->update_meta_data( 'foosales_variation_show_in_pos', $foosales_variation_show_in_pos );
     2399            $wc_product_variation->save();
    22882400        }
    22892401
  • foosales/trunk/default.po

    r2919862 r2926151  
    22msgstr ""
    33"Project-Id-Version: \n"
    4 "POT-Creation-Date: 2023-05-31 13:06-0700\n"
    5 "PO-Revision-Date: 2023-05-31 13:06-0700\n"
     4"POT-Creation-Date: 2023-06-14 11:59-0700\n"
     5"PO-Revision-Date: 2023-06-14 11:59-0700\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    102102#: helpers/foosales-phrases-helper.php:30
    103103msgid ""
    104 "We hope that you enjoyed your 30-day free trial. Please purchase a FooSales "
     104"We hope that you enjoyed your 7-day free trial. Please purchase a FooSales "
    105105"plan to continue using the FooSales apps."
    106106msgstr ""
     
    212212"Your store needs to be linked to a FooSales account in order to use the "
    213213"FooSales apps. Click the button below to sign-up for a FooSales account and "
    214 "start your 30-day free trial today!"
     214"start your 7-day free trial today!"
    215215msgstr ""
    216216
  • foosales/trunk/foosales.php

    r2919862 r2926151  
    33 * Plugin Name: FooSales — Point of Sale (POS) for WooCommerce
    44 * Description: FooSales POS is a point of sale (POS) system for WooCommerce that turns any computer, iPad or Android tablet into a physical retail platform. FooSales POS apps connect to your WooCommerce store using the FooSales POS plugin and enable you to sell your products in person while accepting payments using Square™ and Stripe™ or manually using any third-party card reader.
    5  * Version: 1.33.0
     5 * Version: 1.34.0
    66 * Author: FooSales
    77 * Author URI: https://www.foosales.com
     
    1212 *
    1313 * WC requires at least: 5.0.0
    14  * WC tested up to: 7.7.1
     14 * WC tested up to: 7.8.0
    1515 *
    1616 * Copyright: © 2009-2023 FooSales.
     
    2020 * @package foosales
    2121 */
     22
     23add_action(
     24    'before_woocommerce_init',
     25    function() {
     26        if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     27            \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     28        }
     29    }
     30);
    2231
    2332// Define global variables.
  • foosales/trunk/helpers/foosales-api-helper.php

    r2919862 r2926151  
    88 */
    99
     10use Automattic\WooCommerce\Utilities\OrderUtil;
     11
    1012/**
    1113 * Get all tax rates.
    1214 *
    1315 * @since 1.14.0
     16 *
     17 * @return array
    1418 */
    1519function fsfwc_do_get_all_tax_rates() {
     
    5458 * @since 1.18.0
    5559 * @param bool $admin Specify whether the returned result will only be used for display purposes in the admin area.
     60 *
     61 * @return array
    5662 */
    5763function fsfwc_do_get_all_payment_methods( $admin = false ) {
     
    9096 * @since 1.20.0
    9197 * @param string $payment_method_key The FooSales payment method key for which to return the payment method domain.
     98 *
     99 * @return string
    92100 */
    93101function fsfwc_get_wc_payment_method_from_foosales_key( $payment_method_key ) {
     
    113121 *
    114122 * @since 1.14.0
    115  * @param WC_Product $product The WooCommerce product.
     123 * @param WC_Product $wc_product The WooCommerce product.
    116124 * @param array      $args Additional arguments.
    117125 * @param string     $type The type of product.
    118  */
    119 function fsfwc_get_price_excluding_tax( $product, $args = array(), $type = '' ) {
    120     $price = $product->get_price();
     126 *
     127 * @return string
     128 */
     129function fsfwc_get_price_excluding_tax( $wc_product, $args = array(), $type = '' ) {
     130    $price = $wc_product->get_price();
    121131
    122132    if ( 'regular' === $type ) {
    123         $price = $product->get_regular_price();
     133        $price = $wc_product->get_regular_price();
    124134    } elseif ( 'sale' === $type ) {
    125         $price = $product->get_sale_price();
     135        $price = $wc_product->get_sale_price();
    126136    }
    127137
     
    140150        return '';
    141151    } elseif ( empty( $qty ) ) {
    142         return 0.0;
     152        return '0.0';
    143153    }
    144154
    145155    $line_price = $price * $qty;
    146156
    147     if ( $product->is_taxable() && wc_prices_include_tax() ) {
    148         $tax_rates      = WC_Tax::get_rates( $product->get_tax_class() );
    149         $base_tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
     157    if ( $wc_product->is_taxable() && wc_prices_include_tax() ) {
     158        $tax_rates      = WC_Tax::get_rates( $wc_product->get_tax_class() );
     159        $base_tax_rates = WC_Tax::get_base_tax_rates( $wc_product->get_tax_class( 'unfiltered' ) );
    150160        $remove_taxes   = apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ? WC_Tax::calc_tax( $line_price, $base_tax_rates, true ) : WC_Tax::calc_tax( $line_price, $tax_rates, true );
    151161        $return_price   = $line_price - array_sum( $remove_taxes ); // Unrounded since we're dealing with tax inclusive prices. Matches logic in cart-totals class. @see adjust_non_base_location_price.
     
    154164    }
    155165
    156     return apply_filters( 'woocommerce_get_price_excluding_tax', $return_price, $qty, $product );
     166    return apply_filters( 'woocommerce_get_price_excluding_tax', $return_price, $qty, $wc_product );
    157167}
    158168
     
    161171 *
    162172 * @since 1.14.0
    163  * @param WC_Product $product The WooCommerce product.
     173 * @param WC_Product $wc_product The WooCommerce product.
    164174 * @param string     $type The type of product.
    165  */
    166 function fsfwc_get_price_including_tax( $product, $type = '' ) {
    167     $price = $product->get_price();
     175 *
     176 * @return string
     177 */
     178function fsfwc_get_price_including_tax( $wc_product, $type = '' ) {
     179    $price = $wc_product->get_price();
    168180
    169181    if ( 'regular' === $type ) {
    170         $price = $product->get_regular_price();
     182        $price = $wc_product->get_regular_price();
    171183    } elseif ( 'sale' === $type ) {
    172         $price = $product->get_sale_price();
     184        $price = $wc_product->get_sale_price();
    173185    }
    174186
     
    178190        return '';
    179191    } elseif ( empty( $qty ) ) {
    180         return 0.0;
     192        return '0.0';
    181193    }
    182194
     
    184196    $return_price = $line_price;
    185197
    186     if ( $product->is_taxable() ) {
     198    if ( $wc_product->is_taxable() ) {
    187199        if ( ! wc_prices_include_tax() ) {
    188             $tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
     200            $tax_rates = WC_Tax::get_rates( $wc_product->get_tax_class() );
    189201            $taxes     = WC_Tax::calc_tax( $line_price, $tax_rates, false );
    190202
     
    193205            $return_price = $line_price + $taxes_total;
    194206        } else {
    195             $tax_rates      = WC_Tax::get_rates( $product->get_tax_class() );
    196             $base_tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
     207            $tax_rates      = WC_Tax::get_rates( $wc_product->get_tax_class() );
     208            $base_tax_rates = WC_Tax::get_base_tax_rates( $wc_product->get_tax_class( 'unfiltered' ) );
    197209
    198210            /**
     
    223235        }
    224236    }
    225     return apply_filters( 'woocommerce_get_price_including_tax', $return_price, $qty, $product );
     237
     238    return apply_filters( 'woocommerce_get_price_including_tax', $return_price, $qty, $wc_product );
    226239}
    227240
     
    231244 * @since 1.14.0
    232245 * @param string $payment_method_key The key of the payment method.
     246 *
     247 * @return string
    233248 */
    234249function fsfwc_get_payment_method_from_key( $payment_method_key = '' ) {
     
    256271 * @since 1.14.0
    257272 * @param string $payment_method The payment method.
     273 *
     274 * @return string
    258275 */
    259276function fsfwc_get_payment_method_key_from_value( $payment_method = '' ) {
     
    309326 * @param array $a The one category object to compare.
    310327 * @param array $b The other category object to compare.
     328 *
     329 * @return bool
    311330 */
    312331function fsfwc_do_compare_categories( $a, $b ) {
     
    318337 *
    319338 * @since 1.14.0
     339 *
     340 * @return array
    320341 */
    321342function fsfwc_do_get_all_product_categories() {
     
    387408 * @param int    $offset The offset from where to start adding fetched product images.
    388409 * @param string $platform The platform that is currently performing this request.
     410 *
     411 * @return array
    389412 */
    390413function fsfwc_do_get_all_product_images( $offset = 0, $platform = 'any' ) {
     
    455478    $product_image_data['product_images'] = array();
    456479
    457     foreach ( $query->posts as $post_id ) {
     480    foreach ( $query->posts as $product_id ) {
    458481        $product_image = preg_replace_callback(
    459482            '/[^\x20-\x7f]/',
     
    461484                return rawurlencode( $match[0] );
    462485            },
    463             (string) get_the_post_thumbnail_url( $post_id, 'thumbnail' )
     486            (string) get_the_post_thumbnail_url( $product_id, 'thumbnail' )
    464487        );
    465488
    466489        $product_image_data['product_images'][] = array(
    467             'pid' => (string) $post_id,
     490            'pid' => (string) $product_id,
    468491            'pi'  => $product_image,
    469492        );
     
    485508 * @param int    $offset The offset from where to start adding fetched products.
    486509 * @param string $platform The platform that is currently performing this request.
     510 *
     511 * @return array
    487512 */
    488513function fsfwc_do_get_all_products( $offset = 0, $platform = 'any' ) {
     
    563588    $shop_tax = ( 'yes' === (string) get_option( 'woocommerce_calc_taxes', '' ) ) ? (string) get_option( 'woocommerce_tax_display_shop', '' ) : 'incl';
    564589
    565     foreach ( $query->posts as $post_id ) {
    566 
    567         $products[] = fsfwc_do_get_single_product( $post_id, $wc_tax, $cat_names, $shop_tax, $platform );
     590    foreach ( $query->posts as $product_id ) {
     591
     592        $products[] = fsfwc_do_get_single_product( $product_id, $wc_tax, $cat_names, $shop_tax, $platform );
    568593
    569594    }
     
    585610 *
    586611 * @since 1.14.0
    587  * @param int    $post_id The WordPress post ID.
     612 * @param int    $product_id The WooCommerce product ID.
    588613 * @param WC_Tax $wc_tax The WooCommerce tax object.
    589614 * @param array  $cat_names An array of category names to add to the product if it matches.
    590615 * @param string $shop_tax Whether the shop tax is incl or excl.
    591616 * @param string $platform The platform that is currently performing this request.
    592  */
    593 function fsfwc_do_get_single_product( $post_id, &$wc_tax, &$cat_names, $shop_tax = 'incl', $platform = 'any' ) {
     617 *
     618 * @return array
     619 */
     620function fsfwc_do_get_single_product( $product_id, &$wc_tax, &$cat_names, $shop_tax = 'incl', $platform = 'any' ) {
    594621
    595622    global $foosales_products_default_minimum_cart_quantity;
     
    599626    $product_data = array();
    600627
    601     $wc_product = wc_get_product( $post_id );
     628    $wc_product = wc_get_product( $product_id );
    602629
    603630    $product_data['modified'] = (string) gmdate( 'Y-m-d H:i:s+00:00', strtotime( $wc_product->get_date_modified() ) );
    604631
    605     $product_data['pid']  = (string) $post_id;
    606     $product_data['ppdt'] = (string) get_post_timestamp( $post_id );
    607     $product_data['sip']  = 'no' === get_post_meta( $post_id, 'foosales_product_show_in_pos', true ) ? '0' : '1';
    608     $product_data['pip']  = 'yes' === get_post_meta( $post_id, 'foosales_product_pin_in_pos', true ) ? '1' : '0';
    609 
    610     $product_title = (string) htmlspecialchars_decode( get_post_field( 'post_title', $post_id ) );
     632    $product_data['pid']  = (string) $product_id;
     633    $product_data['ppdt'] = (string) strtotime( $wc_product->get_date_created() );
     634    $product_data['sip']  = 'no' === $wc_product->get_meta( 'foosales_product_show_in_pos', true ) ? '0' : '1';
     635    $product_data['pip']  = 'yes' === $wc_product->get_meta( 'foosales_product_pin_in_pos', true ) ? '1' : '0';
     636
     637    $product_title = (string) htmlspecialchars_decode( $wc_product->get_title() );
    611638
    612639    $product_data['pt'] = $product_title;
     
    633660
    634661    if ( $use_decimal_quantities ) {
    635         $foosales_product_minimum_cart_quantity               = get_post_meta( $post_id, 'foosales_product_minimum_cart_quantity', true );
    636         $foosales_product_cart_quantity_step                  = get_post_meta( $post_id, 'foosales_product_cart_quantity_step', true );
    637         $foosales_product_override_default_cart_quantity_unit = get_post_meta( $post_id, 'foosales_product_override_default_cart_quantity_unit', true );
    638         $foosales_product_cart_quantity_unit                  = get_post_meta( $post_id, 'foosales_product_cart_quantity_unit', true );
     662        $foosales_product_minimum_cart_quantity               = $wc_product->get_meta( 'foosales_product_minimum_cart_quantity', true );
     663        $foosales_product_cart_quantity_step                  = $wc_product->get_meta( 'foosales_product_cart_quantity_step', true );
     664        $foosales_product_override_default_cart_quantity_unit = $wc_product->get_meta( 'foosales_product_override_default_cart_quantity_unit', true );
     665        $foosales_product_cart_quantity_unit                  = $wc_product->get_meta( 'foosales_product_cart_quantity_unit', true );
    639666
    640667        $product_data['mcq'] = (string) ( '' !== $foosales_product_minimum_cart_quantity ? $foosales_product_minimum_cart_quantity : $foosales_products_default_minimum_cart_quantity );
     
    679706
    680707            $product_variation['pvid'] = (string) $variation_id;
    681             $product_variation['sip']  = 'no' === get_post_meta( $variation_id, 'foosales_variation_show_in_pos', true ) ? '0' : '1';
     708            $product_variation['sip']  = 'no' === $wc_product_variation->get_meta( 'foosales_variation_show_in_pos', true ) ? '0' : '1';
    682709            $product_variation['pt']   = $product_title;
    683710
     
    781808    $product_data['pv'] = $product_variations;
    782809
    783     $wc_product = null;
    784 
    785     unset( $wc_product );
    786 
    787810    $product_categories = array();
    788811
    789     $cat_ids = wp_get_post_terms( $post_id, 'product_cat', array( 'fields' => 'ids' ) );
     812    $cat_ids = $wc_product->get_category_ids();
    790813
    791814    $last_cat_id = end( $cat_ids );
     
    824847    }
    825848
    826     if ( 'Event' === get_post_meta( $post_id, 'WooCommerceEventsEvent', true ) && ( is_plugin_active( 'fooevents/fooevents.php' ) || is_plugin_active_for_network( 'fooevents/fooevents.php' ) ) ) {
     849    if ( 'Event' === $wc_product->get_meta( 'WooCommerceEventsEvent', true ) && ( is_plugin_active( 'fooevents/fooevents.php' ) || is_plugin_active_for_network( 'fooevents/fooevents.php' ) ) ) {
    827850
    828851        $event = array();
    829852
    830         $event['et'] = get_post_meta( $post_id, 'WooCommerceEventsType', true );
    831 
    832         $fooevents_pos_attendee_details     = get_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeDetails', true );
    833         $fooevents_pos_attendee_email       = get_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeEmail', true );
    834         $fooevents_pos_attendee_telephone   = get_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeTelephone', true );
    835         $fooevents_pos_attendee_company     = get_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeCompany', true );
    836         $fooevents_pos_attendee_designation = get_post_meta( $post_id, 'WooCommerceEventsPOSAttendeeDesignation', true );
    837 
    838         $event['cad']   = '' === $fooevents_pos_attendee_details ? ( get_post_meta( $post_id, 'WooCommerceEventsCaptureAttendeeDetails', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_details ? '1' : '0' );
    839         $event['cae']   = '' === $fooevents_pos_attendee_email ? ( ( get_post_meta( $post_id, 'WooCommerceEventsCaptureAttendeeDetails', true ) === 'on' && get_post_meta( $post_id, 'WooCommerceEventsCaptureAttendeeEmail', true ) === '' ) || get_post_meta( $post_id, 'WooCommerceEventsCaptureAttendeeEmail', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_email ? '1' : '0' );
    840         $event['cat']   = '' === $fooevents_pos_attendee_telephone ? ( get_post_meta( $post_id, 'WooCommerceEventsCaptureAttendeeTelephone', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_telephone ? '1' : '0' );
    841         $event['cac']   = '' === $fooevents_pos_attendee_company ? ( get_post_meta( $post_id, 'WooCommerceEventsCaptureAttendeeCompany', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_company ? '1' : '0' );
    842         $event['cades'] = '' === $fooevents_pos_attendee_designation ? ( get_post_meta( $post_id, 'WooCommerceEventsCaptureAttendeeDesignation', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_designation ? '1' : '0' );
     853        $event['et'] = $wc_product->get_meta( 'WooCommerceEventsType', true );
     854
     855        $fooevents_pos_attendee_details     = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeDetails', true );
     856        $fooevents_pos_attendee_email       = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeEmail', true );
     857        $fooevents_pos_attendee_telephone   = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeTelephone', true );
     858        $fooevents_pos_attendee_company     = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeCompany', true );
     859        $fooevents_pos_attendee_designation = $wc_product->get_meta( 'WooCommerceEventsPOSAttendeeDesignation', true );
     860
     861        $event['cad']   = '' === $fooevents_pos_attendee_details ? ( $wc_product->get_meta( 'WooCommerceEventsCaptureAttendeeDetails', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_details ? '1' : '0' );
     862        $event['cae']   = '' === $fooevents_pos_attendee_email ? ( ( $wc_product->get_meta( 'WooCommerceEventsCaptureAttendeeDetails', true ) === 'on' && $wc_product->get_meta( 'WooCommerceEventsCaptureAttendeeEmail', true ) === '' ) || $wc_product->get_meta( 'WooCommerceEventsCaptureAttendeeEmail', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_email ? '1' : '0' );
     863        $event['cat']   = '' === $fooevents_pos_attendee_telephone ? ( $wc_product->get_meta( 'WooCommerceEventsCaptureAttendeeTelephone', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_telephone ? '1' : '0' );
     864        $event['cac']   = '' === $fooevents_pos_attendee_company ? ( $wc_product->get_meta( 'WooCommerceEventsCaptureAttendeeCompany', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_company ? '1' : '0' );
     865        $event['cades'] = '' === $fooevents_pos_attendee_designation ? ( $wc_product->get_meta( 'WooCommerceEventsCaptureAttendeeDesignation', true ) === 'on' ? '1' : '0' ) : ( 'hide' !== $fooevents_pos_attendee_designation ? '1' : '0' );
    843866
    844867        $event['rad']   = '' === $fooevents_pos_attendee_details ? $event['cad'] : ( 'required' === $fooevents_pos_attendee_details ? '1' : '0' );
     
    853876            $fooevents_custom_attendee_fields = new Fooevents_Custom_Attendee_Fields();
    854877
    855             $fooevents_custom_attendee_fields_options_serialized = get_post_meta( $post_id, 'fooevents_custom_attendee_fields_options_serialized', true );
     878            $fooevents_custom_attendee_fields_options_serialized = $wc_product->get_meta( 'fooevents_custom_attendee_fields_options_serialized', true );
    856879            $fooevents_custom_attendee_fields_options            = json_decode( $fooevents_custom_attendee_fields_options_serialized, true );
    857880            $fooevents_custom_attendee_fields_options            = $fooevents_custom_attendee_fields->correct_legacy_options( $fooevents_custom_attendee_fields_options );
     
    873896        $event['caf'] = $custom_fields;
    874897
    875         $event['eoas']   = get_post_meta( $post_id, 'WooCommerceEventsAttendeeOverride', true );
    876         $event['eoap']   = get_post_meta( $post_id, 'WooCommerceEventsAttendeeOverridePlural', true );
    877         $event['eots']   = get_post_meta( $post_id, 'WooCommerceEventsTicketOverride', true );
    878         $event['eotp']   = get_post_meta( $post_id, 'WooCommerceEventsTicketOverridePlural', true );
    879         $event['eods']   = get_post_meta( $post_id, 'WooCommerceEventsDayOverride', true );
    880         $event['eodp']   = get_post_meta( $post_id, 'WooCommerceEventsDayOverridePlural', true );
    881         $event['eobss']  = get_post_meta( $post_id, 'WooCommerceEventsBookingsSlotOverride', true );
    882         $event['eobsp']  = get_post_meta( $post_id, 'WooCommerceEventsBookingsSlotOverridePlural', true );
    883         $event['eobds']  = get_post_meta( $post_id, 'WooCommerceEventsBookingsDateOverride', true );
    884         $event['eobdp']  = get_post_meta( $post_id, 'WooCommerceEventsBookingsDateOverridePlural', true );
    885         $event['eobbds'] = get_post_meta( $post_id, 'WooCommerceEventsBookingsBookingDetailsOverride', true );
    886         $event['eobbdp'] = get_post_meta( $post_id, 'WooCommerceEventsBookingsBookingDetailsOverridePlural', true );
    887         $event['eosr']   = get_post_meta( $post_id, 'WooCommerceEventsSeatingRowOverride', true );
    888         $event['eosrp']  = get_post_meta( $post_id, 'WooCommerceEventsSeatingRowOverridePlural', true );
    889         $event['eoss']   = get_post_meta( $post_id, 'WooCommerceEventsSeatingSeatOverride', true );
    890         $event['eossp']  = get_post_meta( $post_id, 'WooCommerceEventsSeatingSeatOverridePlural', true );
    891         $event['eossc']  = get_post_meta( $post_id, 'WooCommerceEventsSeatingSeatingChartOverride', true );
    892         $event['eosscp'] = get_post_meta( $post_id, 'WooCommerceEventsSeatingSeatingChartOverridePlural', true );
    893         $event['eosf']   = get_post_meta( $post_id, 'WooCommerceEventsSeatingFrontOverride', true );
    894         $event['eosfp']  = get_post_meta( $post_id, 'WooCommerceEventsSeatingFrontOverridePlural', true );
    895 
    896         $event['eue'] = 'on' === get_post_meta( $post_id, 'WooCommerceEventsUniqueEmail', true ) ? '1' : '0';
     898        $event['eoas']   = $wc_product->get_meta( 'WooCommerceEventsAttendeeOverride', true );
     899        $event['eoap']   = $wc_product->get_meta( 'WooCommerceEventsAttendeeOverridePlural', true );
     900        $event['eots']   = $wc_product->get_meta( 'WooCommerceEventsTicketOverride', true );
     901        $event['eotp']   = $wc_product->get_meta( 'WooCommerceEventsTicketOverridePlural', true );
     902        $event['eods']   = $wc_product->get_meta( 'WooCommerceEventsDayOverride', true );
     903        $event['eodp']   = $wc_product->get_meta( 'WooCommerceEventsDayOverridePlural', true );
     904        $event['eobss']  = $wc_product->get_meta( 'WooCommerceEventsBookingsSlotOverride', true );
     905        $event['eobsp']  = $wc_product->get_meta( 'WooCommerceEventsBookingsSlotOverridePlural', true );
     906        $event['eobds']  = $wc_product->get_meta( 'WooCommerceEventsBookingsDateOverride', true );
     907        $event['eobdp']  = $wc_product->get_meta( 'WooCommerceEventsBookingsDateOverridePlural', true );
     908        $event['eobbds'] = $wc_product->get_meta( 'WooCommerceEventsBookingsBookingDetailsOverride', true );
     909        $event['eobbdp'] = $wc_product->get_meta( 'WooCommerceEventsBookingsBookingDetailsOverridePlural', true );
     910        $event['eosr']   = $wc_product->get_meta( 'WooCommerceEventsSeatingRowOverride', true );
     911        $event['eosrp']  = $wc_product->get_meta( 'WooCommerceEventsSeatingRowOverridePlural', true );
     912        $event['eoss']   = $wc_product->get_meta( 'WooCommerceEventsSeatingSeatOverride', true );
     913        $event['eossp']  = $wc_product->get_meta( 'WooCommerceEventsSeatingSeatOverridePlural', true );
     914        $event['eossc']  = $wc_product->get_meta( 'WooCommerceEventsSeatingSeatingChartOverride', true );
     915        $event['eosscp'] = $wc_product->get_meta( 'WooCommerceEventsSeatingSeatingChartOverridePlural', true );
     916        $event['eosf']   = $wc_product->get_meta( 'WooCommerceEventsSeatingFrontOverride', true );
     917        $event['eosfp']  = $wc_product->get_meta( 'WooCommerceEventsSeatingFrontOverridePlural', true );
     918
     919        $event['eue'] = 'on' === $wc_product->get_meta( 'WooCommerceEventsUniqueEmail', true ) ? '1' : '0';
    897920
    898921        $event['info'] = array();
    899922
    900         $event_info_orig = get_fooevents_event_info( get_post( $post_id ) );
     923        $event_info_orig = get_fooevents_event_info( get_post( $product_id ) );
    901924
    902925        $exclude_array = array(
     
    957980 * @param int    $offset The offset from where to start adding fetched orders.
    958981 * @param string $platform The platform that is currently performing this request.
     982 *
     983 * @return array
    959984 */
    960985function fsfwc_do_get_all_orders( $offset = 0, $platform = 'any' ) {
     
    9761001
    9771002    $args = array(
    978         'posts_per_page' => -1,
    979         'post_type'      => 'shop_order',
    980         'post_status'    => $order_load_statuses,
    981         'fields'         => 'ids',
    982         'no_found_rows'  => true,
    983         'orderby'        => 'id',
    984         'order'          => 'DESC',
     1003        'limit'   => -1,
     1004        'type'    => 'shop_order',
     1005        'status'  => $order_load_statuses,
     1006        'return'  => 'ids',
     1007        'orderby' => 'ID',
    9851008    );
    9861009
    987     $query = new WP_Query( $args );
     1010    $order_ids = wc_get_orders( $args );
    9881011
    9891012    $args = null;
     
    9911014    unset( $args );
    9921015
    993     $total_orders = $query->post_count;
     1016    $total_orders = count( $order_ids );
    9941017
    9951018    $orders_to_load = (int) get_option( 'globalFooSalesOrdersToLoad', '100' );
     
    10141037    $order_count = 0;
    10151038
    1016     foreach ( $query->posts as $post_id ) {
     1039    foreach ( $order_ids as $order_id ) {
    10171040
    10181041        $order_count++;
     
    10221045        }
    10231046
    1024         $wc_order = wc_get_order( $post_id );
     1047        $wc_order = wc_get_order( $order_id );
    10251048
    10261049        $order_data['orders'][] = fsfwc_do_get_single_order( $wc_order, $platform );
     
    10341057        }
    10351058    }
    1036 
    1037     $query = null;
    1038 
    1039     unset( $query );
    10401059
    10411060    return $order_data;
     
    10491068 * @param int    $offset The offset from where to start adding fetched customers.
    10501069 * @param string $platform The platform that is currently performing this request.
     1070 *
     1071 * @return array
    10511072 */
    10521073function fsfwc_do_get_all_customers( $offset = 0, $platform = 'any' ) {
     
    11711192 * @param string  $chunk The specific chunk of data to fetch.
    11721193 * @param string  $platform The platform that is currently performing this request.
     1194 *
     1195 * @return array
    11731196 */
    11741197function fsfwc_fetch_chunk( $user, $chunk, $platform = 'any' ) {
     
    14311454 * @param array  $product_params Key/value pairs of product data to update.
    14321455 * @param string $platform The platform that is currently performing this request.
     1456 *
     1457 * @return array
    14331458 */
    14341459function fsfwc_do_update_product( $product_params, $platform = 'any' ) {
     
    14401465
    14411466        if ( null === $wc_product || false === $wc_product ) {
    1442             return false;
     1467            return array();
    14431468        }
    14441469
     
    14891514        ob_end_clean();
    14901515    } catch ( Exception $e ) {
    1491         return false;
     1516        return array();
    14921517    }
    14931518
     
    15181543 * @param array  $order_data Key/value pairs containing order data needed to create a new WooCommerce order.
    15191544 * @param string $platform The platform that is currently performing this request.
     1545 *
     1546 * @return WC_Order
    15201547 */
    15211548function fsfwc_do_create_update_order( $order_data, $platform = 'any' ) {
     
    15681595    $existing_order_id           = $order_data[13];
    15691596
    1570     $order = ! empty( $existing_order_id ) ? wc_get_order( $existing_order_id ) : wc_create_order();
     1597    $wc_order = ! empty( $existing_order_id ) ? wc_get_order( $existing_order_id ) : wc_create_order();
    15711598
    15721599    $updated_values = array();
    15731600
    1574     update_post_meta( $order->get_id(), '_foosales_order_source', 'foosales_app' );
     1601    $wc_order->update_meta_data( '_foosales_order_source', 'foosales_app' );
    15751602
    15761603    // Order date.
    15771604    if ( ! empty( $order_date ) ) {
    1578         $order->set_date_created( (int) $order_date );
    1579 
    1580         wp_update_post(
    1581             array(
    1582                 'ID'        => $order->get_id(),
    1583                 'post_date' => gmdate( 'Y-m-d H:i:s+00:00', (int) $order_date ),
    1584             )
    1585         );
     1605        $wc_order->set_date_created( (int) $order_date );
    15861606
    15871607        $updated_values[] = $foosales_phrases['text_order_update_date'];
     
    15901610    // Payment method.
    15911611    if ( ! empty( $payment_method_key ) ) {
    1592         $changed_foosales_payment_method = update_post_meta( $order->get_id(), '_foosales_payment_method', $payment_method_key );
    1593 
    1594         $order->set_payment_method( fsfwc_get_wc_payment_method_from_foosales_key( $payment_method_key ) );
     1612        $changed_foosales_payment_method = $wc_order->update_meta_data( '_foosales_payment_method', $payment_method_key );
     1613
     1614        $wc_order->set_payment_method( fsfwc_get_wc_payment_method_from_foosales_key( $payment_method_key ) );
    15951615
    15961616        $payment_method = fsfwc_get_payment_method_from_key( $payment_method_key );
    15971617
    1598         $order->set_payment_method_title( $payment_method );
    1599 
    1600         update_post_meta( $order->get_id(), $foosales_phrases['meta_key_order_payment_method'], $payment_method );
     1618        $wc_order->set_payment_method_title( $payment_method );
     1619
     1620        $wc_order->update_meta_data( $foosales_phrases['meta_key_order_payment_method'], $payment_method );
    16011621
    16021622        if ( false !== $changed_foosales_payment_method ) {
     
    16171637    ) ) {
    16181638
    1619         $changed_foosales_square_order_id = update_post_meta( $order->get_id(), '_foosales_square_order_id', $square_order_id );
     1639        $changed_foosales_square_order_id = $wc_order->update_meta_data( '_foosales_square_order_id', $square_order_id );
    16201640
    16211641        $square_order_result = fsfwc_get_square_order( $square_order_id );
     
    16271647            if ( ! empty( $square_order['tenders'] ) && count( $square_order['tenders'] ) === 1 ) {
    16281648
    1629                 update_post_meta( $order->get_id(), '_foosales_square_order_auto_refund', '1' );
     1649                $changed_foosales_square_order_id = $wc_order->update_meta_data( '_foosales_square_order_auto_refund', '1' );
    16301650
    16311651            }
     
    16491669        true
    16501670    ) ) {
    1651         $changed_foosales_stripe_payment_id = update_post_meta( $order->get_id(), '_foosales_stripe_payment_id', $stripe_payment_id );
     1671        $changed_foosales_stripe_payment_id = $wc_order->update_meta_data( '_foosales_stripe_payment_id', $stripe_payment_id );
    16521672
    16531673        if ( false !== $changed_foosales_stripe_payment_id ) {
     
    16581678    // User ID.
    16591679    if ( ! empty( $user_id ) && (int) $user_id > 0 ) {
    1660         $changed_foosales_user_id = update_post_meta( $order->get_id(), '_foosales_user_id', $user_id );
     1680        $changed_foosales_user_id = $wc_order->update_meta_data( '_foosales_user_id', $user_id );
    16611681
    16621682        if ( false !== $changed_foosales_user_id ) {
     
    16821702    if ( ! empty( $existing_order_id ) && ! empty( $order_items ) ) {
    16831703        // First remove all items before adding new items.
    1684         $wc_order_items = $order->get_items();
     1704        $wc_order_items = $wc_order->get_items();
    16851705
    16861706        foreach ( $wc_order_items as $wc_order_item ) {
     
    16911711            }
    16921712
    1693             $wc_product = wc_get_product( $product_variation_id );
    1694 
    1695             if ( false !== $wc_product && $wc_product->get_manage_stock() ) {
    1696                 wc_update_product_stock( $wc_product, $wc_order_item->get_quantity(), 'increase' );
    1697             }
    1698 
    1699             $wc_product = null;
    1700 
    1701             unset( $wc_product );
    1702 
    1703             $order->remove_item( $wc_order_item->get_id() );
     1713            $wc_product_variation = wc_get_product( $product_variation_id );
     1714
     1715            if ( false !== $wc_product_variation && $wc_product_variation->get_manage_stock() ) {
     1716                wc_update_product_stock( $wc_product_variation, $wc_order_item->get_quantity(), 'increase' );
     1717            }
     1718
     1719            $wc_product_variation = null;
     1720
     1721            unset( $wc_product_variation );
     1722
     1723            $wc_order->remove_item( $wc_order_item->get_id() );
    17041724
    17051725            if ( false === in_array( $product_variation_id, $updated_product_ids, true ) ) {
     
    17131733    }
    17141734
    1715     $order->{'product_updates'} = wp_json_encode( $product_updates );
     1735    $wc_order->{'product_updates'} = wp_json_encode( $product_updates );
    17161736
    17171737    foreach ( $order_items as $order_item ) {
     
    17321752            }
    17331753
    1734             if ( 'Event' === get_post_meta( $event_product_id, 'WooCommerceEventsEvent', true ) ) {
     1754            $event_product = wc_get_product( $event_product_id );
     1755
     1756            if ( 'Event' === $event_product->get_meta( 'WooCommerceEventsEvent', true ) ) {
    17351757                $order_has_event = true;
    17361758
    1737                 $event_type = get_post_meta( $event_product_id, 'WooCommerceEventsType', true );
     1759                $event_type = $event_product->get_meta( 'WooCommerceEventsType', true );
    17381760
    17391761                if ( ! isset( $analytics_event_info[ $event_type . '_event_tickets' ] ) ) {
     
    17621784        }
    17631785
    1764         $order->add_product( $wc_product, $order_item['oiq'], $product_args );
     1786        $wc_order->add_product( $wc_product, $order_item['oiq'], $product_args );
    17651787
    17661788        if ( ! empty( $existing_order_id ) ) {
     
    18261848        }
    18271849
    1828         $changed_foosales_customer_id = (int) $order->get_customer_id() !== (int) $order_customer['cid'];
    1829 
    1830         $order->set_customer_id( (int) $order_customer['cid'] );
     1850        $changed_foosales_customer_id = (int) $wc_order->get_customer_id() !== (int) $order_customer['cid'];
     1851
     1852        $wc_order->set_customer_id( (int) $order_customer['cid'] );
    18311853
    18321854        if ( trim( $order_customer['cbfn'] ) !== '' ) {
    1833             $order->set_billing_first_name( $order_customer['cbfn'] );
     1855            $wc_order->set_billing_first_name( $order_customer['cbfn'] );
    18341856        } else {
    1835             $order->set_billing_first_name( $order_customer['cfn'] );
     1857            $wc_order->set_billing_first_name( $order_customer['cfn'] );
    18361858        }
    18371859
    18381860        if ( trim( $order_customer['cbln'] ) !== '' ) {
    1839             $order->set_billing_last_name( $order_customer['cbln'] );
     1861            $wc_order->set_billing_last_name( $order_customer['cbln'] );
    18401862        } else {
    1841             $order->set_billing_last_name( $order_customer['cln'] );
    1842         }
    1843 
    1844         $order->set_billing_company( $order_customer['cbco'] );
    1845         $order->set_billing_address_1( $order_customer['cba1'] );
    1846         $order->set_billing_address_2( $order_customer['cba2'] );
    1847         $order->set_billing_city( $order_customer['cbc'] );
    1848         $order->set_billing_postcode( $order_customer['cbpo'] );
    1849         $order->set_billing_country( $order_customer['cbcu'] );
    1850         $order->set_billing_state( $order_customer['cbs'] );
    1851         $order->set_billing_phone( $order_customer['cbph'] );
    1852         $order->set_billing_email( $order_customer['cbe'] );
    1853 
    1854         $order->set_shipping_first_name( $order_customer['csfn'] );
    1855         $order->set_shipping_last_name( $order_customer['csln'] );
    1856         $order->set_shipping_company( $order_customer['csco'] );
    1857         $order->set_shipping_address_1( $order_customer['csa1'] );
    1858         $order->set_shipping_address_2( $order_customer['csa2'] );
    1859         $order->set_shipping_city( $order_customer['csc'] );
    1860         $order->set_shipping_postcode( $order_customer['cspo'] );
    1861         $order->set_shipping_country( $order_customer['cscu'] );
    1862         $order->set_shipping_state( $order_customer['css'] );
     1863            $wc_order->set_billing_last_name( $order_customer['cln'] );
     1864        }
     1865
     1866        $wc_order->set_billing_company( $order_customer['cbco'] );
     1867        $wc_order->set_billing_address_1( $order_customer['cba1'] );
     1868        $wc_order->set_billing_address_2( $order_customer['cba2'] );
     1869        $wc_order->set_billing_city( $order_customer['cbc'] );
     1870        $wc_order->set_billing_postcode( $order_customer['cbpo'] );
     1871        $wc_order->set_billing_country( $order_customer['cbcu'] );
     1872        $wc_order->set_billing_state( $order_customer['cbs'] );
     1873        $wc_order->set_billing_phone( $order_customer['cbph'] );
     1874        $wc_order->set_billing_email( $order_customer['cbe'] );
     1875
     1876        $wc_order->set_shipping_first_name( $order_customer['csfn'] );
     1877        $wc_order->set_shipping_last_name( $order_customer['csln'] );
     1878        $wc_order->set_shipping_company( $order_customer['csco'] );
     1879        $wc_order->set_shipping_address_1( $order_customer['csa1'] );
     1880        $wc_order->set_shipping_address_2( $order_customer['csa2'] );
     1881        $wc_order->set_shipping_city( $order_customer['csc'] );
     1882        $wc_order->set_shipping_postcode( $order_customer['cspo'] );
     1883        $wc_order->set_shipping_country( $order_customer['cscu'] );
     1884        $wc_order->set_shipping_state( $order_customer['css'] );
    18631885
    18641886        if ( false !== $changed_foosales_customer_id ) {
     
    18671889    }
    18681890
    1869     $order->calculate_totals();
     1891    $wc_order->calculate_totals();
    18701892
    18711893    if ( ! empty( $coupons ) ) {
    18721894        foreach ( $coupons as $coupon ) {
    1873             $order->apply_coupon( new WC_Coupon( $coupon ) );
     1895            $wc_order->apply_coupon( new WC_Coupon( $coupon ) );
    18741896        }
    18751897    }
    18761898
    18771899    if ( '' !== $order_note ) {
    1878         $order->add_order_note( $order_note, $order_note_send_to_customer );
     1900        $wc_order->add_order_note( $order_note, $order_note_send_to_customer );
    18791901    }
    18801902
     
    18821904
    18831905        ob_start();
    1884         $order->save();
     1906        $wc_order->save();
    18851907        ob_end_clean();
    18861908
     
    18991921        $fooevents_checkout_helper = new FooEvents_Checkout_Helper( $fooevents_config );
    19001922
    1901         $fooevents_checkout_helper->woocommerce_events_process( $order->get_id() );
     1923        $fooevents_checkout_helper->woocommerce_events_process( $wc_order->get_id() );
    19021924    }
    19031925
     
    19111933        }
    19121934
    1913         $order->set_status( $order_status );
     1935        $wc_order->set_status( $order_status );
    19141936
    19151937        if ( ! empty( $existing_order_id ) ) {
     
    19171939        }
    19181940    } elseif ( empty( $existing_order_id ) ) {
    1919         $order->set_status( 'completed' );
     1941        $wc_order->set_status( 'completed' );
    19201942    }
    19211943
     
    19291951                $foosales_user_display_name = $foosales_user->display_name;
    19301952
    1931                 $order->add_order_note( sprintf( $foosales_phrases['text_order_updated_via_foosales'], $foosales_user_display_name, "\n- " . implode( "\n- ", $updated_values ) ) );
     1953                $wc_order->add_order_note( sprintf( $foosales_phrases['text_order_updated_via_foosales'], $foosales_user_display_name, "\n- " . implode( "\n- ", $updated_values ) ) );
    19321954            }
    19331955        }
     
    19351957
    19361958    ob_start();
    1937     $order->save();
     1959    $wc_order->save();
    19381960    ob_end_clean();
    19391961
     
    19461968        $analytics['total_items']    = $analytics_total_items;
    19471969        $analytics['payment_method'] = $payment_method_key;
    1948         $analytics['total']          = $order->get_total();
     1970        $analytics['total']          = $wc_order->get_total();
    19491971
    19501972        $woocommerce_onboarding_profile = get_option( 'woocommerce_onboarding_profile', array() );
     
    19802002    }
    19812003
    1982     return $order;
     2004    return $wc_order;
    19832005}
    19842006
     
    19902012 * @param string   $platform The platform that is currently performing this request.
    19912013 * @param bool     $get_product_updates Get the latest information for products in this order.
     2014 *
     2015 * @return array
    19922016 */
    19932017function fsfwc_do_get_single_order( &$wc_order, $platform = 'any', $get_product_updates = false ) {
     
    20372061    unset( $tax_lines, $tax_totals );
    20382062
    2039     $payment_method_key = (string) get_post_meta( $wc_order->get_id(), '_foosales_payment_method', true );
     2063    $payment_method_key = (string) $wc_order->get_meta( '_foosales_payment_method', true );
    20402064
    20412065    if ( '' === $payment_method_key ) {
    20422066
    2043         $payment_method = (string) get_post_meta( $wc_order->get_id(), $foosales_phrases['meta_key_order_payment_method'], true );
     2067        $payment_method = (string) $wc_order->get_meta( $foosales_phrases['meta_key_order_payment_method'], true );
    20442068
    20452069        if ( '' === $payment_method ) {
    2046             $payment_method = (string) get_post_meta( $wc_order->get_id(), 'Order Payment Method', true );
     2070            $payment_method = (string) $wc_order->get_meta( 'Order Payment Method', true );
    20472071        }
    20482072
     
    20532077        unset( $payment_method );
    20542078
    2055         update_post_meta( $wc_order->get_id(), '_foosales_payment_method', $payment_method_key );
     2079        $wc_order->update_meta_data( '_foosales_payment_method', $payment_method_key );
     2080        $wc_order->save();
    20562081
    20572082    } elseif ( 'foosales_square' === $payment_method_key ) {
     
    20592084        $payment_method_key = 'foosales_square_reader';
    20602085
    2061         update_post_meta( $wc_order->get_id(), '_foosales_payment_method', $payment_method_key );
     2086        $wc_order->update_meta_data( '_foosales_payment_method', $payment_method_key );
     2087        $wc_order->save();
    20622088
    20632089    }
     
    20652091    $single_order['opmk'] = '' === $payment_method_key ? 'foosales_other' : $payment_method_key;
    20662092
    2067     $order_source = (string) get_post_meta( $wc_order->get_id(), '_foosales_order_source', true );
     2093    $order_source = (string) $wc_order->get_meta( '_foosales_order_source', true );
    20682094
    20692095    $customer_order_notes = array_reverse( $wc_order->get_customer_order_notes() );
     
    20802106    $single_order['fo'] = 'foosales_app' === $order_source ? '1' : '0';
    20812107
    2082     $single_order['soid'] = (string) get_post_meta( $wc_order->get_id(), '_foosales_square_order_id', true );
    2083     $single_order['spid'] = (string) get_post_meta( $wc_order->get_id(), '_foosales_stripe_payment_id', true );
    2084     $single_order['oud']  = (string) get_post_meta( $wc_order->get_id(), '_foosales_user_id', true );
     2108    $single_order['soid'] = (string) $wc_order->get_meta( '_foosales_square_order_id', true );
     2109    $single_order['spid'] = (string) $wc_order->get_meta( '_foosales_stripe_payment_id', true );
     2110    $single_order['oud']  = (string) $wc_order->get_meta( '_foosales_user_id', true );
    20852111
    20862112    $payment_method_key = null;
     
    23022328    $single_order['ocl'] = $coupon_lines;
    23032329
    2304     $single_order['etg'] = '' !== get_post_meta( $wc_order->get_id(), 'WooCommerceEventsTicketsGenerated', true ) ? '1' : '0';
     2330    $single_order['etg'] = '' !== $wc_order->get_meta( 'WooCommerceEventsTicketsGenerated', true ) ? '1' : '0';
    23052331
    23062332    $woocommerce_events_order_tickets = array();
     
    23272353            $woocommerce_events_order_tickets = $fooevents_orders_helper->process_event_tickets_for_display( $event_tickets );
    23282354        } else {
    2329             $woocommerce_events_order_tickets = get_post_meta( $wc_order->get_id(), 'WooCommerceEventsOrderTickets', true );
     2355            $woocommerce_events_order_tickets = $wc_order->get_meta( 'WooCommerceEventsOrderTickets', true );
    23302356            $woocommerce_events_order_tickets = '' !== $woocommerce_events_order_tickets ? $fooevents_orders_helper->process_order_tickets_for_display( $woocommerce_events_order_tickets ) : array();
    23312357        }
     
    23622388            $update_product_params = $offline_change['update_product']['FooSalesProductParams'];
    23632389
    2364             fsfwc_do_update_product( json_decode( $update_product_params, true ), $platform );
     2390            $result = fsfwc_do_update_product( json_decode( $update_product_params, true ), $platform );
    23652391
    23662392            $response = array();
    23672393
    2368             $response['ocid'] = $offline_change['update_product']['ocid'];
     2394            if ( ! empty( $result ) ) {
     2395                $response['ocid'] = $offline_change['update_product']['ocid'];
     2396            }
    23692397
    23702398            echo wp_json_encode( $response );
     
    24822510            }
    24832511
    2484             $refund_result  = fsfwc_do_refund_order( $order_id, $refunded_items );
    2485             $refunded_order = $refund_result['order'];
     2512            $refund_result = fsfwc_do_refund_order( $order_id, $refunded_items );
    24862513
    24872514            $response = array();
     
    25182545 * @param boolean $restock Whether or not the items should be restocked.
    25192546 * @param string  $platform The platform that is currently performing this request.
     2547 *
     2548 * @return bool
    25202549 */
    25212550function fsfwc_do_cancel_order( $order_id, $restock, $platform = 'any' ) {
     
    25762605 * @param array  $refunded_items Items to be refunded.
    25772606 * @param string $platform The platform that is currently performing this request.
     2607 *
     2608 * @return array
    25782609 */
    25792610function fsfwc_do_refund_order( $order_id, $refunded_items, $platform = 'any' ) {
     
    26492680    }
    26502681
    2651     $payment_method_key = get_post_meta( $order_id, '_foosales_payment_method', true );
     2682    $payment_method_key = $wc_order->get_meta( '_foosales_payment_method', true );
    26522683
    26532684    $result = array();
     
    26642695    ) ) {
    26652696
    2666         $square_order_auto_refund = get_post_meta( $order_id, '_foosales_square_order_auto_refund', true ) === '1';
     2697        $square_order_auto_refund = $wc_order->get_meta( '_foosales_square_order_auto_refund', true ) === '1';
    26672698
    26682699        if ( $square_order_auto_refund ) {
    26692700
    2670             $square_order_id = get_post_meta( $order_id, '_foosales_square_order_id', true );
     2701            $square_order_id = $wc_order->get_meta( '_foosales_square_order_id', true );
    26712702
    26722703            $refund_result = fsfwc_refund_square_order( $square_order_id, $refund_total, $platform );
     
    27262757        true
    27272758    ) ) {
    2728         $stripe_payment_id = get_post_meta( $order_id, '_foosales_stripe_payment_id', true );
     2759        $stripe_payment_id = $wc_order->get_meta( '_foosales_stripe_payment_id', true );
    27292760
    27302761        $refund_result = fsfwc_refund_stripe_payment( $stripe_payment_id, $refund_total );
     
    27472778 * @param array  $customer_details Key/value pairs of customer data to create or update a customer.
    27482779 * @param string $platform The platform that is currently performing this request.
     2780 *
     2781 * @return array
    27492782 */
    27502783function fsfwc_do_create_update_customer( $customer_details = array(), $platform = 'any' ) {
     
    28422875 * @param array  $order_customer The cart customer which will be used to obtain the discounts.
    28432876 * @param string $platform The platform that is currently performing this request.
     2877 *
     2878 * @return array
    28442879 */
    28452880function fsfwc_do_get_coupon_code_discounts( $coupons = array(), $order_items = array(), $order_customer = array(), $platform = 'any' ) {
     
    28532888    WC()->cart     = new WC_Cart();
    28542889
    2855     $order = wc_create_order();
     2890    $wc_order = wc_create_order();
    28562891
    28572892    // Order customer.
     
    28912926        WC()->customer->set_shipping_state( $order_customer['css'] );
    28922927
    2893         $order->set_customer_id( (int) $order_customer['cid'] );
     2928        $wc_order->set_customer_id( (int) $order_customer['cid'] );
    28942929
    28952930        if ( trim( $order_customer['cbfn'] ) !== '' ) {
    2896             $order->set_billing_first_name( $order_customer['cbfn'] );
     2931            $wc_order->set_billing_first_name( $order_customer['cbfn'] );
    28972932        } else {
    2898             $order->set_billing_first_name( $order_customer['cfn'] );
     2933            $wc_order->set_billing_first_name( $order_customer['cfn'] );
    28992934        }
    29002935
    29012936        if ( trim( $order_customer['cbln'] ) !== '' ) {
    2902             $order->set_billing_last_name( $order_customer['cbln'] );
     2937            $wc_order->set_billing_last_name( $order_customer['cbln'] );
    29032938        } else {
    2904             $order->set_billing_last_name( $order_customer['cln'] );
    2905         }
    2906 
    2907         $order->set_billing_company( $order_customer['cbco'] );
    2908         $order->set_billing_address_1( $order_customer['cba1'] );
    2909         $order->set_billing_address_2( $order_customer['cba2'] );
    2910         $order->set_billing_city( $order_customer['cbc'] );
    2911         $order->set_billing_postcode( $order_customer['cbpo'] );
    2912         $order->set_billing_country( $order_customer['cbcu'] );
    2913         $order->set_billing_state( $order_customer['cbs'] );
    2914         $order->set_billing_phone( $order_customer['cbph'] );
    2915         $order->set_billing_email( $order_customer['cbe'] );
    2916 
    2917         $order->set_shipping_first_name( $order_customer['csfn'] );
    2918         $order->set_shipping_last_name( $order_customer['csln'] );
    2919         $order->set_shipping_company( $order_customer['csco'] );
    2920         $order->set_shipping_address_1( $order_customer['csa1'] );
    2921         $order->set_shipping_address_2( $order_customer['csa2'] );
    2922         $order->set_shipping_city( $order_customer['csc'] );
    2923         $order->set_shipping_postcode( $order_customer['cspo'] );
    2924         $order->set_shipping_country( $order_customer['cscu'] );
    2925         $order->set_shipping_state( $order_customer['css'] );
     2939            $wc_order->set_billing_last_name( $order_customer['cln'] );
     2940        }
     2941
     2942        $wc_order->set_billing_company( $order_customer['cbco'] );
     2943        $wc_order->set_billing_address_1( $order_customer['cba1'] );
     2944        $wc_order->set_billing_address_2( $order_customer['cba2'] );
     2945        $wc_order->set_billing_city( $order_customer['cbc'] );
     2946        $wc_order->set_billing_postcode( $order_customer['cbpo'] );
     2947        $wc_order->set_billing_country( $order_customer['cbcu'] );
     2948        $wc_order->set_billing_state( $order_customer['cbs'] );
     2949        $wc_order->set_billing_phone( $order_customer['cbph'] );
     2950        $wc_order->set_billing_email( $order_customer['cbe'] );
     2951
     2952        $wc_order->set_shipping_first_name( $order_customer['csfn'] );
     2953        $wc_order->set_shipping_last_name( $order_customer['csln'] );
     2954        $wc_order->set_shipping_company( $order_customer['csco'] );
     2955        $wc_order->set_shipping_address_1( $order_customer['csa1'] );
     2956        $wc_order->set_shipping_address_2( $order_customer['csa2'] );
     2957        $wc_order->set_shipping_city( $order_customer['csc'] );
     2958        $wc_order->set_shipping_postcode( $order_customer['cspo'] );
     2959        $wc_order->set_shipping_country( $order_customer['cscu'] );
     2960        $wc_order->set_shipping_state( $order_customer['css'] );
    29262961    }
    29272962
    29282963    // Order date.
    2929     wp_update_post(
    2930         array(
    2931             'ID'        => $order->get_id(),
    2932             'post_date' => gmdate( 'Y-m-d H:i:s+00:00', time() ),
    2933         )
    2934     );
     2964    $wc_order->set_date_created( time() );
    29352965
    29362966    // Order items.
     
    29472977        $wc_product = wc_get_product( $order_item['pid'] );
    29482978
    2949         $order->add_product( $wc_product, $order_item['oiq'], $product_args );
     2979        $wc_order->add_product( $wc_product, $order_item['oiq'], $product_args );
    29502980
    29512981        $product_args = null;
     
    29542984    }
    29552985
    2956     $order->calculate_totals();
     2986    $wc_order->calculate_totals();
    29572987
    29582988    if ( ! empty( $coupons ) ) {
    29592989        foreach ( $coupons as $coupon ) {
    2960             $coupon_result = $order->apply_coupon( new WC_Coupon( $coupon ) );
     2990            $coupon_result = $wc_order->apply_coupon( new WC_Coupon( $coupon ) );
    29612991
    29622992            if ( is_wp_error( $coupon_result ) ) {
    2963                 $order->delete( true );
     2993                $wc_order->delete( true );
    29642994
    29652995                $output['message'] = html_entity_decode( wp_strip_all_tags( $coupon_result->get_error_message() ) );
     
    29713001
    29723002    $output['status']           = 'success';
    2973     $output['discounted_order'] = fsfwc_do_get_single_order( $order, $platform );
     3003    $output['discounted_order'] = fsfwc_do_get_single_order( $wc_order, $platform );
    29743004
    29753005    $output['discounts'] = array();
    29763006
    2977     $coupons = $order->get_items( 'coupon' );
     3007    $coupons = $wc_order->get_items( 'coupon' );
    29783008
    29793009    if ( ! empty( $coupons ) ) {
     
    29853015            );
    29863016
    2987             $coupon_result = $order->remove_coupon( $coupon->get_code() );
     3017            $coupon_result = $wc_order->remove_coupon( $coupon->get_code() );
    29883018        }
    29893019    }
     
    29923022    WC()->cart->empty_cart();
    29933023
    2994     $order->delete( true );
    2995 
    2996     $order = null;
    2997 
    2998     unset( $order );
     3024    $wc_order->delete( true );
     3025
     3026    $wc_order = null;
     3027
     3028    unset( $wc_order );
    29993029
    30003030    return $output;
     
    30093039 * @param int    $last_checked_timestamp The timestamp of the last time updates were fetched by the app.
    30103040 * @param string $platform The platform that is currently performing this request.
     3041 *
     3042 * @return array
    30113043 */
    30123044function fsfwc_do_get_data_updates( $last_checked_timestamp = 0, $platform = 'any' ) {
     
    30433075
    30443076    $order_args = array(
    3045         'posts_per_page' => -1,
    3046         'post_type'      => 'shop_order',
    3047         'post_status'    => $order_load_statuses,
    3048         'date_query'     => array(
    3049             'column' => 'post_modified',
    3050             'after'  => gmdate( 'Y-m-d H:i:s+00:00', $last_checked_timestamp ),
    3051         ),
    3052         'fields'         => 'ids',
    3053         'no_found_rows'  => true,
    3054         'orderby'        => 'id',
    3055         'order'          => 'DESC',
     3077        'limit'         => -1,
     3078        'type'          => 'shop_order',
     3079        'status'        => $order_load_statuses,
     3080        'date_modified' => '>' . $last_checked_timestamp,
     3081        'return'        => 'ids',
     3082        'orderby'       => 'ID',
    30563083    );
    30573084
    3058     $order_query = new WP_Query( $order_args );
     3085    $order_ids = wc_get_orders( $order_args );
    30593086
    30603087    $order_updates = array();
    30613088
    3062     foreach ( $order_query->posts as $post_id ) {
    3063 
    3064         $wc_order = wc_get_order( $post_id );
     3089    foreach ( $order_ids as $order_id ) {
     3090
     3091        $wc_order = wc_get_order( $order_id );
    30653092
    30663093        $updated_order = fsfwc_do_get_single_order( $wc_order, $platform );
     
    31273154    $updated_order_product_ids = array_unique( array_merge( $products_query->posts, $updated_order_product_ids ) );
    31283155
    3129     foreach ( $updated_order_product_ids as $post_id ) {
     3156    foreach ( $updated_order_product_ids as $product_id ) {
    31303157
    31313158        if ( 'ios' === $platform || 'android' === $platform || 'web' === $platform ) {
     
    31393166        }
    31403167
    3141         $updated_product = fsfwc_do_get_single_product( $post_id, $wc_tax, $cat_names, $shop_tax, $platform );
     3168        $updated_product = fsfwc_do_get_single_product( $product_id, $wc_tax, $cat_names, $shop_tax, $platform );
    31423169
    31433170        $product_image = preg_replace_callback(
     
    31463173                return rawurlencode( $match[0] );
    31473174            },
    3148             (string) get_the_post_thumbnail_url( $post_id, 'thumbnail' )
     3175            (string) get_the_post_thumbnail_url( $product_id, 'thumbnail' )
    31493176        );
    31503177
     
    32573284            if ( ! empty( $response_array['order'] ) ) {
    32583285
    3259                 $order = $response_array['order'];
     3286                $wc_order = $response_array['order'];
    32603287
    32613288                $result['status'] = 'success';
    32623289
    3263                 $result['order'] = $order;
     3290                $result['order'] = $wc_order;
    32643291
    32653292            } else {
     
    33043331    if ( 'success' === $order_result['status'] ) {
    33053332
    3306         $order = $order_result['order'];
     3333        $wc_order = $order_result['order'];
    33073334
    33083335        if ( ! empty( $order['tenders'] ) ) {
     
    34343461 * @param array  $payment_data Key/value pairs for the payment data.
    34353462 * @param string $platform The platform that is currently performing this request.
     3463 *
     3464 * @return array
    34363465 */
    34373466function fsfwc_do_create_square_payment( $payment_data = array(), $platform = 'any' ) {
     
    35013530 * @param array  $square_location Key/value pairs of Square location data.
    35023531 * @param string $platform The platform that is currently performing this request.
     3532 *
     3533 * @return array
    35033534 */
    35043535function fsfwc_do_generate_square_device_code( $square_location = array(), $platform = 'any' ) {
     
    36123643 * @param string $square_device_code_id Square device ID.
    36133644 * @param string $platform The platform that is currently performing this request.
     3645 *
     3646 * @return array
    36143647 */
    36153648function fsfwc_do_get_square_device_pair_status( $square_device_code_id = '', $platform = 'any' ) {
     
    36513684 * @param array  $checkout_data Key/value pairs of checkout data.
    36523685 * @param string $platform The platform that is currently performing this request.
     3686 *
     3687 * @return array
    36533688 */
    36543689function fsfwc_do_create_square_terminal_checkout( $checkout_data = array(), $platform = 'any' ) {
     
    37383773 * @param string $checkout_id The ID of the Square checkout.
    37393774 * @param string $platform The platform that is currently performing this request.
     3775 *
     3776 * @return array
    37403777 */
    37413778function fsfwc_do_get_square_terminal_checkout_status( $checkout_id = '', $platform = 'any' ) {
     
    38353872 * @param array  $refund_data Key/value pairs of refund data.
    38363873 * @param string $platform The platform that is currently performing this request.
     3874 *
     3875 * @return array
    38373876 */
    38383877function fsfwc_do_create_square_terminal_refund( $refund_data = array(), $platform = 'any' ) {
     
    39263965 * @param string $refund_id The ID of the Square refund.
    39273966 * @param string $platform The platform that is currently performing this request.
     3967 *
     3968 * @return array
    39283969 */
    39293970function fsfwc_do_get_square_terminal_refund_status( $refund_id = '', $platform = 'any' ) {
     
    39684009 * @param array  $reader_data The reader data in associative array.
    39694010 * @param string $platform The platform that is currently performing this request.
     4011 *
     4012 * @return array
    39704013 */
    39714014function fsfwc_do_register_stripe_reader( $reader_data = array(), $platform = 'any' ) {
     
    40194062 * @since 1.20.0
    40204063 * @param string $platform The platform that is currently performing this request.
     4064 *
     4065 * @return array
    40214066 */
    40224067function fsfwc_do_create_stripe_connection_token( $platform = 'any' ) {
     
    40654110 * @param string $payment_method The FooSales payment method.
    40664111 * @param string $platform The platform that is currently performing this request.
     4112 *
     4113 * @return array
    40674114 */
    40684115function fsfwc_do_create_stripe_payment_intent( $payment_intent_data = array(), $payment_method = '', $platform = 'any' ) {
     
    41234170 * @param string $payment_intent_id The payment intent ID.
    41244171 * @param string $platform The platform that is currently performing this request.
     4172 *
     4173 * @return array
    41254174 */
    41264175function fsfwc_do_capture_stripe_payment( $payment_intent_id = '', $platform = 'any' ) {
     
    41724221 * @param string $stripe_payment_id The ID of the Stripe payment intent.
    41734222 * @param double $amount The amount in cents to refund to the original payment card.
     4223 *
     4224 * @return array
    41744225 */
    41754226function fsfwc_refund_stripe_payment( $stripe_payment_id = '', $amount = 0 ) {
     
    45944645
    45954646/**
    4596  * Update the modified date to the current time for the given post ID.
     4647 * Update the modified date to the current time for the given item ID.
    45974648 *
    45984649 * @since 1.33.0
    4599  * @param int $post_id The ID of the post to be updated.
    4600  */
    4601 function fsfwc_update_modified_date( $post_id = '' ) {
     4650 * @param int $id The ID of the item to be updated.
     4651 */
     4652function fsfwc_update_modified_date( $id = '' ) {
    46024653    global $wpdb;
    46034654
    4604     if ( '' !== $post_id ) {
     4655    if ( (int) $id > 0 ) {
    46054656        $time = time();
    46064657
    4607         $mysql_time_format = 'Y-m-d H:i:s';
    4608 
    4609         $post_modified = gmdate( $mysql_time_format, $time );
    4610 
    4611         $post_modified_gmt = gmdate( $mysql_time_format, ( $time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
    4612 
    4613         $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
    4614             $wpdb->prepare(
    4615                 "UPDATE $wpdb->posts SET post_modified = %s, post_modified_gmt = %s  WHERE ID = %s",
    4616                 $post_modified,
    4617                 $post_modified_gmt,
    4618                 $post_id
    4619             )
    4620         );
    4621     }
    4622 }
     4658        if ( OrderUtil::is_order( $id ) ) {
     4659            $wc_order = wc_get_order( $id );
     4660
     4661            $wc_order->set_date_modified( $time );
     4662            $wc_order->save();
     4663        } else {
     4664            $mysql_time_format = 'Y-m-d H:i:s';
     4665
     4666            $post_modified = gmdate( $mysql_time_format, $time );
     4667
     4668            $post_modified_gmt = gmdate( $mysql_time_format, ( $time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
     4669
     4670            $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
     4671                $wpdb->prepare(
     4672                    "UPDATE $wpdb->posts SET post_modified = %s, post_modified_gmt = %s  WHERE ID = %s",
     4673                    $post_modified,
     4674                    $post_modified_gmt,
     4675                    $id
     4676                )
     4677            );
     4678        }
     4679    }
     4680}
  • foosales/trunk/helpers/foosales-phrases-helper.php

    r2919862 r2926151  
    33 * All phrases used throughout the plugin
    44 *
    5  * Generated: 2023-05-31 12:35:22 GMT-7
     5 * Generated: 2023-06-14 10:20:40 GMT-7
    66 *
    77 * @link https://www.foosales.com
     
    2828    'label_expired_free_trial'                            => __( 'Expired free trial', 'foosales' ),
    2929    'title_expired_free_trial'                            => __( 'Your free trial has expired!', 'foosales' ),
    30     'description_expired_free_trial'                      => __( 'We hope that you enjoyed your 30-day free trial. Please purchase a FooSales plan to continue using the FooSales apps.', 'foosales' ),
     30    'description_expired_free_trial'                      => __( 'We hope that you enjoyed your 7-day free trial. Please purchase a FooSales plan to continue using the FooSales apps.', 'foosales' ),
    3131    'label_active_free_trial'                             => __( 'Active Free Trial', 'foosales' ),
    3232    'title_active_free_trial'                             => __( 'Your store domain is currently linked to an active free trial', 'foosales' ),
     
    5151    'label_domain_not_found'                              => __( 'Not linked', 'foosales' ),
    5252    'title_domain_not_found'                              => __( 'Your store domain is not currently linked to a FooSales account', 'foosales' ),
    53     'description_domain_not_found'                        => __( 'Your store needs to be linked to a FooSales account in order to use the FooSales apps. Click the button below to sign-up for a FooSales account and start your 30-day free trial today!', 'foosales' ),
     53    'description_domain_not_found'                        => __( 'Your store needs to be linked to a FooSales account in order to use the FooSales apps. Click the button below to sign-up for a FooSales account and start your 7-day free trial today!', 'foosales' ),
    5454    'button_link_store'                                   => __( 'Link your store', 'foosales' ),
    5555    'title_download_apps'                                 => __( 'Download the FooSales apps', 'foosales' ),
  • foosales/trunk/readme.txt

    r2919862 r2926151  
    44Requires at least: 5.1
    55Tested up to: 6.2.2
    6 Stable tag: 1.33.0
     6Stable tag: 1.34.0
    77License: GNU General Public License v3.0
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1616FooSales POS makes it easy to sell your products and services in-person and run your business from anywhere in the world while automatically syncing your WooCommerce product inventory, order and customer data. Turn your WooCommerce store into an omnichannel retail platform for a fraction of the cost of a traditional POS solution thanks to integrations with popular printers, scanners, card readers and other devices. FooSales is perfect for retail stores, markets, pop-up shops, mobile events and many other use cases.
    1717
    18 [youtube https://www.youtube.com/watch?v=I7e_1tpTrRU]
    19 
    20 [Start your 30-day free trial](https://www.foosales.com/signup/?ref=wp)
     18[Start your 7-day free trial](https://www.foosales.com/signup/?ref=wp)
    2119
    2220= Built for WooCommerce =
     
    6866Install the FooSales POS plugin directly from your WordPress admin area by clicking 'Add New' in the Plugins menu, then search for "FooSales" OR manually [download the plugin](https://wordpress.org/plugins/foosales/) from WordPress.org.
    6967
    70 Step 2: Link your store to a 30-day free trial account
     68Step 2: Link your store to a 7-day free trial account
    7169
    7270[Create a FooSales account](https://www.foosales.com/signup/) which will allow you to access all the FooSales POS features on any computer, iPad or Android tablet.
     
    108106= I'm in! Where do I start? =
    109107
    110 [Sign-up](https://www.foosales.com/signup/) to create a FooSales account and start your 30-day free trial!
     108[Sign-up](https://www.foosales.com/signup/) to create a FooSales account and start your 7-day free trial!
    111109
    112110= How much does FooSales POS cost? =
     
    225223
    226224== Changelog ==
     225
     2262023-06-14 - version 1.34.0
     227* Point of sale plugin update: FooSales now supports WooCommerce High Performance Order Storage (HPOS)
    227228
    2282292023-05-31 - version 1.33.0
  • foosales/trunk/templates/template-foosales-import.php

    r2919862 r2926151  
    9292                                $product_stock         = ! empty( $update_product_params['ps'] ) ? $update_product_params['ps'] : 0;
    9393
    94                                 $import_title = esc_html( $foosales_phrases['label_update_product'] ) . ' "' . (string) htmlspecialchars_decode( get_post_field( 'post_title', $update_product_params['pid'] ) ) . '" (' . esc_html( $update_product_params['pid'] ) . ')';
     94                                $wc_product = wc_get_product( $product_id );
     95
     96                                $import_title = esc_html( $foosales_phrases['label_update_product'] ) . ' "' . (string) htmlspecialchars_decode( $wc_product->get_title() ) . '" (' . esc_html( $product_id ) . ')';
    9597
    9698                                if ( $already_imported ) {
     
    103105                                    $update_product_result = fsfwc_do_update_product( $update_product_params, $platform );
    104106
    105                                     if ( false !== $update_product_result ) {
     107                                    if ( ! empty( $update_product_result ) ) {
    106108                                        $import_result .= ! empty( $update_product_params['pp'] ) ? "\t- " . esc_html( $foosales_phrases['label_update_product_set_price'] ) . ': ' . esc_html( wp_strip_all_tags( wc_price( $product_price ) ) ) . "\n" : '';
    107109                                        $import_result .= ! empty( $update_product_params['prp'] ) ? "\t- " . esc_html( $foosales_phrases['label_update_product_set_regular_price'] ) . ': ' . esc_html( wp_strip_all_tags( wc_price( $product_regular_price ) ) ) . "\n" : '';
  • foosales/trunk/vendor/stripe-php/lib/Charge.php

    r2919862 r2926151  
    66
    77/**
    8  * To charge a credit or a debit card, you create a <code>Charge</code> object. You can
    9  * retrieve and refund individual charges as well as list all charges. Charges
    10  * are identified by a unique, random ID.
    11  *
    12  * Related guide: <a href="https://stripe.com/docs/payments/accept-a-payment-charges">Accept a payment with the Charges API</a>
     8 * The <code>Charge</code> object represents a single attempt to move money into your Stripe account.
     9 * PaymentIntent confirmation is the most common way to create Charges, but transferring
     10 * money to a different Stripe account through Connect also creates Charges.
     11 * Some legacy payment flows create Charges directly, which is not recommended for new integrations.
    1312 *
    1413 * @property string $id Unique identifier for the object.
  • foosales/trunk/vendor/stripe-php/lib/Issuing/Cardholder.php

    r2919862 r2926151  
    2121 * @property string $name The cardholder's name. This will be printed on cards issued to them.
    2222 * @property null|string $phone_number The cardholder's phone number. This is required for all cardholders who will be creating EU cards. See the <a href="https://stripe.com/docs/issuing/3d-secure#when-is-3d-secure-applied">3D Secure documentation</a> for more details.
     23 * @property null|string[] $preferred_locales The cardholder’s preferred locales (languages), ordered by preference. Locales can be <code>de</code>, <code>en</code>, <code>es</code>, <code>fr</code>, or <code>it</code>. This changes the language of the <a href="https://stripe.com/docs/issuing/3d-secure">3D Secure flow</a> and one-time password messages sent to the cardholder.
    2324 * @property \FooSales\Stripe\StripeObject $requirements
    2425 * @property null|\FooSales\Stripe\StripeObject $spending_controls Rules that control spending across this cardholder's cards. Refer to our <a href="https://stripe.com/docs/issuing/controls/spending-controls">documentation</a> for more details.
  • foosales/trunk/vendor/stripe-php/lib/LoginLink.php

    r2591658 r2926151  
    66
    77/**
     8 * Login Links are single-use login link for an Express account to access their Stripe dashboard.
     9 *
    810 * @property string $object String representing the object's type. Objects of the same type share the same value.
    911 * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  • foosales/trunk/vendor/stripe-php/lib/Service/ChargeService.php

    r2708162 r2926151  
    2424
    2525    /**
    26      * Capture the payment of an existing, uncaptured, charge. This is the second half
    27      * of the two-step payment flow, where first you <a href="#create_charge">created a
    28      * charge</a> with the capture option set to false.
     26     * Capture the payment of an existing, uncaptured charge that was created with the
     27     * <code>capture</code> option set to false.
    2928     *
    3029     * Uncaptured payments expire a set number of days after they are created (<a
    31      * href="/docs/charges/placing-a-hold">7 by default</a>). If they are not captured
    32      * by that point in time, they will be marked as refunded and will no longer be
    33      * capturable.
     30     * href="/docs/charges/placing-a-hold">7 by default</a>), after which they are
     31     * marked as refunded and capture attempts will fail.
     32     *
     33     * Don’t use this method to capture a PaymentIntent-initiated charge. Use <a
     34     * href="/docs/api/payment_intents/capture">Capture a PaymentIntent</a>.
    3435     *
    3536     * @param string $id
     
    4748
    4849    /**
    49      * To charge a credit card or other payment source, you create a
    50      * <code>Charge</code> object. If your API key is in test mode, the supplied
    51      * payment source (e.g., card) won’t actually be charged, although everything else
    52      * will occur as if in live mode. (Stripe assumes that the charge would have
    53      * completed successfully).
     50     * Use the <a href="/docs/api/payment_intents">Payment Intents API</a> to initiate
     51     * a new payment instead of using this method. Confirmation of the PaymentIntent
     52     * creates the <code>Charge</code> object used to request payment, so this method
     53     * is limited to legacy integrations.
    5454     *
    5555     * @param null|array $params
  • foosales/trunk/vendor/stripe-php/lib/Stripe.php

    r2919862 r2926151  
    5959    private static $initialNetworkRetryDelay = 0.5;
    6060
    61     const VERSION = '10.14.0';
     61    const VERSION = '10.15.0';
    6262
    6363    /**
  • foosales/trunk/vendor/stripe-php/lib/Token.php

    r2919862 r2926151  
    2727 * performs best with integrations that use client-side tokenization.
    2828 *
    29  * Related guide: <a href="https://stripe.com/docs/payments/accept-a-payment-charges#web-create-token">Accept a payment with Charges and Tokens</a>
    30  *
    3129 * @property string $id Unique identifier for the object.
    3230 * @property string $object String representing the object's type. Objects of the same type share the same value.
Note: See TracChangeset for help on using the changeset viewer.