Changeset 3048580
- Timestamp:
- 03/10/2024 12:19:03 PM (2 years ago)
- Location:
- agreeme-checkboxes-for-woocommerce
- Files:
-
- 28 added
- 3 edited
-
tags/1.1.1 (added)
-
tags/1.1.1/agree-me-woocommerce.php (added)
-
tags/1.1.1/css (added)
-
tags/1.1.1/inc (added)
-
tags/1.1.1/inc/agrwc-functions.php (added)
-
tags/1.1.1/inc/classes (added)
-
tags/1.1.1/inc/classes/agrwc-cbx-list-table.php (added)
-
tags/1.1.1/inc/classes/agrwc-cbx.php (added)
-
tags/1.1.1/inc/classes/agrwc-cbxs.php (added)
-
tags/1.1.1/inc/classes/agrwc-compatibility.php (added)
-
tags/1.1.1/inc/classes/agrwc-frontend.php (added)
-
tags/1.1.1/inc/classes/agrwc-install.php (added)
-
tags/1.1.1/inc/classes/agrwc-main.php (added)
-
tags/1.1.1/inc/classes/agrwc-orderdisplay.php (added)
-
tags/1.1.1/inc/classes/agrwc-thirdparty.php (added)
-
tags/1.1.1/inc/options (added)
-
tags/1.1.1/inc/options/agrwc-settings-cbx.php (added)
-
tags/1.1.1/inc/options/view (added)
-
tags/1.1.1/inc/options/view/admin-page-cbx.php (added)
-
tags/1.1.1/js (added)
-
tags/1.1.1/js/agrwc-cbx-backend.js (added)
-
tags/1.1.1/js/agrwc-cbx.js (added)
-
tags/1.1.1/languages (added)
-
tags/1.1.1/languages/agreeme-checkbox-for-woocommerce-es_ES.mo (added)
-
tags/1.1.1/languages/agreeme-checkbox-for-woocommerce-es_ES.po (added)
-
tags/1.1.1/languages/agreeme-checkbox-for-woocommerce.pot (added)
-
tags/1.1.1/readme.txt (added)
-
tags/1.1.1/todo.txt (added)
-
trunk/inc/classes/agrwc-compatibility.php (modified) (4 diffs)
-
trunk/inc/classes/agrwc-frontend.php (modified) (16 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
agreeme-checkboxes-for-woocommerce/trunk/inc/classes/agrwc-compatibility.php
r2996245 r3048580 40 40 $val_arr[1]=AGRWC_YES; 41 41 42 if ( ! session_id() ) { 43 session_start(); 44 } 42 45 43 $cbxs = AGRWC_CBX::get_cbxs(); 46 44 $show_cbx=array(); … … 78 76 if(in_array(trim($keysarr[1]),$show_cbx)) 79 77 { 78 79 $id=(int)trim($keysarr[1]); 80 $valid=WC()->session->get( 'agrwc-'.$id ); 80 81 $meta_key='Agree-'.$id; 81 $meta_value=$cbx->get_label()."-".$val_arr[ $_SESSION['agrwc'][$id]];82 $meta_value=$cbx->get_label()."-".$val_arr[(int)$valid]; 82 83 $order->{$meta_key} = $meta_value; 83 84 … … 105 106 106 107 if(in_array(trim($keysarr[1]),$show_cbx)) 107 { 108 {$id=(int)trim($keysarr[1]); 109 108 110 $meta_key='Agree-'.$id; 109 $meta_value=$cbx->get_label()."-".$val_arr[$_SESSION['agrwc'][$id]]; 111 $valid=WC()->session->get( 'agrwc-'.$id ); 112 $meta_value=$cbx->get_label()."-".$val_arr[$valid]; 110 113 $order->{$meta_key} = $meta_value; 111 114 … … 120 123 } 121 124 122 123 125 ///////////// 126 if($session_started==1) session_write_close(); 124 127 125 128 return $order; -
agreeme-checkboxes-for-woocommerce/trunk/inc/classes/agrwc-frontend.php
r3001295 r3048580 25 25 $enabled = get_option('agrwc_enabled'); 26 26 if (!$enabled || $enabled == "no") return false; 27 if (session_status() == PHP_SESSION_NONE) { 28 29 30 31 session_start(); 32 } 27 33 28 34 29 … … 40 35 $this->checkoutpage_locations['after_terms_conditions']='woocommerce_checkout_after_terms_conditions'; 41 36 $this->checkoutpage_locations['before_submit']='woocommerce_review_order_before_submit'; 42 37 // add_action( 'init', array($this, 'xxxxxxxxxx_init_session'), PHP_INT_MAX); 43 38 44 39 add_action('woocommerce_before_add_to_cart_button', array($this, 'addto_product_page'), PHP_INT_MAX); … … 52 47 add_action('woocommerce_checkout_before_terms_conditions', array($this, 'addto_checkout_page'), PHP_INT_MAX); 53 48 add_action('woocommerce_checkout_after_terms_conditions', array($this, 'addto_checkout_page'), PHP_INT_MAX); 54 add_action('woocommerce_review_order_before_submit', array($this, 'addto_checkout_page'), PHP_INT_MAX); 55 56 add_action('woocommerce_thankyou', array($this, 'order_completed'), PHP_INT_MAX); 57 add_action('woocommerce_checkout_update_order_meta', array($this, 'update_agree_checkbox_fields_order_meta')); 49 add_action('woocommerce_review_order_before_submit', array($this, 'addto_checkout_page'), PHP_INT_MAX); 50 add_action('woocommerce_thankyou', array($this, 'order_completed'), PHP_INT_MAX); 51 add_action('woocommerce_checkout_update_order_meta', array($this, 'update_agree_checkbox_fields_order_meta')); 58 52 add_action('woocommerce_cart_calculate_fees', array($this, 'add_fees'), PHP_INT_MAX); 59 53 add_action('admin_enqueue_scripts', array($this, 'admin_enqueue'), PHP_INT_MAX); … … 69 63 70 64 } 71 72 65 66 73 67 public function admin_enqueue($hook) { 74 68 // Only add to the edit.php admin page. … … 92 86 */ 93 87 public function order_completed($order_id) { 94 95 if(isset($_SESSION['agrwc'])) 96 { 97 $_SESSION['agrwc'] = ''; 98 unset($_SESSION['agrwc']); 99 } 88 $cbxs = AGRWC_CBX::get_cbxs(); 89 foreach ($cbxs as $id => $cbx) { 90 WC()->session->__unset( 'agrwc-'.$id ); 91 92 } 100 93 } 101 94 public function agrwc_post() { … … 105 98 //loop through all... 106 99 foreach ($cbxs as $id => $cbx) { 107 if (isset($_POST[$id])) unset($_SESSION['agrwc'][$id]); 108 if ($_POST[$id]) { 109 $_SESSION['agrwc'][$id] = (int)$_POST[$id]; //checkbox if checked should be 1 100 if (isset($_POST[$id])) WC()->session->__unset( 'agrwc-'.$id ); 101 if (isset($_POST[$id]) && $_POST[$id]) { 102 WC()->session->set('agrwc-'.$id,(int)$_REQUEST[$id]); 103 // $_SESSION['agrwc'][$id] = (int)$_POST[$id]; //checkbox if checked should be 1 110 104 } 111 105 } … … 171 165 $passed = false; 172 166 } 173 $_SESSION['agrwc'][$id] = (int)$_REQUEST[$id]; //store in session. 167 WC()->session->set('agrwc-'.$id,(int)$_REQUEST[$id]); 168 // $_SESSION['agrwc'][$id] = (int)$_REQUEST[$id]; //store in session. 174 169 175 170 } … … 215 210 $match_product = false; 216 211 if (is_array($l_products) && count($l_products)) { 212 213 214 217 215 if (in_array($_REQUEST['add-to-cart'], $l_products)) { 218 216 if (($cbx->get_required() == 'yes') && !isset($_REQUEST[$id])) { 219 217 //wc_add_notice( __( 'Some required fields are missing', 'woocommerce' ), 'error' ); 220 221 } 222 } 223 } 224 if (isset($_REQUEST[$id]) && $_REQUEST['add-to-cart']) $_SESSION['agrwc'][$id] = (int)$_REQUEST[$id]; //store in session. 218 $passed = false; 219 } 220 } 221 } 222 if (isset($_REQUEST[$id]) && $_REQUEST['add-to-cart']) { 223 WC()->session->set('agrwc-'.$id,(int)$_REQUEST[$id]); 224 //$_SESSION['agrwc'][$id] = (int)$_REQUEST[$id]; //store in session. 225 226 227 } 225 228 226 229 } … … 258 261 if (is_array($l_products) && count($l_products)) { 259 262 if (in_array($product_id, $l_products)) { 260 261 if(isset($_SESSION['agrwc'][$id])) unset($_SESSION['agrwc'][$id]);263 WC()->session->__unset( 'agrwc-'.$id ); 264 // if(isset($_SESSION['agrwc'][$id])) unset($_SESSION['agrwc'][$id]); 262 265 } 263 266 } … … 316 319 $reqclass = ''; 317 320 }; 318 if (isset($_SESSION[$id])) $checked = 1; 321 322 if (WC()->session->get( 'agrwc-'.$id ))$checked = 1; 323 // if (isset($_SESSION[$id])) $checked = 1; 319 324 else $checked = 0; 320 325 if ($match_product) { … … 388 393 $reqclass = ''; 389 394 }; 390 if (isset($_SESSION['agrwc'][$id])) $checked = 1; 391 else $checked = 0; 395 if (WC()->session->get( 'agrwc-'.$id ))$checked = 1; 396 // if (isset($_SESSION[$id])) $checked = 1; 397 else $checked = 0; 392 398 woocommerce_form_field($id, array('type' => 'checkbox', 'class' => array('form-row privacy', $reqclass), 'label_class' => array('woocommerce-form__label checkbox'), 'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox agrwc-cbx', $reqclass), 'required' => $req, 'label' => $cbx->get_label(),), $checked); 393 399 $this->sdata[$id] = esc_js($cbx->get_reqalert()); 394 400 }else 395 401 { 396 if (isset($_SESSION['agrwc'][$id])) unset($_SESSION['agrwc'][$id]);402 if (WC()->session->get( 'agrwc-'.$id )) WC()->session->__unset( 'agrwc-'.$id ); 397 403 398 404 } … … 400 406 { 401 407 402 if (isset($_SESSION['agrwc'][$id])) unset($_SESSION['agrwc'][$id]);408 if (WC()->session->get( 'agrwc-'.$id )) WC()->session->__unset( 'agrwc-'.$id ); 403 409 404 410 } … … 494 500 $reqclass = ''; 495 501 }; 496 if (isset($_SESSION['agrwc'][$id]))$checked = 1;497 else $checked = 0;502 if (WC()->session->get( 'agrwc-'.$id ))$checked = 1; 503 else $checked = 0; 498 504 499 505 … … 525 531 $location_arr = $cbx->get_locations(); 526 532 $fee_value = $cbx->get_add_fee(); 527 if ((in_array(3, $location_arr) || in_array(1, $location_arr) || in_array(2, $location_arr)) && $fee_value && isset($_SESSION['agrwc'][$id]) && $_SESSION['agrwc'][$id]) //add fee only works from checkout page..533 if ((in_array(3, $location_arr) || in_array(1, $location_arr) || in_array(2, $location_arr)) && $fee_value && WC()->session->get( 'agrwc-'.$id )) //add fee only works from checkout page.. 528 534 { 529 535 … … 745 751 746 752 $ix++; 747 if (isset($_SESSION['agrwc'][$id])) { 748 749 753 754 $valid=WC()->session->get( 'agrwc-'.$id ); 755 756 if ($valid) { 757 750 758 751 759 … … 759 767 //HPOS 760 768 $order_updated=1; 761 $order->update_meta_data('_agrwc_' . $id, $cbx->get_label() . " - " . $val_arr[(int)$_SESSION['agrwc'][$id]] ); /// 769 770 771 $order->update_meta_data('_agrwc_' . $id, $cbx->get_label() . " - " . $val_arr[$valid] ); /// 762 772 763 773 764 774 }else 765 update_post_meta($order_id, '_agrwc_' . $id, $cbx->get_label() . " - " . $val_arr[(int)$ _SESSION['agrwc'][$id]]);775 update_post_meta($order_id, '_agrwc_' . $id, $cbx->get_label() . " - " . $val_arr[(int)$valid]); 766 776 } 767 777 768 778 } 779 780 781 769 782 if($order_updated){"Order saved"; $order->save(); 783 784 785 770 786 } 771 787 772 788 773 789 add_action('woocommerce_checkout_update_order_meta', array($this, 'update_agree_checkbox_fields_order_meta')); 790 791 774 792 775 793 -
agreeme-checkboxes-for-woocommerce/trunk/readme.txt
r2996245 r3048580 3 3 Tags: woocommerce, checkout, woo commerce 4 4 Requires at least: 5.0 5 Tested up to: 6.4. 16 Stable tag: 1.1. 05 Tested up to: 6.4.3 6 Stable tag: 1.1.1 7 7 License: GNU General Public License v3.0 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 50 50 51 51 == Changelog == 52 = 1.0.1 = 53 Changed to native WC session 52 54 53 55 = 1.0.3 =
Note: See TracChangeset
for help on using the changeset viewer.