PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / trunk
WCPOS – Point of Sale (POS) plugin for WooCommerce vtrunk
1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 All 166 releases
woocommerce-pos / includes / Admin / Products / templates / post-metabox-visibility-select.php

post-metabox-visibility-select.php in WCPOS – Point of Sale (POS) plugin for WooCommerce trunk, at includes/Admin/Products/templates/post-metabox-visibility-select.php

99 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin View: Product Metabox.
4 *
5 * @package WCPOS\WooCommercePOS
6 */
7
8 if ( ! \defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Variables passed from Single_Product::post_submitbox_misc_actions().
14 *
15 * @var \WCPOS\WooCommercePOS\Admin\Products\Single_Product $this
16 * @var string $selected
17 */
18 ?>
19
20 <div class="misc-pub-section" id="pos-visibility">
21 <?php /* translators: Product POS visibility or barcode label in WooCommerce admin. */ esc_html_e( 'POS visibility', 'woocommerce-pos' ); ?>:
22 <strong id="pos-visibility-display"><?php echo esc_html( $this->options[ $selected ] ); // @phpstan-ignore-line ?></strong>
23 <a href="#pos-visibility" id="pos-visibility-show" class="hide-if-no-js"
24 style="display: inline;">
25 <?php
26 // translators: Link text for editing product POS visibility in the WooCommerce product publish box.
27 esc_html_e( 'Edit', 'woocommerce-pos' );
28 ?>
29 </a>
30
31 <div id="pos-visibility-select" class="hide-if-js" style="display: none;">
32 <?php
33 foreach ( $this->options as $value => $label ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- @phpstan-ignore-line
34 $checked = $value == $selected ? 'checked="checked"' : ''; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
35 ?>
36 <label style="display:block;margin: 5px 0;">
37 <input type="radio" name="_pos_visibility"
38 value="<?php echo esc_attr( $value ); ?>" <?php echo esc_attr( $checked ); ?>> <?php echo esc_html( $label ); ?>
39 </label>
40 <?php } ?>
41 <p>
42 <a href="#pos-visibility" id="pos-visibility-save"
43 class="hide-if-no-js button">
44 <?php
45 // translators: Button text confirming product POS visibility changes in the WooCommerce product publish box.
46 esc_html_e( 'OK', 'woocommerce-pos' );
47 ?>
48 </a>
49 <a href="#pos-visibility" id="pos-visibility-cancel"
50 class="hide-if-no-js">
51 <?php
52 // translators: Link text cancelling product POS visibility changes in the WooCommerce product publish box.
53 esc_html_e( 'Cancel', 'woocommerce-pos' );
54 ?>
55 </a>
56 </p>
57 </div>
58 <script>
59 (function () {
60 const display = document.getElementById('pos-visibility-display'),
61 show = document.getElementById('pos-visibility-show'),
62 select = document.getElementById('pos-visibility-select'),
63 cancel = document.getElementById('pos-visibility-cancel'),
64 save = document.getElementById('pos-visibility-save');
65
66 let current = document.querySelector('input[name="_pos_visibility"]:checked');
67
68 function toggleSelect() {
69 select.style.display = select.style.display === 'none' ? 'block' : 'none';
70 show.style.display = show.style.display === 'none' ? 'block' : 'none';
71 }
72
73 function updateDisplay() {
74 const val = current.parentNode.textContent;
75 display.textContent = val;
76 }
77
78 show.addEventListener('click', function (e) {
79 e.preventDefault();
80 toggleSelect();
81 });
82
83 cancel.addEventListener('click', function (e) {
84 e.preventDefault();
85 current.checked = true;
86 updateDisplay();
87 toggleSelect();
88 });
89
90 save.addEventListener('click', function (e) {
91 e.preventDefault();
92 current = document.querySelector('input[name="_pos_visibility"]:checked');
93 updateDisplay();
94 toggleSelect();
95 });
96 })();
97 </script>
98 </div>
99