init = $init;
parent::__construct();
//set return urls
$this->set_return_urls();
//check if we need to update methods first
$this->check_channel();
//initialize all payment methods
$this->methods = new WooCommerce\Methods( $this->id, $this->init, $this->settings );
$this->set_title_by_language();
//add paylater first time notice
add_action( 'admin_notices', array( $this, 'paylater_first_time_notice' ) );
}
private function check_channel() {
global $wpdb;
$sql = "SELECT COUNT(*) AS `channel` FROM `information_schema`.`columns` WHERE `table_name`='".$wpdb->prefix . MAKECOMMERCE_TABLENAME."' AND `column_name`='channel'";
$methodstruct = $wpdb->get_results( $sql );
if ( $methodstruct[0]->channel == 0 ) {
$this->banklinks_update();
}
}
/**
* Set return urls
*
* @since 3.0.0
*/
private function set_return_urls() {
//set language
$langGet = "&lang1=" . \MakeCommerce\i18n::get_two_char_locale();
//set return url's
$this->payment_return_url = site_url( '/?makecommerce_return=1'.$langGet );
$this->payment_return_url_m2m = site_url( '/?makecommerce_return=1&ajax_content=1'.$langGet );
$this->payment_return_url_cancel = site_url( '/?makecommerce_return=1'.$langGet );
}
/**
* Set title according to language
*
* @since 3.0.0
*/
private function set_title_by_language( ) {
//default
if ( !empty( $this->settings['ui_widget_title'] ) ) {
$this->title = $this->settings['ui_widget_title'];
}
$locale = "";
if ( isset( $_GET["lang1"] ) ) {
$locale = $_GET["lang1"];
if ( !empty( $this->settings['ui_widget_title_'.$locale] ) ) {
$this->title = $this->settings['ui_widget_title_'.$locale];
}
} else {
$locale = \MakeCommerce\i18n::get_two_char_locale();
//coming from admin, set language according to order wpml_language. This meta is set for both polylang wpml
if ( isset( $_POST["meta"] ) ) {
foreach ( $_POST["meta"] as $key=>$value ) {
if ( is_array( $value ) ) {
if ( $value["key"] == "wpml_language" ) {
$locale = strtolower( substr( $value["value"], 0, 2 ) );
}
}
}
}
if ( !empty( $this->settings['ui_widget_title_' . $locale] ) ) {
$this->title = $this->settings['ui_widget_title_' . $locale];
}
}
}
/**
* Loads all form fields specific to this payment gateway
*
* @since 3.0.0
*/
public function initialize_gateway_type_form_fields() {
$this->form_fields['active'] = array(
'title' => __( 'Enable/Disable', 'wc_makecommerce_domain' ),
'type' => 'checkbox',
'label' => __( 'Enable MakeCommerce payments', 'wc_makecommerce_domain' ),
'default' => 'no'
);
$a = admin_url( 'admin.php?page=wc-settings&tab=api§ion=mk_api' );
if ( \MakeCommerce::new_woo_version() ) {
$a = admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=mk_api' );
}
$this->form_fields['api_title'] = array(
'title' => __( 'MakeCommerce API', 'wc_makecommerce_domain' ),
'description' => sprintf( __( 'Go to API settings to fill in the credentials', 'wc_makecommerce_domain' ), $a ),
'type' => 'title',
);
$this->form_fields['ui_title'] = array(
'title' => '
'.__( 'User Interface', 'wc_makecommerce_domain' ),
'type' => 'title',
'class' => 'ui-identifier',
);
$this->form_fields['ui_open_by_default'] = array(
'title' => __( 'Set as default selection', 'wc_makecommerce_domain' ),
'label' => __( 'MakeCommerce payments widget will be selected by default', 'wc_makecommerce_domain' ),
'type' => 'checkbox',
'default' => 'yes',
'class' => 'ui-identifier',
);
$this->form_fields['ui_mode'] = array(
'title' => __( 'Display MC payment channels as', 'wc_makecommerce_domain' ),
'type' => 'select',
'default' => 'widget',
'options' => array(
'inline' => __( 'List', 'wc_makecommerce_domain' ),
'widget' => __( 'Grouped to widget', 'wc_makecommerce_domain' ),
),
'class' => 'ui-identifier',
);
$languages = \MakeCommerce\i18n::get_active_languages();
if ( empty( $languages ) ) {
$this->form_fields['ui_widget_title'] = array(
'title' => __( 'Payments widget title', 'wc_makecommerce_domain' ),
'type' => 'text',
'desc_tip' => __( "Appropriate title may depend on the configuration you have made, i.e. 'pay with bank-link or credit card', 'pay with bank-links' or 'payment methods'", 'wc_makecommerce_domain' ),
'default' => __( 'Pay with bank-links or credit card', 'wc_makecommerce_domain' ),
'class' => 'ui-identifier',
);
} else {
foreach ( $languages as $language_code => $language ) {
$this->form_fields['ui_widget_title_'.$language_code] = array(
'title' => __( 'Payments widget title', 'wc_makecommerce_domain' ).sprintf( ' (%s)', $language_code ),
'type' => 'text',
'desc_tip' => __("Appropriate title may depend on the configuration you have made, i.e. 'pay with bank-link or credit card', 'pay with bank-links' or 'payment methods'", 'wc_makecommerce_domain'),
'default' => \MakeCommerce\i18n::get_string_from_mo( 'Pay with bank-links or credit card', 'wc_makecommerce_domain', $language_code ),
'class' => 'ui-identifier',
);
}
}
$this->form_fields['ui_inline_uselogo'] = array(
'title' => __( 'MC payment channels display style', 'wc_makecommerce_domain' ),
'type' => 'select',
'default' => 'logo',
'options' => array(
'logo' => __( 'Logo', 'wc_makecommerce_domain' ),
'text_logo' => __( 'Text & logo', 'wc_makecommerce_domain' ),
'text' => __( 'Text', 'wc_makecommerce_domain' ),
),
'class' => 'ui-identifier',
);
$this->form_fields['ui_widget_logosize'] = array(
'title' => __( 'Size of payment channel logos', 'wc_makecommerce_domain' ),
'type' => 'select',
'default' => 'medium',
'options' => array(
'small' => __( 'Small', 'wc_makecommerce_domain' ),
'medium' => __( 'Medium', 'wc_makecommerce_domain' ),
'large' => __( 'Large', 'wc_makecommerce_domain' )
),
'class' => 'ui-identifier',
);
$this->form_fields['ui_widget_groupcountries'] = array(
'title' => __( 'Group bank-links by countries', 'wc_makecommerce_domain' ),
'type' => 'checkbox',
'default' => 'yes',
'class' => 'ui-identifier',
);
$this->form_fields['ui_widget_countries_hidden'] = array(
'title' => __( 'Hide country selector', 'wc_makecommerce_domain' ),
'label' => __( 'Do not display country selector (flags) at payment methods', 'wc_makecommerce_domain' ),
'type' => 'checkbox',
'default' => 'no',
);
$this->form_fields['ui_widget_countryselector'] = array(
'title' => __( 'Country selector style', 'wc_makecommerce_domain' ),
'type' => 'select',
'default' => 'flag',
'options' => array(
'flag' => __( 'Flag', 'wc_makecommerce_domain' ),
'dropdown' => __( 'Dropdown', 'wc_makecommerce_domain' ),
),
'class' => 'ui-identifier',
);
$this->form_fields['ui_payment_country_order'] = array(
'title' => __( 'Define custom order of payment countries', 'wc_makecommerce_domain' ),
'type' => 'text',
'desc_tip' => __( 'If you want to change default order, insert a comma separated list of 2 char country codes. i.e. - ee, lv, lt, fi (international = other)', 'wc_makecommerce_domain' ),
'class' => 'ui-identifier',
);
$this->form_fields['ui_chorder'] = array(
'title' => __( 'Define custom order of payment channels', 'wc_makecommerce_domain' ),
'type' => 'text',
'desc_tip' => __( 'If you want to change default order, put here comma separated list of channels. i,e, - seb,lhv,swedbank. see more on the module home page (link above)', 'wc_makecommerce_domain' ),
'class' => 'ui-identifier',
);
$this->form_fields['ui_javascript'] = array(
'type' => 'ui_javascript',
);
$this->form_fields['cc_title'] = array(
'title' => '