#tabby_countries option {padding: 10px;} input:invalid { border: red solid 3px;}"; echo self::getSettingsValidationScript(); woocommerce_admin_fields( static::tabby_checkout_api_settings([], 'tabby_api') ); } public static function tabby_update_settings() { $share_feed_old = get_option('tabby_share_feed', 'yes'); woocommerce_update_options( static::tabby_checkout_api_settings([], 'tabby_api') ); WC_Tabby_Webhook::register(); $share_feed_new = get_option('tabby_share_feed', 'yes'); if ($share_feed_old !== 'yes' && $share_feed_new === 'yes') { WC_Tabby_Feed_Sharing::register(); }; if ($share_feed_new !== 'yes') { WC_Tabby_Feed_Sharing::unregister(); }; } public static function sanitize_public_key($value) { $value = trim($value); $msg = null; if (!preg_match("#^pk_(test_)?[\da-f]{8}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{12}$#", $value)) { $msg = '

Wrong PUBLIC key format. Must be: pk_[test_]xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

'; $value = ''; } add_action( 'admin_notices', function() use($msg) { if ($msg) echo $msg; }); return $value; } public static function sanitize_secret_key($value) { $value = trim($value); $msg = null; if (!preg_match("#^sk_(test_)?[\da-f]{8}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{12}$#", $value)) { $msg = '

Wrong SECRET key format. Must be: sk_[test_]xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

