Skip to content

Instantly share code, notes, and snippets.

@efarem
Created October 21, 2013 14:27
Show Gist options
  • Save efarem/7084753 to your computer and use it in GitHub Desktop.
Save efarem/7084753 to your computer and use it in GitHub Desktop.
Basic template for WooCommerce Payment Gateway Class
<?php
class WC_Gateway_EFAREM extends WC_Payment_Gateway
{
public function __construct()
{
$this->id = 'efarem';
$this->icon = plugin_dir_url(__FILE__) . '/assets/images/efarem.png';
$this->has_fields = true;
$this->method_title = '{Title of Gateway}';
$this->method_description = 'Description of gateway';
$this->init_form_fields();
$this->init_settings();
$this->title = $this->get_option('title');
$this->vendor_name = $this->get_option('vendor-name');
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
}
/**
* Add form fields to the WooCommerce Gateway settings page
*
* @return void
**/
public function init_form_fields()
{
$this->form_fields = array(
'enabled' => array(
'title' => __('Enable/Disable', 'woocommerce'),
'type' => 'checkbox',
'label' => __('Enable {Title of Gateway}', 'woocommerce'),
'default' => 'yes',
),
'title' => array(
'title' => __('Title', 'woocommerce'),
'type' => 'text',
'description' => __('This controls the title which the user sees during checkout.', 'woocommerce'),
'default' => __($this->method_title, 'woocommerce'),
'desc_tip' => true,
),
'mode' => array(
'title' => __('Mode', 'woocommerce'),
'type' => 'select',
'decription' => __('Choose the payment mode', 'woocommerce'),
'options' => array('simulator' => __('Simulator', 'woocommerce'), 'test' => __('Test', 'woocommerce'), 'live' => __('Live', 'woocommerce')),
'desc_tip' => true,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment