Plugin Directory

Changeset 3203935


Ignore:
Timestamp:
12/07/2024 06:02:09 AM (16 months ago)
Author:
oscomsupport
Message:

Default checked or not option
Updated to latest WC

Location:
agreeme-checkboxes-for-woocommerce
Files:
28 added
7 edited

Legend:

Unmodified
Added
Removed
  • agreeme-checkboxes-for-woocommerce/trunk/agree-me-woocommerce.php

    r3140717 r3203935  
    44Plugin URI: https:///agreeme-checkbox-for-woocommerce/
    55Description: Add checkbox fields to WooCommerce pages.
    6 Version: 1.1.2
     6Version: 1.1.3
    77Author: Amin Y
    88Author URI: https://qcompsolutions.com
  • agreeme-checkboxes-for-woocommerce/trunk/inc/classes/agrwc-cbx.php

    r2826299 r3203935  
    3131        $this->locationnamearr[3] = __('Checkout Page', 'agreeme-checkbox-for-woocommerce');
    3232        $this->locationnamearr[999] = __('', 'agreeme-checkbox-for-woocommerce');
    33         $this->data = wp_parse_args($data, array('cbx_id' => '', 'name' => '', 'products' => array(), 'locations' => array(), 'olocations' => array(),'clocation' => 'after_customer_notes',  'limit_categories' => array(), 'limit_products' => array(), 'limit_ordertotal' => '', 'conditionx' => '', 'value' => '1', 'label' => '','append_fee' => '0', 'required' => '1', 'reqalert' => '', 'add_fee' => 0, 'fee_text' => ''));
     33        $this->data = wp_parse_args($data, array('cbx_id' => '', 'name' => '', 'products' => array(), 'locations' => array(), 'olocations' => array(),'clocation' => 'after_customer_notes',  'limit_categories' => array(), 'limit_products' => array(), 'limit_ordertotal' => '', 'conditionx' => '', 'value' => '1', 'label' => '','append_fee' => '0', 'required' => '1','dchecked' => '0', 'reqalert' => '', 'add_fee' => 0, 'fee_text' => ''));
    3434    }
    3535    /**
     
    137137     * @param string $name Checkbox name.
    138138     */
     139    public function set_dchecked($required) {
     140        $this->set_prop('dchecked', $required);
     141    }
     142   
     143        public function get_dchecked() {
     144        return $this->get_prop('dchecked');
     145    }
     146
    139147    public function set_required($required) {
    140148        $this->set_prop('required', $required);
    141149    }
     150   
     151   
    142152    public function get_reqalert() {
    143153        return $this->get_prop('reqalert');
  • agreeme-checkboxes-for-woocommerce/trunk/inc/classes/agrwc-frontend.php

    r3140717 r3203935  
    319319                    if ($cbx->get_required() == 'yes') {
    320320                        $req = true;
    321                         $reqclass = " required ";
     321                        $reqclass = " requiredx ";
    322322                    } else {
    323323                        $req = false;
    324324                        $reqclass = '';
    325325                    };
    326                    
     326                    $checked = 0;
     327                    if ($cbx->get_dchecked() == 'yes') $checked = 1;
    327328                    if (isset(WC()->session) && WC()->session->get( 'agrwc-'.$id ))$checked = 1;
    328329                   // if (isset($_SESSION[$id])) $checked = 1;
    329                     else $checked = 0;
     330             
    330331                    if ($match_product) {
    331332                        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);
     
    393394                            if ($cbx->get_required() == 'yes') {
    394395                                $req = true;
    395                                 $reqclass = " required ";
     396                                $reqclass = " requiredx ";
    396397                            } else {
    397398                                $req = false;
    398399                                $reqclass = '';
    399400                            };
     401                           
     402                            $checked = 0;
     403                            if ($cbx->get_dchecked() == 'yes') $checked = 1;
    400404                            if (WC()->session->get( 'agrwc-'.$id ))$checked = 1;
    401405                   // if (isset($_SESSION[$id])) $checked = 1;
    402                     else $checked = 0;
     406             
    403407                            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);
    404408                            $this->sdata[$id] = esc_js($cbx->get_reqalert());
     
    500504                            if ($cbx->get_required() == 'yes') {
    501505                                $req = true;
    502                                 $reqclass = " required ";
     506                                $reqclass = " requiredx ";
    503507                            } else {
    504508                                $req = false;
    505509                                $reqclass = '';
    506510                            };
    507                                 if (WC()->session->get( 'agrwc-'.$id ))$checked = 1;
    508                     else $checked = 0;
     511                           
     512                    $checked = 0;
     513                    if ($cbx->get_dchecked() == 'yes') $checked = 1;
     514                    if (WC()->session->get( 'agrwc-'.$id ))$checked = 1;
     515                 
    509516                       
    510517                       
  • agreeme-checkboxes-for-woocommerce/trunk/inc/options/agrwc-settings-cbx.php

    r2776386 r3203935  
    157157            $postdata['label'] = wp_unslash($postdata['label']); //allow links in label
    158158            $postdata['required'] = isset($postdata['required']) ? 'yes' : 'no';
     159            $postdata['dchecked'] = isset($postdata['dchecked']) ? 'yes' : 'no';
    159160             $postdata['append_fee'] = isset($postdata['append_fee']) ? 'yes' : 'no';
    160161            if (!isset($postdata['limit_products'])) {
  • agreeme-checkboxes-for-woocommerce/trunk/inc/options/view/admin-page-cbx.php

    r2826299 r3203935  
    8585                <td class="forminp forminp-text">
    8686                    <input name="required" id="required" type="checkbox" value="1" <?php if('yes'==$cbx->data['required'])echo "checked"; ?> />Yes/No
     87
     88                </td>
     89        </tr>
     90       
     91                <tr valign="top">
     92            <th scope="row" class="titledesc">
     93                <label for="name"><?php esc_html_e( 'Default Checked', 'agreeme-checkbox-for-woocommerce' ); ?></label>
     94                <?php echo wp_kses_post( wc_help_tip( __( 'Default Checked or Unchecked', 'agreeme-checkbox-for-woocommerce' ) ) ); ?>
     95            </th>
     96                <td class="forminp forminp-text">
     97                    <input name="dchecked" id="dchecked" type="checkbox" value="1" <?php if('yes'==$cbx->data['dchecked'])echo "checked"; ?> />Yes/No
    8798
    8899                </td>
  • agreeme-checkboxes-for-woocommerce/trunk/js/agrwc-cbx.js

    r2915308 r3203935  
    88        var hr = jQuery(this).attr('href');
    99        jQuery('.agrwc-cbx').each(function(index, obj) {
    10             if (!jQuery(this).prop('checked') && jQuery(this).hasClass('required')) {
     10            if (!jQuery(this).prop('checked') && jQuery(this).hasClass('requiredx')) {
    1111                var idx = jQuery(this).prop('id');
    1212                if (AGRWC_VARS[idx]) alert(AGRWC_VARS[idx]);
     
    3535        var hasagrerr = 0;
    3636        jQuery('.agrwc-cbx').each(function(index, obj) {
    37             if (!jQuery(this).prop('checked') && jQuery(this).hasClass('required')) {
     37            if (!jQuery(this).prop('checked') && jQuery(this).hasClass('requiredx')) {
    3838                var idx = jQuery(this).prop('id');
    3939                if (AGRWC_VARS[idx]) alert(AGRWC_VARS[idx]);
  • agreeme-checkboxes-for-woocommerce/trunk/readme.txt

    r3117104 r3203935  
    22Contributors: oscomsupport
    33Tags: woocommerce, checkout, woo commerce
    4 Requires at least: 5.0
    5 Tested up to: 6.4.3
    6 Stable tag: 1.1.2
     4Requires at least: 6.0
     5Tested up to: 6.7.1
     6Stable tag: 1.1.3
    77License: GNU General Public License v3.0
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    5050
    5151== Changelog ==
     52= 1.1.3 =
     53Tested to WP 6.7.1 and added default checked option.
     54
    5255= 1.0.1 =
    5356Changed to native WC session
Note: See TracChangeset for help on using the changeset viewer.