id = 'bacs';
$this->icon = '';
$this->has_fields = false;
$this->enabled = get_option('woocommerce_bacs_enabled');
$this->title = get_option('woocommerce_bacs_title');
$this->description = get_option('woocommerce_bacs_description');
$this->account_name = get_option('woocommerce_bacs_account_name');
$this->account_number = get_option('woocommerce_bacs_account_number');
$this->sort_code = get_option('woocommerce_bacs_sort_code');
$this->bank_name = get_option('woocommerce_bacs_bank_name');
$this->iban = get_option('woocommerce_bacs_iban');
$this->bic = get_option('woocommerce_bacs_bic');
add_action('woocommerce_update_options', array(&$this, 'process_admin_options'));
add_option('woocommerce_bacs_enabled', 'no');
add_option('woocommerce_bacs_title', __('Direct Bank Transer', 'woothemes'));
add_option('woocommerce_bacs_description', __('Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order wont be shipped until the funds have cleared in our account.', 'woothemes'));
add_action('thankyou_bacs', array(&$this, 'thankyou_page'));
}
public function is_available(){
return ($this->enabled == 'yes') ? true : false;
}
public function set_current(){ true; }
public function icon(){}
public function validate_fields(){ true; }
/**
* Admin Panel Options
**/
public function admin_options() { ?>
description) echo wpautop(wptexturize($this->description));
}
function thankyou_page() {
if ($this->description) echo wpautop(wptexturize($this->description));
?>account_name) { ?>
-
:
account_name) ?>
account_number) { ?>
-
:
account_number) ?>
sort_code) { ?>
-
:
sort_code) ?>
bank_name) { ?>
-
:
bank_name) ?>
iban) { ?>
-
:
iban) ?>
bic) { ?>
-
:
bic) ?>
";
}
/**
* Admin Panel Options Processing
* - Saves the options to the DB
**/
public function process_admin_options() {
if(isset($_POST['woocommerce_bacs_enabled'])) update_option('woocommerce_bacs_enabled', 'yes'); else update_option('woocommerce_bacs_enabled', 'no');
if(isset($_POST['woocommerce_bacs_title'])) update_option('woocommerce_bacs_title', woocommerce_clean($_POST['woocommerce_bacs_title'])); else delete_option('woocommerce_bacs_title');
if(isset($_POST['woocommerce_bacs_description'])) update_option('woocommerce_bacs_description', woocommerce_clean($_POST['woocommerce_bacs_description'])); else delete_option('woocommerce_bacs_description');
if(isset($_POST['woocommerce_bacs_account_name'])) update_option('woocommerce_bacs_account_name', woocommerce_clean($_POST['woocommerce_bacs_account_name'])); else delete_option('woocommerce_bacs_account_name');
if(isset($_POST['woocommerce_bacs_account_number'])) update_option('woocommerce_bacs_account_number', woocommerce_clean($_POST['woocommerce_bacs_account_number'])); else delete_option('woocommerce_bacs_account_number');
if(isset($_POST['woocommerce_bacs_sort_code'])) update_option('woocommerce_bacs_sort_code', woocommerce_clean($_POST['woocommerce_bacs_sort_code'])); else delete_option('woocommerce_bacs_sort_code');
if(isset($_POST['woocommerce_bacs_bank_name'])) update_option('woocommerce_bacs_bank_name', woocommerce_clean($_POST['woocommerce_bacs_bank_name'])); else delete_option('woocommerce_bacs_bank_name');
if(isset($_POST['woocommerce_bacs_iban'])) update_option('woocommerce_bacs_iban', woocommerce_clean($_POST['woocommerce_bacs_iban'])); else delete_option('woocommerce_bacs_iban');
if(isset($_POST['woocommerce_bacs_bic'])) update_option('woocommerce_bacs_bic', woocommerce_clean($_POST['woocommerce_bacs_bic'])); else delete_option('woocommerce_bacs_bic');
}
/**
* Process the payment and return the result
**/
function process_payment( $order_id ) {
global $woocommerce;
$order = &new woocommerce_order( $order_id );
// Mark as on-hold (we're awaiting the payment)
$order->update_status('on-hold', __('Awaiting BACS payment', 'woothemes'));
// Remove cart
$woocommerce->cart->empty_cart();
// Empty awaiting payment session
unset($_SESSION['order_awaiting_payment']);
// Return thankyou redirect
return array(
'result' => 'success',
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id'))))
);
}
}
/**
* Add the gateway to WooCommerce
**/
function add_bacs_gateway( $methods ) {
$methods[] = 'woocommerce_bacs'; return $methods;
}
add_filter('woocommerce_payment_gateways', 'add_bacs_gateway' );