/** * add_settings. * * @version 2.5.3 * @since 2.5.3 */ function add_settings($settings) { $settings = array(); $settings[] = array('title' => __('Payment Gateways', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('Leave empty to disable.', 'woocommerce-jetpack') . ' ' . sprintf(__('Custom roles can be added via "Add/Manage Custom Roles" tool in Booster\'s <a href="%s">General</a> module', 'woocommerce-jetpack'), admin_url('admin.php?page=wc-settings&tab=jetpack&wcj-cat=emails_and_misc§ion=general')), 'id' => 'wcj_payment_gateways_by_user_role_gateways_options'); $user_roles = wcj_get_user_roles_options(); $gateways = WC()->payment_gateways->payment_gateways(); foreach ($gateways as $key => $gateway) { $default_gateways = array('bacs'); if (!empty($default_gateways) && !in_array($key, $default_gateways)) { $custom_attributes = apply_filters('booster_get_message', '', 'disabled'); if ('' == $custom_attributes) { $custom_attributes = array(); } $desc_tip = apply_filters('booster_get_message', '', 'desc_no_link'); } else { $custom_attributes = array(); $desc_tip = ''; } $settings[] = array('title' => $gateway->title, 'desc_tip' => $desc_tip, 'desc' => __('Include User Roles', 'woocommerce-jetpack'), 'id' => 'wcj_gateways_user_roles_include_' . $key, 'default' => '', 'type' => 'multiselect', 'class' => 'chosen_select', 'css' => 'width: 450px;', 'options' => $user_roles, 'custom_attributes' => $custom_attributes); $settings[] = array('title' => '', 'desc_tip' => $desc_tip, 'desc' => __('Exclude User Roles', 'woocommerce-jetpack'), 'id' => 'wcj_gateways_user_roles_exclude_' . $key, 'default' => '', 'type' => 'multiselect', 'class' => 'chosen_select', 'css' => 'width: 450px;', 'options' => $user_roles, 'custom_attributes' => $custom_attributes); } $settings[] = array('type' => 'sectionend', 'id' => 'wcj_payment_gateways_by_user_role_gateways_options'); return $settings; }
/** * add_settings. * * @version 2.5.7 * @since 2.5.0 */ function add_settings() { $settings = array(); $settings = array_merge($settings, array(array('title' => __('Options', 'woocommerce-jetpack'), 'type' => 'title', 'id' => 'wcj_price_by_user_role_options'), array('title' => __('Enable per Product Settings', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'desc_tip' => __('When enabled, this will add new "Booster: Price by User Role" meta box to each product\'s edit page.', 'woocommerce-jetpack'), 'type' => 'checkbox', 'id' => 'wcj_price_by_user_role_per_product_enabled', 'default' => 'yes'), array('title' => __('Show Roles on per Product Settings', 'woocommerce-jetpack'), 'desc' => __('If per product settings is enabled, you can choose which roles to show on product\'s edit page. Leave blank to show all roles.', 'woocommerce-jetpack'), 'type' => 'multiselect', 'id' => 'wcj_price_by_user_role_per_product_show_roles', 'default' => '', 'class' => 'chosen_select', 'options' => wcj_get_user_roles_options()), array('title' => __('Shipping', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'desc_tip' => __('When enabled, this will apply user role multipliers to shipping calculations.', 'woocommerce-jetpack'), 'type' => 'checkbox', 'id' => 'wcj_price_by_user_role_shipping_enabled', 'default' => 'no'), array('title' => __('Search Engine Bots', 'woocommerce-jetpack'), 'desc' => __('Disable Price by User Role for Bots', 'woocommerce-jetpack'), 'id' => 'wcj_price_by_user_role_for_bots_disabled', 'default' => 'no', 'type' => 'checkbox'), array('type' => 'sectionend', 'id' => 'wcj_price_by_user_role_options'))); $settings[] = array('title' => __('Roles & Multipliers', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => sprintf(__('Custom roles can be added via "Add/Manage Custom Roles" tool in Booster\'s <a href="%s">General</a> module.', 'woocommerce-jetpack'), admin_url('admin.php?page=wc-settings&tab=jetpack&wcj-cat=emails_and_misc§ion=general')), 'id' => 'wcj_price_by_user_role_multipliers_options'); foreach (wcj_get_user_roles() as $role_key => $role_data) { $settings = array_merge($settings, array(array('title' => $role_data['name'], 'id' => 'wcj_price_by_user_role_' . $role_key, 'default' => 1, 'type' => 'number', 'custom_attributes' => array('step' => '0.000001', 'min' => '0')), array('desc' => __('Make Empty Price', 'woocommerce-jetpack'), 'id' => 'wcj_price_by_user_role_empty_price_' . $role_key, 'default' => 'no', 'type' => 'checkbox'))); } $settings[] = array('type' => 'sectionend', 'id' => 'wcj_price_by_user_role_multipliers_options'); return $settings; }
/** * add_settings. * * @version 2.5.8 * @todo rounding (maybe) */ function add_settings() { $currency_from = get_woocommerce_currency(); $all_currencies = wcj_get_currencies_names_and_symbols(); $settings = array(array('title' => __('Options', 'woocommerce-jetpack'), 'type' => 'title', 'id' => 'wcj_multicurrency_options'), array('title' => __('Exchange Rates Updates', 'woocommerce-jetpack'), 'id' => 'wcj_multicurrency_exchange_rate_update_auto', 'default' => 'manual', 'type' => 'select', 'options' => array('manual' => __('Enter Rates Manually', 'woocommerce-jetpack'), 'auto' => __('Automatically via Currency Exchange Rates module', 'woocommerce-jetpack')), 'desc' => '' == apply_filters('booster_get_message', '', 'desc') ? __('Visit', 'woocommerce-jetpack') . ' <a href="' . admin_url('admin.php?page=wc-settings&tab=jetpack&wcj-cat=prices_and_currencies§ion=currency_exchange_rates') . '">' . __('Currency Exchange Rates module', 'woocommerce-jetpack') . '</a>' : apply_filters('booster_get_message', '', 'desc'), 'custom_attributes' => apply_filters('booster_get_message', '', 'disabled')), array('title' => __('Multicurrency on per Product Basis', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'desc_tip' => __('This will add meta boxes in product edit.', 'woocommerce-jetpack'), 'id' => 'wcj_multicurrency_per_product_enabled', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Revert Currency to Default on Checkout', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'id' => 'wcj_multicurrency_revert', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Rounding', 'woocommerce-jetpack'), 'desc' => __('If using exchange rates, choose rounding here.', 'woocommerce-jetpack'), 'id' => 'wcj_multicurrency_rounding', 'default' => 'no_round', 'type' => 'select', 'options' => array('no_round' => __('No rounding', 'woocommerce-jetpack'), 'round' => __('Round', 'woocommerce-jetpack'), 'round_up' => __('Round up', 'woocommerce-jetpack'), 'round_down' => __('Round down', 'woocommerce-jetpack'))), array('title' => __('Rounding Precision', 'woocommerce-jetpack'), 'desc' => __('If rounding enabled, set precision here.', 'woocommerce-jetpack'), 'id' => 'wcj_multicurrency_rounding_precision', 'default' => absint(get_option('woocommerce_price_num_decimals', 2)), 'type' => 'number', 'custom_attributes' => array('min' => 0)), array('type' => 'sectionend', 'id' => 'wcj_multicurrency_options'), array('title' => __('Currencies Options', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('One currency probably should be set to current (original) shop currency with an exchange rate of 1.', 'woocommerce-jetpack'), 'id' => 'wcj_multicurrency_currencies_options'), array('title' => __('Total Currencies', 'woocommerce-jetpack'), 'id' => 'wcj_multicurrency_total_number', 'default' => 2, 'type' => 'custom_number', 'desc' => apply_filters('booster_get_message', '', 'desc'), 'custom_attributes' => array_merge(is_array(apply_filters('booster_get_message', '', 'readonly')) ? apply_filters('booster_get_message', '', 'readonly') : array(), array('step' => '1', 'min' => '2')))); $total_number = apply_filters('booster_get_option', 2, get_option('wcj_multicurrency_total_number', 2)); for ($i = 1; $i <= $total_number; $i++) { $currency_to = get_option('wcj_multicurrency_currency_' . $i, $currency_from); $custom_attributes = array('currency_from' => $currency_from, 'currency_to' => $currency_to, 'multiply_by_field_id' => 'wcj_multicurrency_exchange_rate_' . $i); if ($currency_from == $currency_to) { $custom_attributes['disabled'] = 'disabled'; } $settings = array_merge($settings, array(array('title' => __('Currency', 'woocommerce-jetpack') . ' #' . $i, 'id' => 'wcj_multicurrency_currency_' . $i, 'default' => $currency_from, 'type' => 'select', 'options' => $all_currencies, 'css' => 'width:250px;'), array('title' => '', 'id' => 'wcj_multicurrency_exchange_rate_' . $i, 'default' => 1, 'type' => 'exchange_rate', 'custom_attributes' => array('step' => '0.000001', 'min' => '0'), 'custom_attributes_button' => $custom_attributes, 'css' => 'width:100px;', 'value' => $currency_from . '/' . $currency_to, 'value_title' => sprintf(__('Grab %s rate from Yahoo.com', 'woocommerce-jetpack'), $currency_from . '/' . $currency_to)))); } $settings = array_merge($settings, array(array('type' => 'sectionend', 'id' => 'wcj_multicurrency_currencies_options'))); $settings = array_merge($settings, array(array('title' => __('Role Defaults', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => sprintf(__('Custom roles can be added via "Add/Manage Custom Roles" tool in Booster\'s <a href="%s">General</a> module.', 'woocommerce-jetpack'), admin_url('admin.php?page=wc-settings&tab=jetpack&wcj-cat=emails_and_misc§ion=general')), 'id' => 'wcj_multicurrency_role_defaults_options'), array('title' => __('Roles', 'woocommerce-jetpack'), 'desc' => __('Save settings after you change this option. Leave blank to disable.', 'woocommerce-jetpack'), 'type' => 'multiselect', 'id' => 'wcj_multicurrency_role_defaults_roles', 'default' => '', 'class' => 'chosen_select', 'options' => wcj_get_user_roles_options()))); $module_currencies = array(); for ($i = 1; $i <= $total_number; $i++) { $currency_code = get_option('wcj_multicurrency_currency_' . $i, $currency_from); $module_currencies[$currency_code] = $all_currencies[$currency_code]; } $module_currencies = array_unique($module_currencies); $module_roles = get_option('wcj_multicurrency_role_defaults_roles', ''); if (!empty($module_roles)) { foreach ($module_roles as $role_key) { // wcj_get_user_roles() as $role_key => $role_data $settings = array_merge($settings, array(array('title' => $role_key, 'id' => 'wcj_multicurrency_role_defaults_' . $role_key, 'default' => '', 'type' => 'select', 'options' => array_merge(array('' => __('No default currency', 'woocommerce-jetpack')), $module_currencies)))); } } $settings[] = array('type' => 'sectionend', 'id' => 'wcj_multicurrency_role_defaults_options'); return $settings; }
/** * add_settings. * * @version 2.5.4 * @since 2.5.3 */ function add_settings() { $fields = array('desc' => __('Description', 'woocommerce-jetpack'), 'short_desc' => __('Short Description', 'woocommerce-jetpack'), 'image' => __('Image', 'woocommerce-jetpack'), 'regular_price' => __('Regular Price', 'woocommerce-jetpack'), 'sale_price' => __('Sale Price', 'woocommerce-jetpack'), 'cats' => __('Categories', 'woocommerce-jetpack'), 'tags' => __('Tags', 'woocommerce-jetpack')); $fields_enabled_options = array(); $fields_required_options = array(); $i = 0; $total_fields = count($fields); foreach ($fields as $field_id => $field_desc) { $i++; $checkboxgroup = ''; if (1 === $i) { $checkboxgroup = 'start'; } elseif ($total_fields === $i) { $checkboxgroup = 'end'; } $fields_enabled_options[] = array('title' => 1 === $i ? __('Additional Fields', 'woocommerce-jetpack') : '', 'desc' => $field_desc, 'id' => 'wcj_product_by_user_' . $field_id . '_enabled', 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => $checkboxgroup, 'custom_attributes' => 'image' === $field_id ? apply_filters('booster_get_message', '', 'disabled') : '', 'desc_tip' => 'image' === $field_id ? apply_filters('booster_get_message', '', 'desc') : ''); $fields_required_options[] = array('title' => 1 === $i ? __('Is Required', 'woocommerce-jetpack') : '', 'desc' => $field_desc, 'id' => 'wcj_product_by_user_' . $field_id . '_required', 'default' => 'no', 'type' => 'checkbox', 'checkboxgroup' => $checkboxgroup, 'custom_attributes' => 'image' === $field_id ? apply_filters('booster_get_message', '', 'disabled') : '', 'desc_tip' => 'image' === $field_id ? apply_filters('booster_get_message', '', 'desc') : ''); } $settings = array_merge(array(array('title' => __('Options', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('<em>Title</em> field is always enabled and required.', 'woocommerce-jetpack'), 'id' => 'wcj_product_by_user_options')), $fields_enabled_options, $fields_required_options, array(array('title' => __('User Visibility', 'woocommerce-jetpack'), 'desc' => sprintf(__('Custom roles can be added via "Add/Manage Custom Roles" tool in Booster\'s <a href="%s">General</a> module', 'woocommerce-jetpack'), admin_url('admin.php?page=wc-settings&tab=jetpack&wcj-cat=emails_and_misc§ion=general')), 'id' => 'wcj_product_by_user_user_visibility', 'default' => array(), 'type' => 'multiselect', 'class' => 'chosen_select', 'options' => wcj_get_user_roles_options()), array('title' => __('Product Status', 'woocommerce-jetpack'), 'id' => 'wcj_product_by_user_status', 'default' => 'draft', 'type' => 'select', 'options' => get_post_statuses()), array('title' => __('Require Unique Title', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'id' => 'wcj_product_by_user_require_unique_title', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Add "My Products" Tab to User\'s My Account Page', 'woocommerce-jetpack'), 'desc' => __('Add', 'woocommerce-jetpack'), 'id' => 'wcj_product_by_user_add_to_my_account', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Message: Product Successfully Added', 'woocommerce-jetpack'), 'id' => 'wcj_product_by_user_message_product_successfully_added', 'default' => __('"%product_title%" successfully added!', 'woocommerce-jetpack'), 'type' => 'text', 'css' => 'width:300px;'), array('title' => __('Message: Product Successfully Edited', 'woocommerce-jetpack'), 'id' => 'wcj_product_by_user_message_product_successfully_edited', 'default' => __('"%product_title%" successfully edited!', 'woocommerce-jetpack'), 'type' => 'text', 'css' => 'width:300px;'), array('type' => 'sectionend', 'id' => 'wcj_product_by_user_options'))); return $settings; }
/** * get_meta_box_options. * * @version 2.5.6 * @since 2.5.5 */ function get_meta_box_options() { $options = array(array('name' => 'wcj_product_by_user_role_visible', 'default' => '', 'type' => 'select', 'options' => wcj_get_user_roles_options(), 'multiple' => true, 'title' => __('Visible for User Roles', 'woocommerce-jetpack'), 'tooltip' => __('Hold Control (Ctrl) key to select multiple roles.', 'woocommerce-jetpack'))); return $options; }
/** * add_settings. * * @version 2.5.7 * @since 2.5.5 */ function add_settings() { $products = apply_filters('wcj_get_products_filter', array()); $settings = array(array('title' => __('Options', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('Wholesale Price Levels Options. If you want to display prices table on frontend, use [wcj_product_wholesale_price_table] shortcode.', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_general_options'), array('title' => __('Enable per Product', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_per_product_enable', 'default' => 'yes', 'type' => 'checkbox'), array('title' => __('Use total cart quantity instead of product quantity', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_use_total_cart_quantity', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Apply wholesale discount only if no other cart discounts were applied', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_apply_only_if_no_other_discounts', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Show discount info on cart page', 'woocommerce-jetpack'), 'desc' => __('Show', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_show_info_on_cart', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('If show discount info on cart page is enabled, set format here', 'woocommerce-jetpack'), 'desc_tip' => __('Replaced values: %old_price%, %price%, %discount_value%.', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_show_info_on_cart_format', 'default' => '<del>%old_price%</del> %price%<br>You save: <span style="color:red;">%discount_value%</span>', 'type' => 'textarea', 'css' => 'width: 450px;'), array('title' => __('Discount Type', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_discount_type', 'default' => 'percent', 'type' => 'select', 'options' => array('percent' => __('Percent', 'woocommerce-jetpack'), 'fixed' => __('Fixed', 'woocommerce-jetpack'))), array('title' => __('Products to include', 'woocommerce-jetpack'), 'desc' => __('Leave blank to include all products.', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_products_to_include', 'default' => '', 'type' => 'multiselect', 'class' => 'chosen_select', 'options' => $products), array('title' => __('Products to exclude', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_products_to_exclude', 'default' => '', 'type' => 'multiselect', 'class' => 'chosen_select', 'options' => $products), array('type' => 'sectionend', 'id' => 'wcj_wholesale_price_general_options'), array('title' => __('Wholesale Levels Options', 'woocommerce-jetpack'), 'type' => 'title', 'id' => 'wcj_wholesale_price_level_options'), array('title' => __('Number of levels', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_levels_number', 'default' => 1, 'type' => 'custom_number', 'desc' => apply_filters('booster_get_message', '', 'desc'), 'custom_attributes' => array_merge(is_array(apply_filters('booster_get_message', '', 'readonly')) ? apply_filters('booster_get_message', '', 'readonly') : array(), array('step' => '1', 'min' => '1')), 'css' => 'width:100px;')); for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_wholesale_price_levels_number', 1)); $i++) { $settings[] = array('title' => __('Min quantity', 'woocommerce-jetpack') . ' #' . $i, 'desc' => __('Minimum quantity to apply discount', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_level_min_qty_' . $i, 'default' => 0, 'type' => 'number', 'custom_attributes' => array('step' => '1', 'min' => '0')); $settings[] = array('title' => __('Discount', 'woocommerce-jetpack') . ' #' . $i, 'desc' => __('Discount', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_level_discount_percent_' . $i, 'default' => 0, 'type' => 'number', 'custom_attributes' => array('step' => '0.0001')); } $settings[] = array('type' => 'sectionend', 'id' => 'wcj_wholesale_price_level_options'); $settings = array_merge($settings, array(array('title' => __('Additional User Roles Options', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('If you want to set different wholesale pricing options for different user roles, fill this section. Please note that you can also use Booster\'s "Price by User Role" module without filling this section.', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_by_user_role_options'), array('title' => __('User Roles Settings', 'woocommerce-jetpack'), 'desc' => __('Save settings after you change this option. Leave blank to disable.', 'woocommerce-jetpack'), 'type' => 'multiselect', 'id' => 'wcj_wholesale_price_by_user_role_roles', 'default' => '', 'class' => 'chosen_select', 'options' => wcj_get_user_roles_options()))); $user_roles = get_option('wcj_wholesale_price_by_user_role_roles', ''); if (!empty($user_roles)) { foreach ($user_roles as $user_role_key) { $settings = array_merge($settings, array(array('title' => __('Number of levels', 'woocommerce-jetpack') . ' [' . $user_role_key . ']', 'id' => 'wcj_wholesale_price_levels_number_' . $user_role_key, 'default' => 1, 'type' => 'custom_number', 'desc' => apply_filters('booster_get_message', '', 'desc'), 'custom_attributes' => array_merge(is_array(apply_filters('booster_get_message', '', 'readonly')) ? apply_filters('booster_get_message', '', 'readonly') : array(), array('step' => '1', 'min' => '1')), 'css' => 'width:100px;'))); for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_wholesale_price_levels_number_' . $user_role_key, 1)); $i++) { $settings = array_merge($settings, array(array('title' => __('Min quantity', 'woocommerce-jetpack') . ' #' . $i . ' [' . $user_role_key . ']', 'desc' => __('Minimum quantity to apply discount', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_level_min_qty_' . $user_role_key . '_' . $i, 'default' => 0, 'type' => 'number', 'custom_attributes' => array('step' => '1', 'min' => '0')), array('title' => __('Discount', 'woocommerce-jetpack') . ' #' . $i . ' [' . $user_role_key . ']', 'desc' => __('Discount', 'woocommerce-jetpack'), 'id' => 'wcj_wholesale_price_level_discount_percent_' . $user_role_key . '_' . $i, 'default' => 0, 'type' => 'number', 'custom_attributes' => array('step' => '0.0001')))); } } } $settings[] = array('type' => 'sectionend', 'id' => 'wcj_wholesale_price_by_user_role_options'); return $settings; }