Changeset 2636643
- Timestamp:
- 11/29/2021 05:37:29 AM (4 years ago)
- Location:
- agecheckernet/trunk
- Files:
-
- 3 edited
-
agechecker.php (modified) (1 diff)
-
class-wc-integration-agechecker-integration.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
agecheckernet/trunk/agechecker.php
r2628388 r2636643 4 4 Plugin URI: https://agechecker.net 5 5 Description: 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. 26 Version: 1.7.3 7 7 Author: AgeChecker.Net 8 8 Author URI: https://agechecker.net -
agecheckernet/trunk/class-wc-integration-agechecker-integration.php
r2628388 r2636643 69 69 $this->tag_order = $this->get_option('tag_order'); 70 70 $this->set_customer_role = $this->get_option('set_customer_role'); 71 $this->role_find_account = $this->get_option('role_find_account'); 71 72 72 73 // Set settings to version without entity codes. … … 207 208 'title' => 'Set Customer Role', 208 209 'type' => 'selectbox', 209 'description' => 'Add a role to a logged-in customer\'s list of user roles upon accepted verification. (Customers must be logged in to their account for the role to be added)',210 'description' => 'Add a role to a logged-in or newly created customer\'s list of user roles upon accepted verification. (Customers must be logged in to their account for the role to be added)', 210 211 'default' => 'do_not_set_role', 211 212 'list' => 'customer_role', 213 'desc_tip' => false, 214 ), 215 'role_find_account' => array( 216 'type' => 'radio', 217 '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.', 218 'default' => 'false', 212 219 'desc_tip' => false, 213 220 ), … … 354 361 <input type="radio" id="<?php echo esc_attr($field); ?>" name="<?php echo esc_attr($field); ?>" value="head" <?php if($script_location_choice == "head") echo 'checked'; ?>> Head<br> 355 362 <input type="radio" id="<?php echo esc_attr($field); ?>" name="<?php echo esc_attr($field); ?>" value="footer" <?php if($script_location_choice == "footer") echo 'checked'; ?>> Footer<br> 363 <?php 364 } else if($key == "role_find_account") { 365 $find_account_choice = $this->get_option($key); 366 ?> 367 <input type="radio" id="<?php echo esc_attr($field); ?>" name="<?php echo esc_attr($field); ?>" value="true" <?php if($find_account_choice == "true") echo 'checked'; ?>> Attempt to find user account based on guest order details<br> 368 <input type="radio" id="<?php echo esc_attr($field); ?>" name="<?php echo esc_attr($field); ?>" value="false" <?php if($find_account_choice == "false") echo 'checked'; ?>> Only use user accounts associated with orders<br> 356 369 <?php 357 370 } else if($key == "workflow_type") { … … 836 849 $res = json_decode($post['body']); 837 850 if ($res->status == "accepted") { 838 $user = wp_get_current_user();839 if($user && $user->ID !== 0) {840 $this->set_verified_role($user);841 }842 851 return true; 843 852 } else { … … 852 861 public function add_verified_notes( $order_id ) { 853 862 $order = new WC_Order( $order_id ); 863 864 if(!isset($_POST['agechecker_uuid'])) return; 865 866 // Not order tagging logic, but we set this here for before_payment logic 867 // so users that are created after an order is created are correctly set 868 // with the role. 869 if($this->workflow_type == "before_payment") { 870 $this->set_verified_role($order); 871 } 854 872 855 if(isset($ _POST['agechecker_uuid']) && isset($this->tag_order)) {873 if(isset($this->tag_order)) { 856 874 if($this->tag_order == "tag_notes" || $this->tag_order == "tag_both") { 857 875 $note = __("Age Verified order. \n\nAgeChecker UUID: ". $_POST['agechecker_uuid']); … … 1214 1232 public function add_script_afterpayment($order_id) { 1215 1233 $order = new WC_Order($order_id); 1234 1216 1235 if ($this->is_excluded($order->get_items()) || $this->is_shipping_excluded()) { 1217 1236 return; … … 1334 1353 } 1335 1354 1336 public function set_verified_role($user) { 1355 public function set_verified_role($order) { 1356 if($this->set_customer_role == 'do_not_set_role') return; 1357 1358 $user = $order->get_user(); 1359 1337 1360 // Add user role if defined in settings, and user's logged in 1338 if($user && $this->set_customer_role != 'do_not_set_role') { 1361 // Else, try to find a user account if setting is enabled 1362 if($user) { 1339 1363 $user->add_role($this->set_customer_role); 1364 } else if($this->role_find_account == 'true') { 1365 $user = get_user_by('email', $order->get_billing_email()); 1366 1367 if($user) { 1368 if($order->get_billing_first_name() == $user->billing_first_name && 1369 $order->get_billing_last_name() == $user->billing_last_name && 1370 $order->get_billing_address_1() == $user->billing_address_1 && 1371 $order->get_billing_city() == $user->billing_city && 1372 $order->get_billing_state() == $user->billing_state && 1373 $order->get_billing_postcode() == $user->billing_postcode && 1374 $order->get_billing_country() == $user->billing_country) { 1375 $user->add_role($this->set_customer_role); 1376 } 1377 } 1340 1378 } 1341 1379 } … … 1402 1440 $uuid = $body['uuid']; 1403 1441 1442 $status = $body['status']; 1443 1404 1444 $order->update_meta_data('AgeChecker Status', $this->get_status_wording($body) ); 1405 1445 … … 1410 1450 $order->save(); 1411 1451 1412 $this->set_verified_role($order->get_user()); 1452 if(isset($status) && $status == "accepted") { 1453 $this->set_verified_role($order); 1454 } 1413 1455 } 1414 1456 -
agecheckernet/trunk/readme.txt
r2628388 r2636643 4 4 Requires at least: 4.4 5 5 Tested up to: 5.8 6 Stable tag: 1.7. 26 Stable tag: 1.7.3 7 7 8 8 AgeChecker.Net seamlessly and securely verifies the age of your customers directly on your website during the checkout process. … … 62 62 63 63 == Changelog == 64 65 = 1.7.3 = 66 *Release Date - 29 November 2021* 67 68 * Set customer role (if set) to newly created accounts made through guest orders. 69 * Give option to assign roles to existing accounts based on email and billing info from guest order. 64 70 65 71 = 1.7.2 =
Note: See TracChangeset
for help on using the changeset viewer.