PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 11, 2022

[FIXED] How to use file upload option in WooCommerce payment gateway admin options?

 November 11, 2022     hook-woocommerce, payment-gateway, woocommerce, wordpress, wordpress-plugin-creation     No comments   

Issue

I am developing a plugin to integrate a payment gateway in WooCommerce. I have done one before.

But in this one, I need to upload a key file in gateway settings and that is used to hash the data before making payment request to related portal.

I have following code which allows to choose file, but I doubt this is working in the back end.

    'sandbox_pvt_key' => array(
        'title'       => __( 'Test Private Key', 'woocommerce-custom-gateway' ),
        'type'        => 'file',
        'desc_tip'    => true,
        'description' => __( 'Please upload the test private key file; this is needed in order to test payment.', 'woocommerce-custom-gateway' ),
        'default'     => '',
    ),

The output looks like the following: enter image description here

Can anybody lemme know if this is supported option in the gateway settings? If not, can anybody guide me on how I can customize it via some hook/filters or any other way.


Solution

This can be achieved in the process_admin_options()

public function process_admin_options() {
   $this->upload_key_files();

   $saved = parent::process_admin_options();

   return $saved;
}

private function upload_key_files() {
    //handle uploads here
}


Answered By - Prajwol
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing