id = 'cod';
$this->icon = '';
$this->has_fields = false;
$this->enabled = get_option('jigoshop_cod_enabled');
$this->title = get_option('jigoshop_cod_title');
$this->description = get_option('jigoshop_cod_description');
add_action('jigoshop_update_options', array(&$this, 'process_admin_options'));
add_option('jigoshop_cod_enabled', 'yes');
add_option('jigoshop_cod_title', __('Cash on Delivery', 'jigoshop') );
add_option('jigoshop_cod_description', __('Please pay to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'jigoshop'));
add_action('thankyou_cod', 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['jigoshop_cod_enabled'])) update_option('jigoshop_cod_enabled', jigowatt_clean($_POST['jigoshop_cod_enabled'])); else @delete_option('jigoshop_cod_enabled');
if(isset($_POST['jigoshop_cod_title'])) update_option('jigoshop_cod_title', jigowatt_clean($_POST['jigoshop_cod_title'])); else @delete_option('jigoshop_cod_title');
if(isset($_POST['jigoshop_cod_description'])) update_option('jigoshop_cod_description', jigowatt_clean($_POST['jigoshop_cod_description'])); else @delete_option('jigoshop_cod_description');
}
/**
* Process the payment and return the result
**/
function process_payment( $order_id ) {
$order = new jigoshop_order( $order_id );
// Mark as on-hold (we're awaiting the cod)
$order->update_status('on-hold', __('Waiting for cash delivery', 'jigoshop'));
// Remove cart
jigoshop_cart::empty_cart();
// Return thankyou redirect
$checkout_redirect = apply_filters( 'jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks') );
return array(
'result' => 'success',
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink( $checkout_redirect )))
);
}
}
/**
* Add the gateway to JigoShop
**/
function add_cod_gateway( $methods ) {
$methods[] = 'jigoshop_cod'; return $methods;
}
add_filter('jigoshop_payment_gateways', 'add_cod_gateway' );