Plugin Directory

Changeset 2737166


Ignore:
Timestamp:
06/03/2022 09:30:49 PM (4 years ago)
Author:
agechecker
Message:
  • After-Payment workflow: Add ability to automatically set order status depending on verification result
  • After-Payment workflow: CSS adjustments on order list for verification statuses
Location:
agecheckernet
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • agecheckernet/trunk/agechecker.php

    r2725650 r2737166  
    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.10.0
     6Version:     1.11.0
    77Author:      AgeChecker.Net
    88Author URI:  https://agechecker.net
  • agecheckernet/trunk/class-wc-integration-agechecker-integration.php

    r2725650 r2737166  
    5454            $this->element             = $this->get_option('element');
    5555            $this->workflow_type       = $this->get_option('workflow_type');
     56            $this->set_status_pending  = $this->get_option('set_status_pending');
     57            $this->set_status_accepted = $this->get_option('set_status_accepted');
     58            $this->set_status_denied   = $this->get_option('set_status_denied');
     59            $this->set_status_disabled = $this->get_option('set_status_disabled');
     60            $this->set_status_blocked  = $this->get_option('set_status_blocked');
    5661            $this->excluded_categories = $this->get_option('excluded_categories');
    5762            $this->categories_mode     = $this->get_option('categories_mode');
     
    9196                    'desc_tip'    => false,
    9297                ),
    93                 'workflow_type'             => array(
     98                'workflow_type'   => array(
    9499                    'title'       => 'Verification Workflow Type',
    95100                    'type'        => 'radio',
     
    98103                    'desc_tip'    => false,
    99104                ),
    100                 'key'                 => array(
     105                'key'             => array(
    101106                    'title'       => 'API Key',
    102107                    'type'        => 'text',
     
    112117                    'desc_tip'    => false,
    113118                ),
    114                 'store_name'          => array(
     119                'store_name'      => array(
    115120                    'title'       => 'Store Name',
    116121                    'type'        => 'text',
     
    119124                    'desc_tip'    => false,
    120125                ),
    121                 'element'             => array(
     126                'element'         => array(
    122127                    'title'       => 'Element',
    123128                    'type'        => 'text',
    124129                    'description' => 'Element selector to attach the popup event to when using the "Before Payment" workflow. You may need to change this if you use a custom theme/template. Please contact us if the popup is not showing when the element is clicked. The default element is the final checkout button.',
    125130                    'default'     => '#place_order',
     131                    'desc_tip'    => false,
     132                ),
     133                'set_status_pending' => array(
     134                    'title'       => 'Set Order Status when Verification is Pending',
     135                    'type'        => 'selectbox',
     136                    'description' => 'Change the status of an order when a verification is <i>pending</i>. (Such as waiting for photo ID submission or e-signature, or no verification has been performed at all yet) AgeChecker will not set the order status if set to "None".',
     137                    'default'     => 'do_not_set_status',
     138                    'list'        => 'order_status_pending',
     139                    'desc_tip'    => false,
     140                ),
     141                'set_status_accepted' => array(
     142                    'title'       => 'Set Order Status when Verification is Accepted',
     143                    'type'        => 'selectbox',
     144                    'description' => 'Change the status of an order when a verification is <i>accepted</i>. AgeChecker will not set the order status if set to "None".',
     145                    'default'     => 'do_not_set_status',
     146                    'list'        => 'order_status_accepted',
     147                    'desc_tip'    => false,
     148                ),
     149                'set_status_denied' => array(
     150                    'title'       => 'Set Order Status when Verification is Denied',
     151                    'type'        => 'selectbox',
     152                    'description' => 'Change the status of an order when a verification is <i>denied</i>. AgeChecker will not set the order status if set to "None".',
     153                    'default'     => 'do_not_set_status',
     154                    'list'        => 'order_status_denied',
     155                    'desc_tip'    => false,
     156                ),
     157                'set_status_disabled' => array(
     158                    'title'       => 'Set Order Status when Verification is Disabled at Customer\'s Location',
     159                    'type'        => 'selectbox',
     160                    'description' => 'Change the status of an order when a verification is disabled and not needed at customer\'s location. AgeChecker will not set the order status if set to "None".',
     161                    'default'     => 'do_not_set_status',
     162                    'list'        => 'order_status_disabled',
     163                    'desc_tip'    => false,
     164                ),
     165                'set_status_blocked' => array(
     166                    'title'       => 'Set Order Status when Verification is Blocked at Customer\'s Location',
     167                    'type'        => 'selectbox',
     168                    'description' => 'Change the status of an order when a verification is blocked due to customer\'s location. AgeChecker will not set the order status if set to "None".',
     169                    'default'     => 'do_not_set_status',
     170                    'list'        => 'order_status_blocked',
    126171                    'desc_tip'    => false,
    127172                ),
     
    134179                    'desc_tip'    => false,
    135180                ),
    136                 'categories_mode'             => array(
     181                'categories_mode' => array(
    137182                    'type'        => 'radio',
    138183                    'default'     => 'exclude',
     
    140185                    'desc_tip'    => false,
    141186                ),
    142                 'excluded_groups'     => array(
     187                'excluded_groups' => array(
    143188                    'title'       => 'Exclude/Include Groups',
    144189                    'type'        => 'listbox',
     
    147192                    'desc_tip'    => false,
    148193                ),
    149                 'groups_mode'             => array(
     194                'groups_mode'     => array(
    150195                    'type'        => 'radio',
    151196                    'default'     => 'exclude',
     
    153198                    'desc_tip'    => false,
    154199                ),
    155                 'excluded_shipping'     => array(
     200                'excluded_shipping'  => array(
    156201                    'title'       => 'Exclude Shipping Methods',
    157202                    'type'        => 'listbox',
     
    160205                    'desc_tip'    => false,
    161206                ),
    162                 'excluded_payment'     => array(
     207                'excluded_payment' => array(
    163208                    'title'       => 'Exclude Payment Methods',
    164209                    'type'        => 'listbox',
     
    167212                    'desc_tip'    => false,
    168213                ),
    169                 'min_total'     => array(
     214                'min_total'       => array(
    170215                    'title'       => 'Minimum Total',
    171216                    'type'        => 'text',
     
    174219                    'desc_tip'    => false,
    175220                ),
    176                 'page'                => array(
     221                'page'            => array(
    177222                    'title'       => 'Page',
    178223                    'type'        => 'text',
     
    181226                    'desc_tip'    => false,
    182227                ),
    183                 'enable_all'           => array(
     228                'enable_all'      => array(
    184229                    'title'       => 'Enable on All Pages',
    185230                    'type'        => 'radio',
     
    188233                    'desc_tip'    => false,
    189234                ),
    190                 'script_location'           => array(
     235                'script_location' => array(
    191236                    'title'       => 'Script Location',
    192237                    'type'        => 'radio',
     
    195240                    'desc_tip'    => false,
    196241                ),
    197                 'category_apikeys'     => array(
     242                'category_apikeys' => array(
    198243                    'title'       => 'Category Specific API Keys (Advanced)',
    199244                    'type'        => 'apikeys_listbox',
     
    201246                    'desc_tip'    => false,
    202247                ),
    203                 'apikeys_list'     => array(
     248                'apikeys_list'    => array(
    204249                    'type'        => 'ordered_listbox',
    205250                    'default'     => 'default_api_key',
     
    208253                    'desc_tip'    => false,
    209254                ),
    210                 'client_config'       => array(
     255                'client_config'   => array(
    211256                    'title'       => 'Additional Config (Advanced)',
    212257                    'type'        => 'textarea',
     
    215260                    'css'         => 'width: 400px'
    216261                ),
    217                 'before_script'       => array(
     262                'before_script'   => array(
    218263                    'title'       => 'Before Load Script (Advanced)',
    219264                    'type'        => 'textarea',
     
    222267                    'css'         => 'width: 400px'
    223268                ),
    224                 'tag_order'           => array(
     269                'tag_order'       => array(
    225270                    'title'       => 'Tag Orders',
    226271                    'type'        => 'radio',
     
    229274                    'desc_tip'    => false,
    230275                ),
    231                 'set_customer_role'           => array(
     276                'set_customer_role' => array(
    232277                    'title'       => 'Set Customer Role',
    233278                    'type'        => 'selectbox',
     
    237282                    'desc_tip'    => false,
    238283                ),
    239                 'role_find_account'           => array(
     284                'role_find_account' => array(
    240285                    'type'        => 'radio',
    241286                    'description' => 'If first option is enabled, a user\'s account will be attempted to be found based on a guest order\'s email and billing details. If matching, the role will be applied to the found user account.',
     
    243288                    'desc_tip'    => false,
    244289                ),
    245                 'enable_noscript'           => array(
     290                'enable_noscript' => array(
    246291                    'title'       => 'Redirect users if Javascript is disabled',
    247292                    'type'        => 'radio',
     
    256301            $field = $this->plugin_id . $this->id . '_' . $key;
    257302
    258             $roles = array();
    259             foreach (get_editable_roles() as $role_name => $role_info) {
    260                 $roles[] = $role_name;
     303            $array = array();
     304            $default = "";
     305
     306            if($key == "set_customer_role") {
     307                $default = "do_not_set_role";
     308                foreach (get_editable_roles() as $role_name => $role_info) {
     309                    $array[$role_name] = $role_name;
     310                }
     311            } else if(substr($key, 0, strlen("set_status_")) === "set_status_")  {
     312                $default = "do_not_set_status";
     313                $order_statuses = wc_get_order_statuses();
     314 
     315                foreach ($order_statuses as $status_tag => $status_name) {
     316                  $array[$status_tag] = $status_name;
     317                }
    261318            }
    262319
     
    275332                        <p>
    276333                            <select id="<?php echo $data['list']; ?>Input" name="<?php echo $data['list']; ?>Input">
    277                                 <option value="do_not_set_role" <?php echo ($this->get_option($key) === "do_not_set_role" ? "selected" : ""); ?>>None</option>
     334                                <option value="<?php echo $default; ?>" <?php echo ($this->get_option($key) === $default ? "selected" : ""); ?>>None</option>
    278335                                <?php
    279                                     foreach ($roles as $c) {
    280                                         echo '<option value="' . $c . '" '. ($this->get_option($key) === $c ? "selected" : "") .'>' . $c . '</option>';
     336                                    foreach ($array as $k => $c) {
     337                                        echo '<option value="' . $k . '" '. ($this->get_option($key) === $k ? "selected" : "") .'>' . $c . '</option>';
    281338                                    }
    282339                                ?>
     
    297354                const beforePaymentFields = ["[name='woocommerce_integration-agechecker_element']", "#woocommerce_integration-agechecker_enable_all",
    298355                "#woocommerce_integration-agechecker_script_location", "#woocommerce_integration-agechecker_tag_order", "#woocommerce_integration-agechecker_page"];
    299                 const afterPaymentFields = ["[for='woocommerce_integration-agechecker_secret']"];
     356                const afterPaymentFields = ["[for='woocommerce_integration-agechecker_secret']", "#order_status_pendingInput", "#order_status_acceptedInput", "#order_status_deniedInput",
     357                "#order_status_disabledInput", "#order_status_blockedInput"];
    300358
    301359                function changeWorkflow(sel) {
     
    847905        function add_order_status_column_style() {
    848906            $css = '.agechecker_status
    849             { padding: 2px 6px; border-radius: 4px; text-align: center; width: 18ch; }
     907            { padding: 2px 6px; border-radius: 4px; text-align: center; max-width: 18ch; }
    850908            .agechecker_status--accepted { background-color: #c6e1c6; }
    851909            .agechecker_status--denied { background-color: #e9b7b7; }
     
    9701028            $order = new WC_Order( $order_id );
    9711029
     1030            // Set pending order status for after payment workflow is available
     1031            if($this->workflow_type == "after_payment" && $this->set_status_pending != "do_not_set_status") {
     1032                $order->update_status($this->set_status_pending);
     1033            }
     1034
    9721035            if(!isset($_POST['agechecker_uuid'])) return;
    9731036           
     
    10001063                </div>
    10011064                <?php
     1065                return $this->get_option($key);
    10021066            }
    10031067
     
    10131077                </div>
    10141078                <?php
     1079                return $this->get_option($key);
    10151080            }
    10161081
     
    10261091                </div>
    10271092                <?php
     1093                return $this->get_option($key);
    10281094            }
    10291095
     
    10391105                </div>
    10401106                <?php
     1107                return $this->get_option($key);
    10411108            }
    10421109
     
    10661133                </div>
    10671134                <?php
     1135                return $this->get_option($key);
    10681136            }
    10691137
     
    10791147                </div>
    10801148                <?php
     1149                return $this->get_option($key);
    10811150            }
    10821151
     
    10941163                </div>
    10951164                <?php
     1165                return $this->get_option($key);
    10961166            }
    10971167
     
    11071177                </div>
    11081178                <?php
     1179                return $this->get_option($key);
     1180            }
     1181
     1182            return $value;
     1183        }
     1184
     1185        public function validate_set_status_pending_field($key) {
     1186            $value = $_POST["order_status_pendingInput"];
     1187            if (!isset($value)) {
     1188                ?>
     1189                <div class="error notice">
     1190                    <p><strong>Invalid order status for "Set Order Status When Verification is Pending".</strong></p>
     1191                </div>
     1192                <?php
     1193                return $this->get_option($key);
     1194            }
     1195
     1196            return $value;
     1197        }
     1198
     1199        public function validate_set_status_accepted_field($key) {
     1200            $value = $_POST["order_status_acceptedInput"];
     1201            if (!isset($value)) {
     1202                ?>
     1203                <div class="error notice">
     1204                    <p><strong>Invalid order status for "Set Order Status When Verification is Accepted".</strong></p>
     1205                </div>
     1206                <?php
     1207                return $this->get_option($key);
     1208            }
     1209
     1210            return $value;
     1211        }
     1212
     1213        public function validate_set_status_denied_field($key) {
     1214            $value = $_POST["order_status_deniedInput"];
     1215            if (!isset($value)) {
     1216                ?>
     1217                <div class="error notice">
     1218                    <p><strong>Invalid order status for "Set Order Status When Verification is Denied".</strong></p>
     1219                </div>
     1220                <?php
     1221                return $this->get_option($key);
     1222            }
     1223
     1224            return $value;
     1225        }
     1226
     1227        public function validate_set_status_disabled_field($key) {
     1228            $value = $_POST["order_status_disabledInput"];
     1229            if (!isset($value)) {
     1230                ?>
     1231                <div class="error notice">
     1232                    <p><strong>Invalid order status for "Set Order Status when Verification is Disabled at Customer's Location".</strong></p>
     1233                </div>
     1234                <?php
     1235                return $this->get_option($key);
     1236            }
     1237
     1238            return $value;
     1239        }
     1240
     1241        public function validate_set_status_blocked_field($key) {
     1242            $value = $_POST["order_status_blockedInput"];
     1243            if (!isset($value)) {
     1244                ?>
     1245                <div class="error notice">
     1246                    <p><strong>Invalid order status for "Set Order Status when Verification is Blocked at Customer's Location".</strong></p>
     1247                </div>
     1248                <?php
     1249                return $this->get_option($key);
    11091250            }
    11101251
     
    13511492            $order = new WC_Order($order_id);
    13521493
     1494            $status = $order->get_meta('AgeChecker Status');
     1495            if(!empty($status)) {
     1496                $status = strip_tags(trim(substr($status, 0, strpos($status, "-"))));
     1497                if($status != "Denied" && $status != "Photo ID Required" && $status != "Signature Required") {
     1498                    return;
     1499                }
     1500            }
     1501
    13531502            if($this->enable_noscript == "enable_noscript") {
    13541503            ?>
     
    16551804            $order->save();
    16561805
    1657             if(isset($status) && $status == "accepted") {
    1658                 $this->set_verified_role($order);
     1806            if(isset($status)) {
     1807                if($status == "accepted") {
     1808                    if($this->set_status_accepted != "do_not_set_status") {
     1809                        $order->update_status($this->set_status_accepted);
     1810                    }
     1811
     1812                    $this->set_verified_role($order);
     1813                } else if($status == "denied") {
     1814                    if($this->set_status_denied != "do_not_set_status") {
     1815                        $order->update_status($this->set_status_denied);
     1816                    }
     1817                } else if($status == "photo_id" || $status == "signature") {
     1818                    if($this->set_status_pending != "do_not_set_status") {
     1819                        $order->update_status($this->set_status_pending);
     1820                    }
     1821                } else if($status == "not_created") {
     1822                    $reason = $body['reason'];
     1823                    if($reason == 'location_blocked') {
     1824                        if($this->set_status_blocked != "do_not_set_status") {
     1825                            $order->update_status($this->set_status_blocked);
     1826                        }
     1827                    } else if($reason == 'verification_disabled') {
     1828                        if($this->set_status_disabled != "do_not_set_status") {
     1829                            $order->update_status($this->set_status_disabled);
     1830                        }
     1831                    }
     1832                }
    16591833            }
    16601834        }
  • agecheckernet/trunk/readme.txt

    r2725650 r2737166  
    44Requires at least: 4.4
    55Tested up to: 5.8
    6 Stable tag: 1.10.0
     6Stable tag: 1.11.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.11.0 =
     66*Release Date - 3 June 2022*
     67
     68* After-Payment workflow: Add ability to automatically set order status depending on verification result
     69* After-Payment workflow: CSS adjustments on order list for verification statuses
    6470
    6571= 1.10.0 =
Note: See TracChangeset for help on using the changeset viewer.