Plugin Directory

Changeset 2841634


Ignore:
Timestamp:
12/30/2022 06:31:41 PM (3 years ago)
Author:
agechecker
Message:
  • Updates how product categories are stored internally in the "Exclude/Include Categories" section.
Location:
agecheckernet
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • agecheckernet/trunk/agechecker.php

    r2815496 r2841634  
    44Plugin URI:  https://agechecker.net
    55Description: AgeChecker.Net seamlessly and securely verifies the age of your customers directly on your website during the checkout process. Keep your site up to date on the latest age regulations for your industry while ensuring that purchasing is frustration-free for your site users.
    6 Version:     1.13.4
     6Version:     1.14.0
    77Author:      AgeChecker.Net
    88Author URI:  https://agechecker.net
  • agecheckernet/trunk/class-wc-integration-agechecker-integration.php

    r2815493 r2841634  
    495495        }
    496496
     497        public function product_name_from_value($value, $product_categories) {
     498            if (substr($value, 0, 6) == "\$_ID_=") {
     499                $id = substr($value, 6, strlen($value));
     500                foreach ($product_categories as $c) {
     501                    if($c->term_id == $id) {
     502                        return $c->name;
     503                    }
     504                }
     505            } else {
     506                return $value;
     507            }
     508        }
     509
    497510        public function generate_listbox_html($key, $data) {
    498511            $field              = $this->plugin_id . $this->id . '_' . $key;
    499512            $product_categories = get_terms('product_cat');
    500 
    501513
    502514            $roles = array();
     
    539551                                if ($this->get_option($key) != "" && sizeof(explode(",", $this->get_option($key))) != 0) {
    540552                                    foreach (explode(",", $this->get_option($key)) as $c) {
    541                                         echo '<option value="' . $c . '">' . $c . '</option>';
     553                                        if ($data['list'] == "categories") {
     554                                            echo '<option value="' . $c . '">' . $this->product_name_from_value($c, $product_categories) . '</option>';
     555                                        }
     556                                        else {
     557                                            echo '<option value="' . $c . '">' . $c . '</option>';
     558                                        }
    542559                                    }
    543560                                }
     
    555572                                if ($data['list'] == "categories") {
    556573                                    foreach ($product_categories as $c) {
    557                                         echo '<option value="' . $c->name . '">' . $c->name . '</option>';
     574                                        echo '<option value="$_ID_=' . $c->term_id . '">' . $c->name . '</option>';
    558575                                    }
    559576                                } else if($data['list'] == "roles") {
     
    572589                                ?>
    573590                            </select>
    574                             <button onclick="var exists = false; for(var i=0;i<document.getElementById('<?php echo esc_attr($field); ?>').options.length;i++) if(!document.getElementById('<?php echo $data['list']; ?>Input').value || document.getElementById('<?php echo esc_attr($field); ?>').options[i].value == document.getElementById('<?php echo $data['list']; ?>Input').value) exists = true; if(!exists) { var x = document.createElement('option'); x.text = document.getElementById('<?php echo $data['list']; ?>Input').value; document.getElementById('<?php echo esc_attr($field); ?>').add(x); } var data = ''; for(var i=0;i<document.getElementById('<?php echo esc_attr($field); ?>').options.length;i++) data += (i != 0 ? ',' : '') + document.getElementById('<?php echo esc_attr($field); ?>').options[i].value; document.getElementById('<?php echo $data['list']; ?>ListData').value = data;"
     591                            <button onclick="var exists = false; for(var i=0;i<document.getElementById('<?php echo esc_attr($field); ?>').options.length;i++) if(!document.getElementById('<?php echo $data['list']; ?>Input').value || document.getElementById('<?php echo esc_attr($field); ?>').options[i].value == document.getElementById('<?php echo $data['list']; ?>Input').value) exists = true; if(!exists) { var x = document.createElement('option'); x.value = document.getElementById('<?php echo $data['list']; ?>Input').value; x.text = document.getElementById('<?php echo $data['list']; ?>Input').value.indexOf('$_ID_') != -1 ? document.getElementById('<?php echo $data['list']; ?>Input').options[document.getElementById('<?php echo $data['list']; ?>Input').selectedIndex].textContent : document.getElementById('<?php echo $data['list']; ?>Input').value; document.getElementById('<?php echo esc_attr($field); ?>').add(x); } var data = ''; for(var i=0;i<document.getElementById('<?php echo esc_attr($field); ?>').options.length;i++) data += (i != 0 ? ',' : '') + document.getElementById('<?php echo esc_attr($field); ?>').options[i].value; document.getElementById('<?php echo $data['list']; ?>ListData').value = data;"
    575592                                    class="button-secondary" type="button"
    576593                                    style="<?php if(array_key_exists("css", $data)) echo esc_attr($data['css']); ?>" <?php echo $this->get_custom_attribute_html($data); ?>>
     
    16771694            $categories = explode(",", $this->excluded_categories);
    16781695
     1696            $product_categories = get_terms('product_cat');
     1697
    16791698            if (!(sizeof($categories) == 1 && $categories[0] == "")) {
    16801699                $cart_items = $order_items;
     
    16891708                        $noExclude = true;
    16901709                        foreach ($categories as $c) {
    1691                             if (has_term($c, 'product_cat', $prod_id)) {
     1710                            $cat = $this->product_name_from_value($c, $product_categories);
     1711                            if (has_term($cat, 'product_cat', $prod_id)) {
    16921712                                $noExclude = false;
    16931713                                break;
     
    17051725                        $noExclude = false;
    17061726                        foreach ($categories as $c) {
    1707                             if (has_term($c, 'product_cat', $prod_id)) {
     1727                            $cat = $this->product_name_from_value($c, $product_categories);
     1728                            if (has_term($cat, 'product_cat', $prod_id)) {
    17081729                                $noExclude = true;
    17091730                                break;
  • agecheckernet/trunk/readme.txt

    r2815496 r2841634  
    44Requires at least: 4.4
    55Tested up to: 6.1
    6 Stable tag: 1.13.4
     6Stable tag: 1.14.0
    77
    88AgeChecker.Net seamlessly and securely verifies the age of your customers directly on your website during the checkout process.
     
    6363== Changelog ==
    6464
     65= 1.14.0 =
     66*Release Date - 30 December 2022*
     67
     68* Updates how product categories are stored internally in the "Exclude/Include Categories" section. Although the old internal format is backwards compatible with this version, it is recommended to do the following so the categories are stored in the new format:
     69
     70  1. Take a screenshot or write down every product category you have added to "Exclude/Include Categories"
     71  2. Remove all categories from the "Exclude/Include Categories" list
     72  3. Add back the categories
     73  4. Save settings
     74
    6575= 1.13.4 =
    6676*Release Date - 9 November 2022*
Note: See TracChangeset for help on using the changeset viewer.