Plugin Directory

Changeset 2651450


Ignore:
Timestamp:
12/31/2021 07:09:55 PM (4 years ago)
Author:
agechecker
Message:

Added ability to exclude payment methods from age verification

Location:
agecheckernet
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • agecheckernet/trunk/agechecker.php

    r2636643 r2651450  
    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.7.3
     6Version:     1.8.0
    77Author:      AgeChecker.Net
    88Author URI:  https://agechecker.net
  • agecheckernet/trunk/class-wc-integration-agechecker-integration.php

    r2636643 r2651450  
    5959            $this->groups_mode         = $this->get_option('groups_mode');
    6060            $this->excluded_shipping   = $this->get_option('excluded_shipping');
     61            $this->excluded_payment    = $this->get_option('excluded_payment');
    6162            $this->page                = $this->get_option('page');
    6263            $this->enable_all          = $this->get_option('enable_all');
     
    148149                    'default'     => '',
    149150                    'list'        => 'shipping_methods',
     151                    'desc_tip'    => false,
     152                ),
     153                'excluded_payment'     => array(
     154                    'title'       => 'Exclude Payment Methods',
     155                    'type'        => 'listbox',
     156                    'default'     => '',
     157                    'list'        => 'payment_methods',
    150158                    'desc_tip'    => false,
    151159                ),
     
    428436            }
    429437
     438            $payment_methods = WC()->payment_gateways->payment_gateways();
     439
    430440            ob_start();
    431441
     
    472482                                    foreach ($shipping_methods as $c) {
    473483                                        echo '<option value="' . $c . '">' . $c . '</option>';
     484                                    }
     485                                } else if($data['list'] == "payment_methods") {
     486                                    foreach ($payment_methods as $c) {
     487                                        echo '<option value="' . $c->id . '">' . $c->title . ' (' . $c->id . ') </option>';
    474488                                    }
    475489                                }
     
    771785
    772786        public function validate_order() {
    773             if ($this->workflow_type != "before_payment" || $this->is_excluded(false) || $this->is_shipping_excluded()) {
     787            if ($this->workflow_type != "before_payment" || $this->is_excluded(false) || $this->is_shipping_excluded() || $this->is_payment_excluded()) {
    774788                return true;
    775789            }
     
    923937        }
    924938
     939        public function validate_excluded_payment_field($key) {
     940            $value = $_POST["payment_methodsListData"];
     941            if (!isset($value)) {
     942                ?>
     943                <div class="error notice">
     944                    <p><strong>Invalid payment fields.</strong></p>
     945                </div>
     946                <?php
     947            }
     948
     949            return $value;
     950        }
     951
    925952        public function validate_category_apikeys_field($key) {
    926953            $value = $_POST["categoryApiKeysListData"];
     
    11471174            (function(w,d) {
    11481175            <?php echo $this->before_script; ?>
     1176
    11491177            var config={key:'<?php echo $this->get_api_key(false); ?>',element:'<?php echo $this->element; ?>',name:'<?php echo esc_html($this->store_name); ?>',<?php echo $this->client_config; ?>};
    1150 
    11511178            <?php
    1152             if($this->excluded_shipping != '') {
     1179            $shipping_excluded = $this->excluded_shipping != '';
     1180            $payment_excluded = $this->excluded_payment != '';
     1181            if($shipping_excluded || $payment_excluded) {
    11531182            ?>
     1183
    11541184            if(config.platform_features && config.platform_features.woocommerce) {
    1155                 config.platform_features.woocommerce.shipping_methods = "<?php echo $this->excluded_shipping ?>".split(",");
     1185                <?php
     1186                if($shipping_excluded) {
     1187                    echo "config.platform_features.woocommerce.shipping_methods = \"". $this->excluded_shipping . "\".split(\",\");";
     1188                }
     1189                ?>
     1190
     1191                <?php
     1192                if($payment_excluded) {
     1193                    echo "config.platform_features.woocommerce.payment_methods = \"". $this->excluded_payment . "\".split(\",\");";
     1194                }
     1195                ?>
     1196               
    11561197            } else {
    11571198                config.platform_features = {
    11581199                    woocommerce: {
    1159                         shipping_methods: "<?php echo $this->excluded_shipping ?>".split(",")
     1200                        <?php
     1201                        if($shipping_excluded) {
     1202                            echo "shipping_methods: \"". $this->excluded_shipping ."\".split(\",\"),";
     1203                        }
     1204                        ?>
     1205
     1206                        <?php
     1207                        if($payment_excluded) {
     1208                            echo "payment_methods: \"". $this->excluded_payment ."\".split(\",\"),";
     1209                        }
     1210                        ?>
     1211
    11601212                    }
    11611213                };
     
    12331285            $order = new WC_Order($order_id);
    12341286
    1235             if ($this->is_excluded($order->get_items()) || $this->is_shipping_excluded()) {
     1287            if ($this->is_excluded($order->get_items()) || $this->is_shipping_excluded() || $this->is_payment_excluded()) {
    12361288                return;
    12371289            }
     
    12661318                                return true;
    12671319                            }
     1320                        }
     1321                    }
     1322                }
     1323            }
     1324
     1325            return false;
     1326        }
     1327
     1328        public function is_payment_excluded() {
     1329            $excluded_payment_methods = explode(",", $this->excluded_payment);
     1330
     1331            if (!(sizeof($excluded_payment_methods) == 1 && $excluded_payment_methods[0] == "")) {
     1332                $chosen_method = WC()->session->get('chosen_payment_method');
     1333                if($chosen_method) {
     1334                    foreach ($excluded_payment_methods as $c) {
     1335                        if ($chosen_method == $c) {
     1336                            return true;
    12681337                        }
    12691338                    }
  • agecheckernet/trunk/readme.txt

    r2636643 r2651450  
    44Requires at least: 4.4
    55Tested up to: 5.8
    6 Stable tag: 1.7.3
     6Stable tag: 1.8.0
    77
    88AgeChecker.Net seamlessly and securely verifies the age of your customers directly on your website during the checkout process.
     
    6262
    6363== Changelog ==
     64
     65= 1.8.0 =
     66*Release Date - 31 December 2021*
     67
     68* Added ability to exclude payment methods from age verification
    6469
    6570= 1.7.3 =
Note: See TracChangeset for help on using the changeset viewer.