Changeset 3015266
- Timestamp:
- 12/28/2023 10:54:34 PM (2 years ago)
- Location:
- agecheckernet
- Files:
-
- 4 added
- 3 edited
-
tags/1.16.0 (added)
-
tags/1.16.0/agechecker.php (added)
-
tags/1.16.0/class-wc-integration-agechecker-integration.php (added)
-
tags/1.16.0/readme.txt (added)
-
trunk/agechecker.php (modified) (1 diff)
-
trunk/class-wc-integration-agechecker-integration.php (modified) (13 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
agecheckernet/trunk/agechecker.php
r2986427 r3015266 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.1 5.36 Version: 1.16.0 7 7 Author: AgeChecker.Net 8 8 Author URI: https://agechecker.net -
agecheckernet/trunk/class-wc-integration-agechecker-integration.php
r2986427 r3015266 37 37 add_action('woocommerce_checkout_process', array( 38 38 $this, 39 'validate_order '39 'validate_order_shortcode' 40 40 )); 41 // Add hook for WooCommerce Block Checkout 42 add_action('woocommerce_store_api_checkout_update_order_from_request', array( 43 $this, 44 'validate_order_blocks' 45 ), 10, 2); 41 46 add_action( 'woocommerce_new_order', array( 42 47 $this, 43 ' add_verified_notes'48 'new_order' 44 49 )); 45 50 add_action( 'rest_api_init', array( … … 133 138 'type' => 'text', 134 139 '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.', 135 'default' => '#place_order ',140 'default' => '#place_order,.wc-block-components-checkout-place-order-button', 136 141 'desc_tip' => false, 137 142 ), … … 1038 1043 } 1039 1044 1040 public function validate_order() { 1041 if ($this->workflow_type != "before_payment" || $this->is_excluded(false) || $this->is_total_excluded(false) || $this->is_shipping_excluded() || $this->is_payment_excluded()) { 1045 public function validate_order_blocks($order, $request) { 1046 $chosenPayment = ""; 1047 if(isset($order) && isset($order->payment_method)) { 1048 $chosenPayment = $order->payment_method; 1049 } 1050 1051 if ($this->is_before_excluded($chosenPayment)) { 1042 1052 return true; 1043 1053 } 1044 1054 1055 $uuid = ""; 1056 if(isset($request)) { 1057 $body = $request->get_body(); 1058 if(isset($body)) { 1059 $post = json_decode($body); 1060 if(isset($post->extensions)) { 1061 $extensions = $post->extensions; 1062 if(isset($extensions->agecheckernet_checkout) && isset($extensions->agecheckernet_checkout->agechecker_uuid)) { 1063 $uuid = $extensions->agecheckernet_checkout->agechecker_uuid; 1064 } 1065 } 1066 } 1067 } 1068 $this->validate_order($uuid); 1069 $this->add_verified_notes($order, $uuid); 1070 } 1071 1072 public function validate_order_shortcode() { 1073 if ($this->is_before_excluded($_POST["payment_method"])) { 1074 return true; 1075 } 1076 1077 $this->validate_order($_POST["agechecker_uuid"]); 1078 } 1079 1080 public function validate_order($uuid) { 1045 1081 // Check custom form trigger 1046 1082 if (!empty($this->get_option("form_trigger_name")) && !empty($this->get_option("form_trigger_value"))) { … … 1053 1089 } 1054 1090 } 1055 1056 $uuid = $_POST["agechecker_uuid"];1057 1091 1058 1092 // In order to work around Google Pay or Apple Pay from the WooCommerce Square plugin, we check if … … 1108 1142 } else { 1109 1143 if (!isset($uuid) || strlen($uuid) != 32) { 1110 wc_add_notice('You must complete the age verification process! Need help? Contact help@agechecker.net or try using another device or browser. (Error WP201)', 'error');1144 throw new Exception('You must complete the age verification process! Need help? Contact help@agechecker.net or try using another device or browser. (Error WP201)'); 1111 1145 } else { 1112 1146 $req = json_encode(array( … … 1124 1158 )); 1125 1159 if (is_wp_error($post)) { 1126 wc_add_notice('The age verification service could not verify you at this time. Need help? Contact help@agechecker.net. (Error WP203)', 'error');1160 throw new Exception('The age verification service could not verify you at this time. Need help? Contact help@agechecker.net. (Error WP203)'); 1127 1161 } else { 1128 1162 $res = json_decode($post['body']); … … 1130 1164 return true; 1131 1165 } else { 1132 wc_add_notice('You have not been approved by the age verification process! Need help? Contact help@agechecker.net. (Error WP205)' . $res->status, 'error');1166 throw new Exception('You have not been approved by the age verification process! Need help? Contact help@agechecker.net. (Error WP205)'); 1133 1167 } 1134 1168 } … … 1138 1172 } 1139 1173 1140 public function add_verified_notes( $order_id ) { 1174 public function is_before_excluded($chosenPayment) { 1175 if ($this->workflow_type != "before_payment" || $this->is_excluded(false) || $this->is_total_excluded(false) || $this->is_shipping_excluded(null) || $this->is_payment_excluded($chosenPayment)) { 1176 return true; 1177 } else { 1178 return false; 1179 } 1180 } 1181 1182 public function new_order( $order_id ) { 1141 1183 $order = new WC_Order( $order_id ); 1142 1184 1143 1185 if(!isset($_POST['agechecker_uuid'])) return; 1186 1187 $uuid = $_POST['agechecker_uuid']; 1188 1189 $this->add_verified_notes($order, $uuid); 1190 } 1191 1192 public function add_verified_notes( $order, $uuid ) { 1193 if(!isset($uuid)) return; 1144 1194 1145 1195 // Not order tagging logic, but we set this here for before_payment logic … … 1152 1202 if(isset($this->tag_order)) { 1153 1203 if($this->tag_order == "tag_notes" || $this->tag_order == "tag_both") { 1154 $note = __("Age Verified order. \n\nAgeChecker UUID: ". $ _POST['agechecker_uuid']);1204 $note = __("Age Verified order. \n\nAgeChecker UUID: ". $uuid); 1155 1205 $order->add_order_note( $note ); 1156 1206 } 1157 1207 if($this->tag_order == "tag_fields" || $this->tag_order == "tag_both") { 1158 $order->update_meta_data( 'Age Verified', 'AgeChecker UUID: '. $ _POST['agechecker_uuid']);1208 $order->update_meta_data( 'Age Verified', 'AgeChecker UUID: '. $uuid ); 1159 1209 } 1160 1210 } … … 1720 1770 $order = new WC_Order($order_id); 1721 1771 1722 if ($this->is_excluded($order->get_items()) || $this->is_total_excluded($order->get_total()) || $this->is_shipping_excluded() || $this->is_payment_excluded()) { 1772 $shipping_methods = array(); 1773 foreach ( $order->get_shipping_methods() as $shipping_method ) { 1774 $shipping_methods[] = $shipping_method->get_method_id() . ":" . $shipping_method->get_instance_id(); 1775 } 1776 1777 if ($this->is_excluded($order->get_items()) || $this->is_total_excluded($order->get_total()) || $this->is_shipping_excluded($shipping_methods) || $this->is_payment_excluded($order->get_payment_method())) { 1723 1778 return; 1724 1779 } … … 1739 1794 } 1740 1795 1741 public function is_shipping_excluded( ) {1796 public function is_shipping_excluded($chosen_methods) { 1742 1797 $excluded_shipping_methods = explode(",", $this->excluded_shipping); 1743 1798 1744 1799 if (!(sizeof($excluded_shipping_methods) == 1 && $excluded_shipping_methods[0] == "")) { 1800 if($chosen_methods === null) { 1801 $chosen_methods = WC()->session->get('chosen_shipping_methods'); 1802 } 1803 1745 1804 $all_shipping_methods = array(); 1746 1805 foreach(WC_Shipping_Zones::get_zones() as $zone_key => $zone ) { … … 1756 1815 } 1757 1816 1758 $chosen_methods = WC()->session->get('chosen_shipping_methods');1759 1817 if($chosen_methods) { 1760 1818 foreach ($chosen_methods as $shipping_method_key => $shipping_method) { … … 1773 1831 } 1774 1832 1775 public function is_payment_excluded( ) {1833 public function is_payment_excluded($chosen_method) { 1776 1834 $excluded_payment_methods = explode(",", $this->excluded_payment); 1777 1835 1778 1836 if (!(sizeof($excluded_payment_methods) == 1 && $excluded_payment_methods[0] == "")) { 1779 $chosen_method = WC()->session->get('chosen_payment_method'); 1837 if($chosen_method === null) { 1838 $chosen_method = WC()->session->get('chosen_payment_method'); 1839 } 1780 1840 if($chosen_method) { 1781 1841 foreach ($excluded_payment_methods as $c) { -
agecheckernet/trunk/readme.txt
r2986427 r3015266 1 === Age Verification for your checkout page. Verify your customer's identity ===1 === Age Verification for your checkout page. Verify your customer's identity === 2 2 Contributors: agechecker 3 3 Tags: age checker, age check, AgeChecker.Net, check age, verify age, age verification, fda, vape, Age Verification and KYC, KYC, Fraud Prevention 4 4 Requires at least: 4.4 5 Tested up to: 6. 36 Stable tag: 1.1 5.35 Tested up to: 6.4 6 Stable tag: 1.16.0 7 7 8 8 AgeChecker.Net seamlessly and securely verifies the age of your customers directly on your website during the checkout process. … … 63 63 == Changelog == 64 64 65 = 1.16.0 = 66 *Release Date - 28 December 2023* 67 68 * "Element" setting field's default value on fresh installs is now: **#place_order,.wc-block-components-checkout-place-order-button** 69 * Adds support for Before-payment workflow to function on WooCommerce block-based checkout pages 70 * Site-owners who installed the plugin before this version, and are looking to set their checkout page to block-based, will need to update set their "Element" setting field to **#place_order,.wc-block-components-checkout-place-order-button** 71 65 72 = 1.15.3 = 66 73 *Release Date - 30 October 2023*
Note: See TracChangeset
for help on using the changeset viewer.