Custome Payment Gateway Settings not Saving
-
Hello! I’m running the newest version of WooCommerce. (2.1.7) I am trying to use my custom payment gateway, but the settings for it don’t seem to be saving. It gives me the message settings saved, but they stay the same. My need part of my code is as follows, (I didn’t include the slew of callback code or the unrelated shortcode for interacting with the user.)
<?php /* Plugin Name: Bitcoin WooCommerce Payment Gatway Description: A Bitcoin payment gatway for WooCommerce made specifically for Bitcoin Publish. Version: 0.03 Author: Cammy_the_block */ /** * Check if WooCommerce is active **/ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {} function declare_blockchain_gateway() { if ( ! class_exists( 'WC_Payment_Gateways' ) ) return; class WC_BWCPG extends WC_Payment_Gateway { public function __construct() { $this->id = 'Bitcoin WooCommerce Payment Gatway'; $this->has_fields = false; // Load the form fields. $this->init_form_fields(); // Load the settings. $this->init_settings(); // Define user set variables $this->title = $this->settings['title']; $this->description = $this->settings['description']; // Actions if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) { add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); } else { add_action( 'woocommerce_update_options_payment_gateways', array( &$this, 'process_admin_options' ) ); } // Customer Emails add_action('woocommerce_email_before_order_table', array(&$this, 'email_instructions'), 10, 2); } function init_form_fields() { $this->form_fields = array( 'enabled' => array( 'title' => __( 'Enable/Disable', 'woothemes' ), 'type' => 'checkbox', 'label' => __( 'Enable the Payment Gatway', 'woothemes' ), 'default' => 'yes' ), 'title' => array( 'title' => __( 'Title', 'woothemes' ), 'type' => 'text', 'description' => __( 'This controls the title which the user sees during checkout.', 'woothemes' ), 'default' => __( 'Bitcoin', 'woothemes' ) ), 'description' => array( 'title' => __( 'Customer Message', 'woothemes' ), 'type' => 'textarea', 'description' => __( 'This controls the description which the user sees during checkout.', 'woothemes' ), 'default' => 'Pay securely with Bitcoin.' ), 'location' => array( 'title' => __( 'Location of the Payment Page', 'woothemes' ), 'type' => 'text', 'description' => __( 'This is the location of the page that contains the shortcode [bitcoin-payment].', 'woothemes' ), 'default' => 'bitcoin-payment' ) ); } public function admin_options() { ?> <h3><?php _e('Bitcoin Payment', 'woothemes'); ?></h3> <p><?php _e('Allows Bitcoin payments using the Blockchain API.', 'woothemes'); ?></p> <table class="form-table"> <?php // Generate the HTML For the settings form. $this->generate_settings_html(); ?> </table> <?php } function payment_fields(){ ?> You will recive a Bitcoin address and when enough Bitcoins are recieved your order will be processed.<?php } public function email_instructions( $order, $sent_to_admin ) { return; } function thankyou_page() { if ($this->description) echo wpautop(wptexturize($this->description)); } function process_payment( $order_id ) { global $woocommerce; $order = &new WC_Order( $order_id ); // Mark as on-hold (we're awaiting the coins) //add_note('User has not generated an adress yet.', $orderNumber); $order->reduce_order_stock(); $woocommerce->cart->empty_cart(); $fullTyLink = $this->get_return_url( $order ); $linkArgs = parse_url($fullTyLink, PHP_URL_QUERY); $tyPath = parse_url($fullTyLink, PHP_URL_PATH); // use get_option('siteurl'). to find website url then check WC API or settings to find ty page. return array( 'result' => 'success', 'redirect' => '/'.$this->settings['location'].'?'.$linkArgs.'&l='.$tyPath ); } } } function add_blockchain_gateway( $methods ) { $methods[] = 'WC_BWCPG'; return $methods; } //include plugin_dir_path(__FILE__).'callback.php'; //add_shortcode( 'bitcoin-payment', 'bitcoin_payment' ); add_action('plugins_loaded', 'declare_blockchain_gateway', 0); add_filter('woocommerce_payment_gateways', 'add_blockchain_gateway' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custome Payment Gateway Settings not Saving’ is closed to new replies.