array( 'name' => __('Custom text change', 'wfm-text'), 'type' => 'title', 'desc' => __('Change default text of the woocommerce', 'wfm-text'), 'id' => 'wfm_settings_tab_custom_section_title_custom_text' ), 'add-to-cart' => array( 'name' => __('Add to cart', 'wfm-text'), 'type' => 'text', 'id' => 'wfm_settings_tab_custom_add-to-cart' ), 'checkout' => array( 'name' => __('Checkout', 'wfm-text'), 'type' => 'text', 'id' => 'wfm_settings_tab_custom_checkout' ), 'place-order' => array( 'name' => __('Place Order', 'wfm-text'), 'type' => 'text', 'id' => 'wfm_settings_tab_custom_place-order' ), 'section_end' => array( 'type' => 'sectionend', 'id' => 'wfm_settings_tab_custom_section_end_text' ), // set default product image 'section_title_image' => array( 'name' => __('Change woocommerce Default image', 'wfm-text'), 'type' => 'title', 'desc' => __('Change Default image of the woocommerce products', 'wfm-text'), 'id' => 'wfm_settings_tab_custom_section_title_image' ), 'default-images' => array( 'name' => __('Default Image', 'wfm-text'), 'type' => 'image', 'id' => 'wfm_settings_tab_custom_default_image' ), 'section_end_image' => array( 'type' => 'sectionend', 'id' => 'wfm_settings_tab_custom_section_end_image' ), //Add / Update SKU 'section_title_sku' => array( 'name' => __('Pre-define SKU', 'wfm-text'), 'type' => 'title', 'desc' => __('Add/Update Sku of the woocommerce products', 'wfm-text'), 'id' => 'wfm_settings_tab_custom_section_title_sku' ), 'pre-define add sku' => array( 'name' => __('Enable Feature', 'wfm-text'), 'type' => 'checkbox', 'css' => 'min-width:300px;', 'id' => 'wfm_settings_tab_custom_add_sku' ), 'section_end_sku' => array( 'type' => 'sectionend', 'id' => 'wfm_settings_tab_custom_section_end_sku' ), //change text of out of stock 'section_title_stock' => array( 'name' => __('Change text of "Out Of Stock"', 'wfm-text'), 'type' => 'title', 'desc' => __('Change text of the woocommerce out of stock', 'wfm-text'), 'id' => 'wfm_settings_tab_custom_section_title_stock' ), 'selection-stock-text' => array( 'name' => __('Select Option', 'wfm-text'), 'type' => 'select', 'options' => array( 'none' => __('None', 'wfm-text'), 'global' => __('Globally', 'wfm-text'), 'admin_side_changes' => __('Manually', 'wfm-text'), ), 'desc' => $desc, 'id' => 'wfm_settings_tab_custom_out_of_stock_selection_value' ), 'out-of-stock' => array( 'name' => __('Out of Stock', 'wfm-text'), 'type' => 'text', 'id' => 'wfm_settings_tab_custom_out_of_stock', 'class' => $hidden_class, ), 'section_end_stock' => array( 'type' => 'sectionend', 'id' => 'wfm_settings_tab_custom_section_end_stock' ), ); return apply_filters('wc_settings_tab_custom_settings', $settings); } } WFM_Settings_Tab_Custom::init(); /** * To change text of add to cart * * @since 1.0.0 */ if (!function_exists('wfm_custom_cart_button_text')) { add_filter('add_to_cart_text', 'wfm_custom_cart_button_text'); add_filter('woocommerce_product_add_to_cart_text', 'wfm_custom_cart_button_text'); add_filter('woocommerce_product_single_add_to_cart_text', 'wfm_custom_cart_button_text'); function wfm_custom_cart_button_text($add_to_cart_real_text) { $add_to_cart_text = get_option('wfm_settings_tab_custom_add-to-cart'); if ($add_to_cart_text != '') { return __($add_to_cart_text, 'wfm-text'); } else { return $add_to_cart_real_text; } } } /** * To change text of checkout button * * @since 1.0.0 */ if (!function_exists('wfm_custom_checkout_button_text')) { add_action('woocommerce_proceed_to_checkout', 'wfm_custom_checkout_button_text'); function wfm_custom_checkout_button_text() { $checkout_text = get_option('wfm_settings_tab_custom_checkout'); $checkout_url = wc_get_checkout_url(); if ($checkout_text != '') { remove_action('woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20); ?> post_type != 'product') { return; } if (isset($_REQUEST['_sku']) && $_REQUEST['_sku'] != NULL) { return; } $post_id = $post->ID; $post_title = $post->post_title; $post_sku = $post_id . '-' . $post_title; update_post_meta($post_id, '_sku', $post_sku); } } } /** * To change text of Out of stock * * @global array $post * @param array $availability * @return string * * @since 1.0.0 */ if (!function_exists('wfm_change_text_out_of_stock')) { add_filter('woocommerce_get_availability', 'wfm_change_text_out_of_stock', 10, 2); function wfm_change_text_out_of_stock($availability) { global $post; if ($availability['class'] == 'out-of-stock') { $selection = get_option('wfm_settings_tab_custom_out_of_stock_selection_value'); if ($selection == 'global') { $out_of_stock_text = get_option('wfm_settings_tab_custom_out_of_stock'); if ($out_of_stock_text != NULL) { $availability['availability'] = $out_of_stock_text; } } elseif ($selection == 'admin_side_changes') { $stock_value = get_post_meta($post->ID, '_stock_value'); $stock_status = get_post_meta($post->ID, '_stock_status'); // echo $stock_status[0];exit; if ($stock_value != NULL && $stock_status[0] == 'outofstock') { $availability['availability'] = $stock_value[0]; } } return $availability; } } } /** * To add custom text field in admin side inventory tab. it's change text of single product of out of stock-text * * @global array $post * * @since 1.0.0 */ if (!function_exists('wfm_add_custom_field_inventory_product_data')) { add_action('woocommerce_product_options_inventory_product_data', 'wfm_add_custom_field_inventory_product_data', 10, 0); function wfm_add_custom_field_inventory_product_data() { global $post; $selection = get_option('wfm_settings_tab_custom_out_of_stock_selection_value'); if ($selection == 'admin_side_changes') { $product_stock = get_post_meta($post->ID, '_stock_value', true); echo '
'; } } } /** * To display text on inventory custom text field in admin side * * @param int $post_id * * @since 1.0.0 */ if (!function_exists('wfm_save_the_stock_to_invetory_product_field')) { add_action('woocommerce_process_product_meta', 'wfm_save_the_stock_to_invetory_product_field'); function wfm_save_the_stock_to_invetory_product_field($post_id) { $wc_field = $_POST['_stock_value']; if (!empty($wc_field)) { update_post_meta($post_id, '_stock_value', sanitize_text_field($wc_field)); } } } /** * To add custom css for show/hide text field of out of stock * * @since 1.0.0 */ if (!function_exists('wfm_custom_style')) { add_action('admin_footer', 'wfm_custom_style'); function wfm_custom_style() { ?>| ($data['id'] . '-button'), 'option_name' => ($data['id']), 'data' => ($value), 'type' => 'button', )); ?> |