Plugin Directory

Changeset 3341654


Ignore:
Timestamp:
08/08/2025 01:11:40 PM (7 months ago)
Author:
UkrSolution
Message:

1.10.2

Location:
barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk
Files:
4 added
4 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/download-csv.php

    r3304735 r3341654  
    22
    33use UkrSolution\BarcodeScanner\Core;
    4 
    5 if (!defined('WP_USE_THEMES')) {
    6     define('WP_USE_THEMES', false);
    7 }
    8 
    9 if (!defined('DISABLE_WP_CRON')) {
    10     define('DISABLE_WP_CRON', true);
    11 }
    124
    135global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
     
    2820
    2921require($root . "/wp-load.php");
     22
     23if (!defined('WP_USE_THEMES')) {
     24    define('WP_USE_THEMES', false);
     25}
     26
     27if (!defined('DISABLE_WP_CRON')) {
     28    define('DISABLE_WP_CRON', true);
     29}
    3030
    3131$dt = new \DateTime("now");
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/request.php

    r3336436 r3341654  
    22
    33use UkrSolution\BarcodeScanner\Core;
    4 
    5 if (!defined('WP_USE_THEMES')) {
    6     define('WP_USE_THEMES', false);
    7 }
    8 
    9 if (!defined('DISABLE_WP_CRON')) {
    10     define('DISABLE_WP_CRON', true);
    11 }
    124
    135global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
     
    2820
    2921require($root . "/wp-load.php");
     22
     23if (!defined('WP_USE_THEMES')) {
     24    define('WP_USE_THEMES', false);
     25}
     26
     27if (!defined('DISABLE_WP_CRON')) {
     28    define('DISABLE_WP_CRON', true);
     29}
    3030
    3131function usbs_plugin_filter($plugins)
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/API/actions/CartScannerActions.php

    r3335202 r3341654  
    744744            "cart_total_c" => strip_tags($cartTotal),
    745745            "cart_subtotal" => $cart_subtotal,
    746             "cart_subtotal_c" => strip_tags(wc_price($cartSubtotal)), 
     746            "cart_subtotal_c" => strip_tags(wc_price($cartSubtotal)),
    747747            "cart_subtotal_tax" => $cartSubtotalTax,
    748748            "cart_subtotal_tax_c" => strip_tags(wc_price($cartSubtotalTax)),
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/API/actions/HPOS.php

    r3335202 r3341654  
    507507
    508508            $taxAddress = $cartScannerActions->getTaxAddress(array("address" => array(
    509                 "billing_country" => $order->billing_country,
    510                 "billing_state" => $order->billing_state,
    511                 "billing_city" => $order->billing_city,
    512                 "billing_postcode" => $order->billing_postcode,
    513                 "shipping_country" => $order->shipping_country,
    514                 "shipping_state" => $order->shipping_state,
    515                 "shipping_city" => $order->shipping_city,
    516                 "shipping_postcode" => $order->shipping_postcode,
     509                "billing_country" => $order->get_billing_country(),
     510                "billing_state" => $order->get_billing_state(),
     511                "billing_city" => $order->get_billing_city(),
     512                "billing_postcode" => $order->get_billing_postcode(),
     513                "shipping_country" => $order->get_shipping_country(),
     514                "shipping_state" => $order->get_shipping_state(),
     515                "shipping_city" => $order->get_shipping_city(),
     516                "shipping_postcode" => $order->get_shipping_postcode(),
    517517                "shipping_as_billing" => 0
    518518            )));
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/API/actions/ManagementActions.php

    r3335202 r3341654  
    21392139            $order->save();
    21402140
    2141             if (preg_match('/^(\d+)\%$/', $coupon, $matches)) {
     2141            if (false && preg_match('/^(\d+)\%$/', $coupon, $matches)) {
    21422142                $couponPercent = $matches[1];
    2143                 $item = new \WC_Order_Item_Coupon();
    2144                 $item->set_props(array(
    2145                     'code' => $coupon,
    2146                     'discount' => $couponPercent,
    2147                     'discount_tax' => 0,
    2148                 ));
    2149                 $order->add_item($item);
     2143                $coupon_code = 'dynamic' . $couponPercent . '-' . wp_generate_password(6, false);
     2144                $coupon_code = $couponPercent . "%";
     2145                $coupon = new \WC_Coupon();
     2146                $coupon->set_description('Barcode scanner - autogenerated coupon');
     2147                $coupon->set_code($coupon_code);
     2148                $coupon->set_discount_type('percent');
     2149                $coupon->set_amount($couponPercent);
     2150                $coupon->set_individual_use(true);
     2151                $coupon->set_usage_limit(1);
     2152                $coupon->set_date_expires(strtotime('+1 day'));
     2153                $coupon->save();
     2154
     2155                $order->apply_coupon($coupon->get_code());
     2156                $order->set_discount_total($coupon->get_amount());
     2157
     2158
    21502159
    21512160            }
     
    21542163
    21552164                if ($coupon->get_id()) {
    2156                     $order->apply_coupon($coupon->get_code());
    2157                     $order->set_discount_total($coupon->get_amount());
    2158                 }
    2159             }
     2165                    $coupon_code = $order->apply_coupon($coupon->get_code());
     2166
     2167                    if (is_wp_error($coupon_code)) {
     2168                        return rest_ensure_response(array("error" => $coupon_code->get_error_message()));
     2169                    } else {
     2170                        $order->set_discount_total($coupon->get_amount());
     2171                    }
     2172                } else {
     2173                    return rest_ensure_response(array("error" => __("Coupon not found.", "us-barcode-scanner")));
     2174                }
     2175            }
    21602176
    21612177
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/API/classes/Integrations.php

    r3304735 r3341654  
    3434
    3535            add_action('init', array($this, "postDateFields"));
     36
     37            add_action('init', array($this, "printInvoicesPackingSlipLabelsForWoocommerce"));
    3638        } catch (\Throwable $th) {
    3739        }
     
    575577        }, 10, 3);
    576578    }
     579
     580    public function printInvoicesPackingSlipLabelsForWoocommerce()
     581    {
     582        add_filter('wf_pklist_modify_meta_data', function ($meta_data, $order_item, $order = null, $template_type = null) {
     583            if (isset($meta_data['usbs_check_product_scanned'])) {
     584                unset($meta_data['usbs_check_product_scanned']);
     585            }
     586
     587            if (isset($meta_data['usbs_check_product'])) {
     588                unset($meta_data['usbs_check_product']);
     589            }
     590
     591            return $meta_data;
     592        }, 1000, 4);
     593    }
    577594}
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/Database.php

    r3335202 r3341654  
    503503            array("field_name" => "usbs_stock_location_level_2", "field_label" => "Rack", "label_position" => "top", "label_width" => $widthRight, "position" => "product-left-sidebar", "type" => "text", "field_height" => 0, "status" => 1, "order" => 290),
    504504            array("field_name" => "usbs_stock_location_level_3", "field_label" => "Shelf", "label_position" => "top", "label_width" => $widthRight, "position" => "product-left-sidebar", "type" => "text", "field_height" => 0, "status" => 1, "order" => 280),
    505         );
    506         $defaultFieldsForAll = array(
     505            );
     506            $defaultFieldsForAll = array(
    507507            array("field_name" => "usbs_variation_attributes", "field_label" => "Variation attributes", "label_position" => "top", "label_width" => $widthRight, "position" => "product-middle-right", "type" => "variation_attributes", "field_height" => 0, "status" => 1, "order" => 870),
    508508            array("field_name" => "product_cat", "field_label" => "Categories", "label_position" => "left", "label_width" => $widthLeft, "position" => "product-middle-left", "type" => "taxonomy", "field_height" => 0, "status" => 1, "order" => 400),
     
    513513            array("field_name" => "_backorders", "field_label" => "Allow backorders?", "label_position" => "top", "label_width" => $widthRight, "position" => "product-middle-right", "type" => "select", "field_height" => 0, "status" => 0, "options" => json_encode($_backorders), "order" => 920),
    514514            array("field_name" => "_switch_status", "field_label" => "Checkbox", "label_position" => "top", "label_width" => $widthRight, "position" => "product-middle-right", "type" => "checkbox", "field_height" => 0, "status" => 0, "mobile_status" => 0, "order" => 920),
    515         );
     515
     516            array("field_name" => "product_name_section", "field_label" => "Product name section", "label_position" => "", "label_width" => $widthLeft, "position" => "product-middle-top", "type" => "product_name_section", "field_height" => 0, "status" => 1, "mobile_status" => 0, "order" => 3000),
     517            );
    516518
    517519
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/Languages.php

    r3335202 r3341654  
    22
    33return array(
     4    "ID" => __("ID", 'us-barcode-scanner'),
    45    "inventory" => __("Inventory", 'us-barcode-scanner'),
    56    "orders" => __("Orders", 'us-barcode-scanner'),
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/features/settings/assets/js/index.js

    r3304735 r3341654  
    258258    } else if (position === "product-middle-bottom") {
    259259      template.find(".usbs_label_width").val("100");
     260    } else if (position === "product-middle-top") {
     261      template.find(".usbs_label_width").val("100");
    260262    }
    261263  });
     
    279281  const fieldsChecker = (e, field) => {
    280282    const type = jQuery(e.target).closest(".settings_field_body").find(".usbs_field_type").val();
     283    const fieldStatusEl = jQuery(e.target).closest(".settings_field_body").find(".usbs_field_status");
     284    const fieldRemoveEl = jQuery(e.target).closest(".settings_field_body").find(".settings_field_remove");
     285    const dashiconsMoveEl = jQuery(e.target).closest(".settings_field_section").find(".dashicons.dashicons-move");
    281286    const positionEl = jQuery(e.target).closest(".settings_field_body").find(".usbs_field_label_position");
    282287    const nameEl = jQuery(e.target).closest(".settings_field_body").find(".usbs_field_name");
     
    291296    const buttonWidthEl = jQuery(e.target).closest(".settings_field_body").find(".button_width");
    292297    const taxonomyEl = jQuery(e.target).closest(".settings_field_body").find(".usbs_taxonomy");
    293 
    294     if (['usbs_wcpbn', 'usbs_webis'].includes(type)) {
     298    const productNameSectionEl = jQuery(e.target).closest(".settings_field_body").find(".product_name_section");
     299    const fieldTypeEl = jQuery(e.target).closest(".settings_field_body").find(".tr_usbs_field_type");
     300
     301    if (['usbs_wcpbn', 'usbs_webis', 'search_section', 'product_name_section'].includes(type)) {
    295302      const elements = jQuery("select.usbs_field_type").filter((index, el) => jQuery(el).val() == type);
     303      const position = jQuery(e.target).closest("[data-position]").attr("data-position");
    296304
    297305      if (elements && elements.length > 1) {
    298306        alert('This type of field already was created!');
    299307        jQuery(e.target).val('text');
     308        jQuery(e.target).change();
     309        return;
     310      } else if (position && position != "product-middle-top") {
     311        alert('You can\'t add this type of field to this position!');
     312        jQuery(e.target).val('text');
     313        jQuery(e.target).change();
    300314        return;
    301315      }
     316    }
     317
     318    fieldTypeEl.removeAttr("style");
     319
     320    if (['search_section', 'product_name_section'].includes(type)) {
     321      fieldRemoveEl.css("display", "none");
     322      dashiconsMoveEl.css("display", "none");
     323    } else {
     324      fieldRemoveEl.removeAttr("style");
     325      dashiconsMoveEl.removeAttr("style");
    302326    }
    303327
     
    413437      if (!["position"].includes(field)) positionEl.change();
    414438    }
     439
     440
     441    if (productNameSectionEl && type == "product_name_section") {
     442      fieldStatusEl.closest("tr").css("display", "none");
     443      heightEl.closest("tr").css("display", "none");
     444      nameEl.closest("tr").css("display", "none");
     445      positionEl.closest("tr").css("display", "none");
     446      showInCreateOrderEl.closest("tr").css("display", "none");
     447      labelEl.closest("tr").css("display", "none");
     448      heightEl.closest("tr").css("display", "none");
     449      labelWidthEl.closest("tr").css("display", "none");
     450      fieldTypeEl.closest("tr").css("display", "none");
     451    }
    415452  };
    416453
     
    474511    stop: WebbsFieldsInitAfterChanges,
    475512    start: function (event, ui) {
     513      if (jQuery(ui.item).hasClass('field_product_name_section')) {
     514        jQuery(this).sortable("option", "revert", false);
     515        setTimeout(() => {
     516          jQuery(this).sortable("cancel");
     517        }, 0);
     518        return;
     519      }
     520
    476521      if (!jQuery(ui.item).find(".edit_java_script_modal").attr("style")) {
    477522        jQuery(this).sortable("option", "revert", false);
     
    486531      }
    487532    },
     533    beforeStop: function (event, ui) {
     534      const $container = jQuery(this);
     535      const $productNameSection = $container.find('.field_product_name_section');
     536
     537      if ($productNameSection.length > 0) {
     538        if ($productNameSection.index() !== 0) {
     539          $container.prepend($productNameSection);
     540        }
     541      }
     542    },
     543    change: function (event, ui) {
     544
     545
     546    },
     547    update: function (event, ui) {
     548      const $container = jQuery(this);
     549      const $productNameSection = $container.find('.field_product_name_section');
     550
     551      if ($productNameSection.length > 0 && $productNameSection.index() !== 0) {
     552        $container.prepend($productNameSection);
     553      }
     554    },
    488555    receive: function (event, ui) {
     556      const $container = jQuery(this);
     557      const $productNameSection = $container.find('.field_product_name_section');
     558
     559      if ($productNameSection.length > 0) {
     560        if ($productNameSection.index() !== 0) {
     561          $container.prepend($productNameSection);
     562        }
     563      }
    489564    },
    490565  });
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/features/settings/views/fields/_mobile.php

    r3304735 r3341654  
    2424            <?php foreach ($interfaceData::getFields(false, "mobile", false, $roleActive, false) as $field) : ?>
    2525                <?php if ($field["type"] == "price") continue; ?>
    26                 <?php if (in_array($field["position"], array("product-middle-left", "product-middle-right", "product-left-sidebar", "product-column-4", "product-middle-bottom"))) {
     26                <?php if (in_array($field["position"], array("product-middle-top", "product-middle-left", "product-middle-right", "product-left-sidebar", "product-column-4", "product-middle-bottom"))) {
    2727                    require __DIR__ . "/field.php";
    2828                } ?>
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/features/settings/views/fields/_web.php

    r3304735 r3341654  
    138138</div>
    139139<!-- end product-column-4 -->
     140 <!-- middle top -->
     141<div style="margin-right: 20px; width: 380px;">
     142    <b><?php echo esc_html__("Middle top fields:", "us-barcode-scanner"); ?></b>
     143    <button type="button" class="settings_field_add_new" data-position="product-middle-top"><?php echo esc_html__("Add new", "us-barcode-scanner"); ?></button>
     144
     145    <div style="height: 10px;"></div>
     146    <table class="form-table wrapper" data-position="product-middle-top" style="min-height: 100px;">
     147        <tbody class="usbs_fields_list_sortable">
     148            <?php foreach ($interfaceData::getFields(false, "", false, $roleActive, false) as $field) : ?>
     149                <?php if ($field["position"] == "product-middle-top") {
     150                    require __DIR__ . "/field.php";
     151                } ?>
     152            <?php endforeach; ?>
     153        </tbody>
     154    </table>
     155</div>
     156<!-- end middle top -->
    140157<!-- middle bottom -->
    141158<div style="width: 380px;">
  • barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/trunk/src/features/settings/views/fields/field.php

    r3304735 r3341654  
    7979                        </tr>
    8080
    81                         <tr>
     81                        <tr class="tr_usbs_field_type">
    8282                            <td scope="row" style="text-align:left; padding: 0 10px 0 10px; width: 110px; box-sizing: border-box;">
    8383                                <?php echo esc_html__("Field type", "us-barcode-scanner"); ?>
     
    112112                                    <?php endif; ?>
    113113                                    <option value="checkbox" <?php echo $field["type"] == "checkbox" ? wp_kses_post("selected='selected'") : ""; ?>><?php echo  esc_html__("Checkbox", "us-barcode-scanner"); ?></option>
     114                                    <!-- <option value="search_section" <?php echo $field["type"] == "search_section" ? wp_kses_post("selected='selected'") : ""; ?>><?php echo  esc_html__("Search section", "us-barcode-scanner"); ?></option> -->
     115                                    <option value="product_name_section" <?php echo $field["type"] == "product_name_section" ? wp_kses_post("selected='selected'") : ""; ?>><?php echo  esc_html__("Product name section", "us-barcode-scanner"); ?></option>
    114116                                </select>
    115117                            </td>
Note: See TracChangeset for help on using the changeset viewer.