'; $value = ''; } add_action( 'admin_notices', function() use($msg) { if ($msg) echo $msg; }); return $value; } public static function tabby_checkout_api_settings( $settings, $current_section ) { if ( $current_section == 'tabby_api' ) { $settings_tabby = array(); $settings_tabby[] = array( 'name' => __( 'Tabby Checkout API', 'tabby-checkout' ), 'type' => 'title', 'desc' => __( 'The following options are used to configure Tabby Checkout API', 'tabby-checkout' ), 'id' => 'tabby-checkout' ); $settings_tabby[] = array( 'name' => __( 'Share product feed with Tabby', 'tabby-checkout' ), 'id' => 'tabby_share_feed', 'type' => 'checkbox', 'default' => 'yes' ); $settings_tabby[] = array( 'name' => __( 'Plugin mode', 'tabby-checkout' ), 'id' => 'tabby_checkout_mode', 'type' => 'select', 'desc' => __( 'Operational mode: Payment gateway or promotions only', 'tabby-checkout' ), 'options' => [ 'payment' => __('Payment gateway', 'tabby-checkout'), 'promo' => __('Promo only', 'tabby-checkout') ], 'default' => 'payment' ); $settings_tabby[] = array( 'name' => __( 'Merchant Public Key', 'tabby-checkout' ), 'id' => 'tabby_checkout_public_key', 'type' => 'password', 'class' => 'promo-hidden', 'desc' => __( 'Used for public API calls
pk_[test_]xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'tabby-checkout' ), 'custom_attributes' => array( 'minlength' => 39, 'maxlength' => 44 ), ); $settings_tabby[] = array( 'name' => __( 'Merchant Secret Key', 'tabby-checkout' ), 'id' => 'tabby_checkout_secret_key', 'type' => 'password', 'class' => 'promo-hidden', 'desc' => __( 'Used for server to server calls
sk_[test_]xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'tabby-checkout' ), 'custom_attributes' => array( 'minlength' => 39, 'maxlength' => 44 ), ); $settings_tabby[] = array( 'name' => __( 'Tabby Language', 'tabby-checkout' ), 'id' => 'tabby_checkout_popup_language', 'type' => 'select', 'desc' => __( 'Tabby popup language', 'tabby-checkout' ), 'options' => [ 'auto' => __('Auto', 'tabby-checkout'), 'en' => __('English', 'tabby-checkout'), 'ar' => __('Arabic', 'tabby-checkout') ], 'default' => 'auto' ); $settings_tabby[] = array( 'name' => __( 'Tabby order timeout, mins', 'tabby-checkout' ), 'id' => 'tabby_checkout_order_timeout', 'type' => 'text', 'class' => 'promo-hidden', 'desc' => __( 'Used for deleting unpaid orders', 'tabby-checkout' ), 'type' => 'number', 'custom_attributes' => array( 'min' => 0, 'step' => 1, ), 'css' => 'width: 80px;', 'default' => '20', 'autoload' => false, ); $settings_tabby[] = array( 'name' => __( 'Action on Failed Payment', 'tabby-checkout' ), 'id' => 'tabby_checkout_failed_action', 'type' => 'text', 'desc' => __( 'Delete or cancel unpaid orders', 'tabby-checkout' ), 'type' => 'select', 'class' => 'promo-hidden', 'options' => [ 'delete' => __('Cancel & Delete', 'tabby-checkout'), 'trash' => __('Cancel & Move to Trash', 'tabby-checkout'), 'cancel' => __('Cancel Only', 'tabby-checkout') ], 'css' => 'width: 180px;', 'default' => 'delete' ); $settings_tabby[] = array( 'name' => __( 'Use phone number for order history lookup', 'tabby-checkout' ), 'id' => 'tabby_checkout_use_phone', 'type' => 'checkbox', 'class' => 'promo-hidden', 'desc' => __( 'Add order history by phone', 'tabby-checkout' ), 'default' => 'yes' ); $settings_tabby[] = array( 'name' => __( 'Capture payment on checkout', 'tabby-checkout' ), 'id' => 'tabby_checkout_capture', 'type' => 'checkbox', 'class' => 'promo-hidden', 'desc' => __( 'Enable payment capture on checkout', 'tabby-checkout' ), 'default' => 'yes' ); $settings_tabby[] = array( 'name' => __( 'Tabby promotions (product)', 'tabby-checkout' ), 'id' => 'tabby_promo', 'type' => 'checkbox', 'desc' => __( 'Enable Tabby promo on product view pages', 'tabby-checkout' ), 'default' => 'yes' ); $settings_tabby[] = array( 'name' => __( 'Tabby promotions (cart page)', 'tabby-checkout' ), 'id' => 'tabby_promo_cart', 'type' => 'checkbox', 'desc' => __( 'Enable Tabby promo on shopping cart page', 'tabby-checkout' ), 'default' => 'yes' ); $settings_tabby[] = array( 'name' => __( 'Minimum price for Tabby promo', 'tabby-checkout' ), 'id' => 'tabby_checkout_promo_min_total', 'type' => 'text', 'desc' => __( 'Minimum price showing Tabby promotions, 0 for unlimited', 'tabby-checkout' ), 'type' => 'number', 'custom_attributes' => array( 'min' => 0, 'step' => 1, ), 'css' => 'width: 80px;', 'default' => '0', 'autoload' => false, ); $settings_tabby[] = array( 'name' => __( 'Tabby promo max price', 'tabby-checkout' ), 'id' => 'tabby_checkout_promo_price', 'type' => 'text', 'desc' => __( 'Maximum product price for showing Tabby promotions, 0 for unlimited', 'tabby-checkout' ), 'type' => 'number', 'custom_attributes' => array( 'min' => 0, 'step' => 1, ), 'css' => 'width: 80px;', 'default' => '0', 'autoload' => false, ); /* $settings_tabby[] = array( 'name' => __( 'Promotion snippets (additional settings)', 'tabby-checkout' ), 'id' => 'tabby_checkout_promo_type_price', 'type' => 'text', 'desc' => __( 'Please use this settings only in case if you have the recommendations from Tabby team.

Set up -1 for Standard promotion snippets as a default value
Set up 0 for Credit Card installments promotion snippets as a default value
Set up the limit between 0 - 50000 to show Standard promotion snippets for the amount which is lower than the limit and Credit Card installments promotion snippets for the amount which is higher than the limit. ', 'tabby-checkout' ), 'type' => 'number', 'custom_attributes' => array( 'min' => -1, 'step' => 1, ), 'css' => 'width: 80px;', 'default' => '-1', 'autoload' => false, ); */ $settings_tabby[] = array( 'name' => __( 'Tabby promotions theme', 'tabby-checkout' ), 'id' => 'tabby_checkout_promo_theme', 'type' => 'text', 'desc' => __( 'Used for styling Tabby promotions widget (blank for default)', 'tabby-checkout' ), ); $settings_tabby[] = array( 'name' => __( 'Disable for SKUs (one per line)', 'tabby-checkout' ), 'id' => 'tabby_checkout_disable_for_sku', 'custom_attributes' => array( 'rows' => 8 ), 'type' => 'textarea', 'desc' => __( 'Disable promotions and checkout process for specific SKUs', 'tabby-checkout' ), ); $countries = new WC_Countries(); $options = []; foreach (WC_Tabby_Config::ALLOWED_COUNTRIES as $code) { $options[$code] = __($countries->countries[$code], 'tabby-checkout'); } asort($options); $settings_tabby[] = array( 'name' => __( 'Allowed Countries', 'tabby-checkout' ), 'id' => 'tabby_countries', 'type' => 'multiselect', 'class' => 'promo-hidden', 'desc' => __( 'Tabby allowed countries', 'tabby-checkout' ), 'options' => $options, 'default' => WC_Tabby_Config::ALLOWED_COUNTRIES ); $settings_tabby[] = array( 'name' => __( 'Use tag lang', 'tabby-checkout' ), 'id' => 'tabby_checkout_locale_html', 'type' => 'checkbox', 'desc' => __( 'Use documentElement lang attribute for tabby language', 'tabby-checkout' ), ); $settings_tabby[] = array( 'name' => __( 'Hide methods', 'tabby-checkout' ), 'id' => 'tabby_checkout_hide_methods', 'type' => 'checkbox', 'class' => 'promo-hidden', 'desc' => __( 'Hide Tabby payment methods on checkout if not available', 'tabby-checkout' ), ); $settings_tabby[] = array( 'name' => __( 'Debug', 'tabby-checkout' ), 'id' => 'tabby_checkout_debug', 'type' => 'checkbox', 'class' => 'promo-hidden', 'desc' => __( 'Enable API request/reply logging', 'tabby-checkout' ), 'default' => 'yes' ); $settings_tabby[] = array( 'type' => 'sectionend', 'id' => 'tabby_api' ); return $settings_tabby; } else { return $settings; } } static public function getSettingsValidationScript() { return ' '; } }