id = 'cheque';
$this->icon = '';
$this->has_fields = false;
$this->enabled = get_option('woocommerce_cheque_enabled');
$this->title = get_option('woocommerce_cheque_title');
$this->description = get_option('woocommerce_cheque_description');
add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
add_option('woocommerce_cheque_enabled', 'yes');
add_option('woocommerce_cheque_title', __('Cheque Payment', 'woothemes') );
add_option('woocommerce_cheque_description', __('Please send your cheque to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'woothemes'));
add_action('woocommerce_thankyou_cheque', array(&$this, 'thankyou_page'));
}
/**
* Admin Panel Options
* - Options for bits like 'title' and availability on a country-by-country basis
**/
public function admin_options() {
?>
description) echo wpautop(wptexturize($this->description));
}
function thankyou_page() {
if ($this->description) echo wpautop(wptexturize($this->description));
}
/**
* Admin Panel Options Processing
* - Saves the options to the DB
**/
public function process_admin_options() {
if(isset($_POST['woocommerce_cheque_enabled'])) update_option('woocommerce_cheque_enabled', 'yes'); else update_option('woocommerce_cheque_enabled', 'no');
if(isset($_POST['woocommerce_cheque_title'])) update_option('woocommerce_cheque_title', woocommerce_clean($_POST['woocommerce_cheque_title'])); else delete_option('woocommerce_cheque_title');
if(isset($_POST['woocommerce_cheque_description'])) update_option('woocommerce_cheque_description', woocommerce_clean($_POST['woocommerce_cheque_description'])); else delete_option('woocommerce_cheque_description');
}
/**
* 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 cheque)
$order->update_status('on-hold', __('Awaiting cheque 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_cheque_gateway( $methods ) {
$methods[] = 'woocommerce_cheque'; return $methods;
}
add_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );