Plugin Directory

Changeset 2417450


Ignore:
Timestamp:
11/12/2020 07:52:37 PM (5 years ago)
Author:
pookidevs
Message:

Version 1.2: New feature of adding custom input field

Location:
k2-woo-custom-payment-gateway
Files:
7 added
2 edited

Legend:

Unmodified
Added
Removed
  • k2-woo-custom-payment-gateway/trunk/K2_Custom_Payment_Gateway.php

    r2415222 r2417450  
    6262            $this->method_title       = __( 'K2-Woo Custom Payment Gateway', $this->domain );
    6363            $this->method_description = __( 'Description: Add Custom Payment Gateway on Woocommerce Checkout with custom fields.', $this->domain );
     64            $this->show_field         = "Hidden";
    6465
    6566            // Load the settings.
     
    7172            $this->description  = $this->get_option( 'description' );
    7273            $this->order_status = $this->get_option( 'order_status', 'completed' );
    73 
     74            $this->cust  = $this->get_option( 'custom-field-title' );
    7475            // Actions
    7576           
     
    8788           
    8889           
    89             add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
     90            add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
    9091
    9192        }
     
    125126                    'default'     => __('Checkout with K2-Woo Custom Payment Gateway with additional custom fields', $this->domain),
    126127                    'desc_tip'    => true,
     128                ),
     129                'custom-field-title' => array(
     130                    'title' => 'Custom field title',
     131                    'description' => __('Adding title will enable a custom text input with that title.'),
     132                    'type' => 'text',
     133                    'default' => 'Add your custom field title',
     134                    'desc_tip'    => true,
    127135                )
    128136            );
    129137        }
    130 
     138       
    131139
    132140        public function payment_scripts() {
     
    142150            }
    143151
    144 
    145152        }
    146153       
    147 
     154        public function payment_fields(){
     155
     156            echo wpautop( wptexturize( $this->description ) );
     157
     158            if ( $this->cust != 'Add your custom field title' && !empty($this->cust)) {
     159                echo wpautop( wptexturize( $this->cust ) );
     160                $this->show_field = "text";   
     161                ?>
     162                <div id="custom_input">
     163                    <div style="padding: 0em; display: flex; flex-wrap: wrap;">
     164                            <input style = "flex: 1 1 65%; box-sizing: border-box !important; margin-right: 0.5em;  margin-top: 0.3em; background-color: #F5F5F5;" type="<?= $this->show_field ?>" class="" name="custom-field" id="mobile" placeholder="Enter the <?= $this->cust ?>" value='' >
     165                    </div>
     166                </div>
     167                <?php
     168            }
     169            else{
     170                ?>
     171                <div id="custom_input">
     172                <div style="padding: 0em; display: flex; flex-wrap: wrap;">
     173                        <input style = "flex: 1 1 65%; box-sizing: border-box !important; margin-right: 0.5em;  margin-top: 0.3em; background-color: #F5F5F5;" type="Hidden" class="" name="custom-field" id="mobile" placeholder="Enter the <?= $this->cust ?>" value='' >
     174                </div>
     175                </div>
     176                <?php
     177            }
     178            $this->show_field = "Hidden";
     179        }
     180       
    148181        /**
    149182         * Process the payment and return the result.
     
    158191            $status = 'wc-' === substr( $this->order_status, 0, 3 ) ? substr( $this->order_status, 3 ) : $this->order_status;
    159192
     193            if (!empty($_POST['custom-field'])) {
     194                update_post_meta($order_id, $this->cust , sanitize_text_field($_POST['custom-field']));
     195            }
    160196            // Set order status
    161197            $order->update_status( $status, __( 'Checkout with K2-Woo Custom Payment Gateway. ', $this->domain ) );
  • k2-woo-custom-payment-gateway/trunk/Readme.txt

    r2415212 r2417450  
    11=== K2 Custom Payment Gateway for WooCommerce ===
    2 Contributors: syedharis632, shahrukhx04, hmumtaz1, saadhamid
     2Contributors: hmumtaz1, syedharis632, shahrukhx04, saadhamid
    33Tags: Wordpress, Woocommerce, Essentials
    44Requires at least: 5.2
    55Tested up to: 5.5.1
    66Requires PHP: 5.6
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88License: GPL2+
    99License URI: https://www.gnu.org/licenses/gpl-2.0.txt
     
    2121DYNAMIC TITLE
    2222
    23 You can define your own custom payment method by adding a dynamic title of your own choice.
     23You can define your own custom payment method by adding a dynamic title of your own choice i.e Cash on Delivery.
    2424
    2525DYNAMIC DESCRIPTION
     
    2727You can describe your own custom payment method by adding a dynamic description of your own choice.
    2828
    29 DYNAMIC ICON
    30 
    31 You can add your own dynamic icon to your custom payment method.
    32 
    3329ORDER STATUS
    3430
    3531You can define your own order statuses. You can also choose what the order status will be once payment is processed through your custom payment gateway.
     32
     33DYNAMIC INPUT FIELD
     34
     35You can add the title for an input you want from the user when they choose this specific payment option i.e input address only for payment through cash on delivery orders
    3636
    3737
     
    6666= 1.1 =
    6767Bug fixes
     68= 1.2 =
     69Added feature to add dynamic input field for saving with the order
    6870
    6971== Development ==
Note: See TracChangeset for help on using the changeset viewer.