id = "agechecked_woocommerce_addon";
// The Title shown on the top of the settings page
$this->method_title = self::get_title();
// The description, shown on the actual Payment options page on the backend
$this->method_description = __("AgeChecked Plug-in for WooCommerce", 'agechecked-wc-addon');
// The title to be used for the vertical tabs that can be ordered top to bottom
$this->title = __("AgeChecked", 'agechecked-wc-addon');
// If you want to show an image next to the plugin name on the frontend, enter a URL to an image.
$this->icon = null;
// This basically defines your settings which are then loaded with init_settings()
$this->init_form_fields();
$this->init_settings();
// Turn these settings into variables we can use
foreach ($this->settings as $setting_key => $value) {
$this->$setting_key = is_string($value) ? trim($value) : $value;
}
// Save settings
if (is_admin()) {
// Versions over 2.0
// Save our administration options. Since we are not going to be doing anything special
// we have not defined 'process_admin_options' in this class so the method in the parent
// class will be used instead
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(
$this,
'process_admin_options',
));
}
add_action('wp_enqueue_scripts', array($this, 'agechecked_woocommerce_addon_enqueue_scripts'));
add_action('woocommerce_checkout_before_customer_details', array($this, 'agechecked_woocommerce_addon_ui'));
//validating
add_action('woocommerce_checkout_process', array($this, 'agechecked_woocommerce_addon_verify'));
// Saving data
add_action('woocommerce_checkout_update_order_meta', array($this, 'agechecked_woocommerce_addon_checkout_update_order_meta'));
//showing data in admin
add_action('woocommerce_admin_order_data_after_billing_address', array($this, 'agechecked_woocommerce_addon_admin_order_data_after_billing_address'), 10, 1);
load_plugin_textdomain('agechecked-wc-addon', false, dirname(plugin_basename(__FILE__)) . '/lang/');
}
function WC_compat($order, $old, $new = null, $old_is_property = true, $new_is_property = false) {
$method_property_name = !$new ? 'get_'.$old : $new;
if (!$new_is_property) {
return method_exists($order, $method_property_name) ? $order->$method_property_name() : ($old_is_property ? $order->$old : $order->$old());
} else {
return property_exists($order, $method_property_name) ? $order->$method_property_name : ($old_is_property ? $order->$old : $order->$old());
}
}
/**
* Output plugin settings to WC Checkout tab.
*/
public function admin_options() {
echo '
' . esc_html( $this->method_title ) . '
';
echo wp_kses_post( wpautop( $this->method_description ) );
parent::admin_options();
$this->checks();
}
//Plugin settings
function init_form_fields()
{
$this->form_fields = array(
'enabled' => array(
'id' => 'agechecked_wc_settings_enabled',
'title' => __('Enable/Disable', 'agechecked-wc-addon'),
'label' => __('Enable age checks on checkout', 'agechecked-wc-addon'),
'desc_tip' => __('Select to enable age checks.', 'agechecked-wc-addon'),
'type' => 'checkbox',
'default' => 'no',
),
'url' => array(
'title' => __('API URL', 'agechecked-wc-addon'),
'desc_tip' => __('Please insert the API URL provided by your agechecked.com account manager.', 'agechecked-wc-addon'),
'id' => 'agechecked_wc_settings_url',
'type' => 'text',
'css' => 'min-width:300px;',
'default' => 'https://staging.agechecked.com/api', // WC >= 2.0
'placeholder' => 'e.g. https://staging.agechecked.com/api',
'description' => __('', 'agechecked-wc-addon')
),
'public_key' => array(
'title' => __('Public Key', 'agechecked-wc-addon'),
'desc_tip' => __('Please insert the public key provided by your agechecked.com account manager.', 'agechecked-wc-addon'),
'id' => 'agechecked_wc_settings_public_key',
'type' => 'text',
'css' => 'min-width:600px;',
'default' => '', // WC >= 2.0
'description' => __('', 'agechecked-wc-addon')
),
'private_key' => array(
'title' => __('Private Key', 'agechecked-wc-addon'),
'desc_tip' => __('Please insert the private key provided by your agechecked.com account manager.', 'agechecked-wc-addon'),
'id' => 'agechecked_wc_settings_private_key',
'type' => 'text',
'css' => 'min-width:600px;',
'default' => '', // WC >= 2.0
'description' => __('', 'agechecked-wc-addon')
),
"product_category" => array(
'title' => __('Product Category', 'agechecked-wc-addon'),
'desc_tip' => __('Please enter the product category that should be age checked. Ensure category exists.', 'agechecked-wc-addon'),
'id' => 'agechecked_wc_settings_product_category',
'type' => 'text',
'default' => 'AgeChecked',
'placeholder' => 'Limit by category (e.g. AgeChecked)',
'css' => 'min-width:300px;',
'description' => __('Allocates age checks to the specified category of products. Leave empty to age check all products.', 'agechecked-wc-addon')
)
);
}
// Check if SSL is enabled and notify the user.
public function checks() {
if ( 'no' == $this->enabled ) {
return false;
}
// PHP Version
if ( version_compare( phpversion(), '5.3', '<' ) ) {
echo '
' . sprintf( __( 'AgeChecked Error: AgeChecked requires PHP 5.3 and above. You are using version %s.', 'agechecked-wc-addon' ), phpversion() ) . '