product_type; //Cogemos el valor de la variable de la bd y si no por defecto $texto_single = 'Add to cart'; //esc_attr (get_option ('add_to_cart_single', 'Add to cart'); $texto_externo = esc_attr (get_option ('add_to_cart_external', 'Buy product')); $texto_agrupado = esc_attr (get_option ('add_to_cart_grouped', 'View products')); $texto_simple = esc_attr (get_option ('add_to_cart_simple', 'Add to cart')); $texto_variable = esc_attr (get_option ('add_to_cart_variable', 'Select options')); $texto_bookable = esc_attr (get_option ('add_to_cart_bookable', 'Book now')); $texto_externo_single = esc_attr (get_option ('add_to_cart_external_single', $texto_externo)); $texto_agrupado_single = esc_attr (get_option ('add_to_cart_grouped_single', $texto_single)); $texto_simple_single = esc_attr (get_option ('add_to_cart_simple_single', $texto_single)); $texto_variable_single = esc_attr (get_option ('add_to_cart_variable_single', $texto_single)); $texto_bookable_single = esc_attr (get_option ('add_to_cart_bookable_single', $texto_bookable)); if (is_product ()) { //Para la página de producto switch ($product_type) { case 'external': return __($texto_externo_single, 'woocommerce'); break; case 'grouped': return __($texto_agrupado_single, 'woocommerce'); break; case 'simple': return __($texto_simple_single, 'woocommerce'); break; case 'variable': return __($texto_variable_single, 'woocommerce'); break; // case 'booking': // return __($texto_bookable_single, 'woocommerce-bookings'); // break; default: return __($texto_single, 'woocommerce'); } } else { //Para las páginas de archivo switch ($product_type) { case 'external': return __($texto_externo, 'woocommerce'); break; case 'grouped': return __($texto_agrupado, 'woocommerce'); break; case 'simple': return __($texto_simple, 'woocommerce'); break; case 'variable': return __($texto_variable, 'woocommerce'); break; case 'booking': return __($texto_bookable, 'woocommerce-bookings'); break; default: return __($texto_single, 'woocommerce'); } } } add_filter ('add_to_cart_text', 'er_cambia_texto_boton'); //Compatibilidad para WooCommerce <2.1 add_filter ('woocommerce_product_add_to_cart_text', 'er_cambia_texto_boton'); add_filter ('woocommerce_product_single_add_to_cart_text', 'er_cambia_texto_boton'); //Creamos el menú de opciones function er_crea_menu_opciones () { add_options_page ('Add to Cart Custom Text', 'Add to Cart Button', 'manage_options', 'add-to-cart', 'er_add_to_cart_opciones'); } //Registramos las opciones function er_registra_opciones () { //register_setting ('addtocart-opciones', 'add_to_cart_single'); register_setting ('addtocart-opciones', 'add_to_cart_external'); register_setting ('addtocart-opciones', 'add_to_cart_grouped'); register_setting ('addtocart-opciones', 'add_to_cart_simple'); register_setting ('addtocart-opciones', 'add_to_cart_variable'); register_setting ('addtocart-opciones', 'add_to_cart_external_single'); register_setting ('addtocart-opciones', 'add_to_cart_grouped_single'); register_setting ('addtocart-opciones', 'add_to_cart_simple_single'); register_setting ('addtocart-opciones', 'add_to_cart_variable_single'); if (is_plugin_active ('woocommerce-bookings/woocommmerce-bookings.php')) { register_setting ('addtocart-opciones', 'add_to_cart_bookable'); // register_setting ('addtocart-opciones', 'add_to_cart_bookable_single'); } } if (is_admin ()) { add_action ('admin_menu', 'er_crea_menu_opciones'); add_action ('admin_init', 'er_registra_opciones'); } //Y creamos la página de opciones function er_add_to_cart_opciones () { if (!is_plugin_active ('woocommerce/woocommerce.php')) //Comprobamos que WooCommerce está instalado y activo wp_die (__('This plugin has no sense without WooCommerce. Please, activate WooCommerce first.', 'add-to-cart-custom-text')); if (!current_user_can ('manage_options')) //Comprobamos si el usuario tiene permisos para acceder a las opciones wp_die (__('You do not have sufficient permissions to access this page.')); ?>

', 'add-to-cart-custom-text').__('Add to cart', 'woocommerce').__(' button in single product pages by product type', 'add-to-cart-custom-text'); ?>


', 'add-to-cart-custom-text').__('Add to cart', 'woocommerce').__(' button in archive pages (shop, category, tags...) by product type', 'add-to-cart-custom-text'); ?>

''.__('Settings').''); $mienlace = array ('support' => ''.__('Visit me', 'add-to-cart-custom-text').''); $damelinks = array_merge ($settings, $damelinks); $damelinks = array_merge ($mienlace, $damelinks); } return $damelinks; } add_filter ('plugin_action_links', 'er_enlaces', 10, 5);