Changeset 3229725
- Timestamp:
- 01/27/2025 03:43:23 PM (14 months ago)
- Location:
- riskcube-von-creditreform-schweiz/trunk
- Files:
-
- 4 edited
-
assets/riskcube.front.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
riskcube.php (modified) (1 diff)
-
src/Core/RiskCube.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
riskcube-von-creditreform-schweiz/trunk/assets/riskcube.front.js
r3071289 r3229725 3 3 console.error('riskCubeCf object not present') 4 4 } 5 //require('riskcube.legacy.js'); 6 window.setTimeout(function() { 7 var requiredFields = jQuery('#billing_first_name, #billing_last_name, #billing_address_1, #billing_postcode, #billing_city, #billing_phone, #billing_email'); 8 var shippingToggle = jQuery('#ship-to-different-address-checkbox'); 9 var shippingFields = jQuery('#shipping_first_name, #shipping_last_name, #shipping_address_1, #shipping_postcode, #shipping_city'); 10 jQuery("#billing_first_name_field, #billing_last_name_field, #billing_company_field, #billing_email").addClass("address-field"); 5 11 6 require('riskcube.legacy.js'); 12 jQuery(requiredFields).off('change').on('change', executeCall); 13 jQuery(shippingFields).off('change').on('change', executeCall); 14 15 function executeCall() { 16 var emptyFields, fields; 17 18 fields = jQuery(requiredFields); 19 20 if (jQuery(shippingToggle).is(':checked')) { 21 fields = fields.add(jQuery(shippingFields)); 22 } 23 emptyFields = jQuery(fields).filter(function () { 24 return jQuery(this).val() === ""; 25 }); 26 console.log(emptyFields); 27 28 if (emptyFields.length <= 1) { 29 jQuery(document.body).trigger('update_checkout'); 30 } 31 } 32 }, 1000); 7 33 if (typeof wc === 'object') { 8 34 require('riskcube.blocks.js'); -
riskcube-von-creditreform-schweiz/trunk/readme.txt
r3224301 r3229725 5 5 Tested up to: 6.7.1 6 6 Requires PHP: 7.4 7 Stable Tag: 2.4.12. 97 Stable Tag: 2.4.12.10 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 145 145 == Changelog == 146 146 147 = 2.4.12.10 = 148 **Bug Fixes** 149 - Fixed endless reload on checkout page 150 147 151 = 2.4.12.9 = 148 152 **Bug Fixes** -
riskcube-von-creditreform-schweiz/trunk/riskcube.php
r3224301 r3229725 6 6 * Plugin Name: RiskCUBE von Creditreform Schweiz 7 7 * Plugin URI: 8 * Version: 2.4.12. 98 * Version: 2.4.12.10 9 9 * Description: RiskCube 10 10 * Author: Masterhomepage GmbH -
riskcube-von-creditreform-schweiz/trunk/src/Core/RiskCube.php
r3224301 r3229725 52 52 // // add_action('woocommerce_checkout_create_order', [__CLASS__, 'before_checkout_create_order'], 20, 2); 53 53 //} 54 55 54 if(self::$isClassicCheckout) { 56 55 add_filter('woocommerce_available_payment_gateways', [__CLASS__, 'controlPaymentGateways'], 10, 1); … … 62 61 add_action('wp_head', [__CLASS__, 'new_checkout_header']); 63 62 } 64 65 63 // Frontend Assets 66 64 foreach ($jsFiles as $jsFile) { 67 65 wp_enqueue_script(basename($jsFile), RISKCUBE__PLUGIN_URL . $jsFile, [], FileHelper::get_file_version($jsFile), true); 68 66 } 67 69 68 70 69 if (get_option('wc_riskcube_invoice_payment_gateway', 0) == 1) { … … 214 213 public static function woocommerce_checkout_update_order_review($post_data) 215 214 { 216 if (!empty($post_data)) { 217 parse_str($post_data, $data); 218 } else { 219 return false; 220 } 221 222 WC()->customer->set_props([ 223 'billing_first_name' => isset($data['billing_first_name']) ? wp_unslash($data['billing_first_name']) : null, 224 'billing_last_name' => isset($data['billing_last_name']) ? wp_unslash($data['billing_last_name']) : null, 225 'billing_company' => isset($data['billing_company']) ? wp_unslash($data['billing_company']) : null, 226 'billing_phone' => isset($data['billing_phone']) ? wp_unslash($data['billing_phone']) : null, 227 'billing_email' => isset($data['billing_email']) ? wp_unslash($data['billing_email']) : null, 228 ]); 229 230 if (wc_ship_to_billing_address_only()) { 231 WC()->customer->set_props([ 232 'shipping_first_name' => isset($data['billing_first_name']) ? wp_unslash($data['billing_first_name']) : null, 233 'shipping_last_name' => isset($data['billing_last_name']) ? wp_unslash($data['billing_last_name']) : null, 234 'shipping_company' => isset($data['billing_company']) ? wp_unslash($data['billing_company']) : null, 235 'shipping_phone' => isset($data['billing_phone']) ? wp_unslash($data['billing_phone']) : null, 236 'shipping_email' => isset($data['billing_email']) ? wp_unslash($data['billing_email']) : null, 237 ]); 238 } else { 239 WC()->customer->set_props([ 240 'shipping_first_name' => isset($data['shipping_first_name']) ? wp_unslash($data['shipping_first_name']) : null, 241 'shipping_last_name' => isset($data['shipping_last_name']) ? wp_unslash($data['shipping_last_name']) : null, 242 'shipping_company' => isset($data['shipping_company']) ? wp_unslash($data['shipping_company']) : null, 243 'shipping_phone' => isset($data['shipping_phone']) ? wp_unslash($data['billing_phone']) : null, 244 'shipping_email' => isset($data['shipping_email']) ? wp_unslash($data['shipping_email']) : null, 245 ]); 246 } 247 248 // cancel the shipping address that woocommerce tries to set if the checkbox is not marked 249 if (array_key_exists('ship_to_different_address', $data) && !$data['ship_to_different_address']) { 250 WC()->customer->set_props([ 251 'shipping_first_name' => '', 252 'shipping_last_name' => '', 253 'shipping_company' => '', 254 'shipping_phone' => '', 255 'shipping_email' => '', 256 257 'shipping_country' => '', 258 'shipping_state' => '', 259 'shipping_postcode' => '', 260 'shipping_city' => '', 261 'shipping_address_1' => '', 262 'shipping_address_2' => '', 263 ]); 264 WC()->customer->save(); 265 215 /* 266 216 // 20220304 disabled, was breaking tax/shipping calculation 267 217 //foreach (['s_country', 's_state', 's_postcode', 's_city', 's_address', 's_address_2'] as $field) { 268 218 //unset($_POST[$field]); 269 219 //} 220 }*/ 221 if( empty($post_data) ) return false; 222 parse_str($post_data, $data); 223 224 // Unslash the input data 225 $data = wp_unslash( $data ); 226 227 $ship_to_different_address = isset($data['ship_to_different_address']) ? wc_string_to_bool($data['ship_to_different_address']) : false; 228 229 $customer_fields = ['first_name', 'last_name', 'company', 'phone', 'email']; 230 foreach ($customer_fields as $field) { 231 $billing_field = 'billing_' . $field; 232 $shipping_field = 'shipping_' . $field; 233 $value = isset( $data[$billing_field] ) ? $data[$billing_field] : null; 234 $value = strpos($field,'email') !== false ? sanitize_email($value) : sanitize_text_field($value); 235 if( WC()->customer->{"get_{$billing_field}"}() !== $value ) { 236 WC()->customer->{"set_{$billing_field}"}($value); 237 } 238 /* There is no get / set shipping_email */ 239 if( $field !== 'email' && $ship_to_different_address ){ 240 $value = isset( $data[$shipping_field] ) ? sanitize_text_field( $data[$shipping_field] ) : null; 241 if( WC()->customer->{"get_{$shipping_field}"}() !== $value ) { 242 WC()->customer->{"set_{$shipping_field}"}($value); 243 } 244 } 245 } 246 //cancel the shipping address if the checkbox is not checked 247 if (!$ship_to_different_address) { 248 WC()->customer->set_props([ 249 'shipping_first_name' => '', 250 'shipping_last_name' => '', 251 'shipping_company' => '', 252 'shipping_phone' => '', 253 'shipping_email' => '', 254 'shipping_country' => '', 255 'shipping_state' => '', 256 'shipping_postcode' => '', 257 'shipping_city' => '', 258 'shipping_address_1' => '', 259 'shipping_address_2' => '', 260 ]); 261 // Save changes to customer 262 WC()->customer->save(); 270 263 } 271 264 }
Note: See TracChangeset
for help on using the changeset viewer.