Created
December 6, 2015 16:39
-
-
Save edinsoncs/3bfec612072bcf69607d to your computer and use it in GitHub Desktop.
wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////// | |
// // | |
// WORDPRESS // | |
// PLUGIN: WOOCOMMERCE // | |
// NOTAS SOBRE PROBLEMAS Y SOLUCIONES // | |
// // | |
/////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////// | |
// // | |
// PROBLEMAS // | |
// // | |
/////////////////////////////////////////////////////////////////// | |
------------------------------------------------------------------- | |
UN TEMA INHABILITA TODO EL AJAX DE WORDPRESS | |
------------------------------------------------------------------- | |
El tema Wootique (no he probado otros temas) de Woocommerce | |
inhabilita todos los botones y procesos que involucran AJAX en | |
todo el administrador de Wordpress (como guardar un post o usar | |
la edición rápida en el listado de posts). | |
El problema reside en el archivo functions.php del tema que invoca | |
unos archivos js que añaden funcionalidades al administrador de WP | |
(como personalizar el tema, agregar widgets, etc) a travez de | |
WooFramework. | |
Probablemente esto se puede solucionar actualizando el tema y el | |
framework pero este proceso no funciona (porque AJAX está | |
desactivado). Tampoco funciona bajar nuevamente el tema porque | |
el problema persiste (al parecer, a la fecha WooCommerce desconoce | |
este problema). | |
También podemos intentar comentando las lineas que llaman a los | |
archivos o el hook que los incluye en el administrador (dentro de | |
functions.php) pero eso inhabilita toda la tienda (tampoco es buena | |
idea estar desactivando líneas cuando querramos usar el admin y | |
luego activarlas para la tienda). | |
ÚNICA SOLUCION VIABLE ENCONTRADA | |
Desactivar el tema o esperar a que la gente de Woocommerce | |
lance una solucion en el mismo tema descargable. | |
------------------------------------------------------------------- | |
SOBRE LAS TRADUCCIONES | |
------------------------------------------------------------------- | |
Woocommerce no se lleva bien con mi instalación de Wordpress en | |
español y por eso cuando instalo los archivos .po y actives una | |
nueva traducción en wp-config.php el sitio muestra un error 500. | |
No permite acceder al frontend ni al backend por lo que solo | |
quedará desactivar el nuevo idioma o desactivar el plugin | |
WooCommerce desde PhpMyAdmin. Solo así el sitio volverá a | |
funcionar. | |
SOLUCIÓN COMPROBADA | |
El problema en verdad era un "memory exhaust". Para identificarlo | |
en el .htaccess agregué la línea: | |
php_flag display_errors on | |
De esta forma Wordpress me mostró la causa que estaba generando | |
el error 500: | |
Fatal error: Allowed memory size of xxx bytes exhausted | |
(tried to allocate 1000 bytes) in /xxx/xxx.php on line xxx | |
Para solucionarlo bastó aumentarle la memoria a Wordpress | |
a traves del archivo wp-config: | |
define('WP_MEMORY_LIMIT', '64M'); | |
Si esto no lo soluciona prueba a aumentar a más memoria | |
o hacerlo con el mismo fichero .htaccess: | |
php_value memory_limit 64M | |
/////////////////////////////////////////////////////////////////// | |
// // | |
// HOW TO's // | |
// // | |
/////////////////////////////////////////////////////////////////// | |
------------------------------------------------------------------- | |
CREAR PLANTILLAS - LA ESTRUCTURA DE ARCHIVOS | |
------------------------------------------------------------------- | |
Las tiendas de WooCommerce primero buscan los archivos de | |
plantilla dentro de la carpeta woocommerce de nuestro tema: | |
/wp-content/themes/-mi-tema-/woocommerce, | |
pero al no encontrar dicha carpeta usa los predefinidos en: | |
/wp-content/plugins/woocommerce/templates/ | |
Entonces para poder empezar a trabajar nuestra propiaa plantilla | |
empezaremos copiando la carpeta templates del plugin a nuestra | |
plantilla. En este caso estoy usando el tema TwentyEleven por lo | |
que quedaría así: | |
/wp-content/themes/twentyeleven/templates/ | |
luego le cambiamos el nombre "templates" a "woocommerce" para que | |
la tienda lo identifique. De esta manera, WooCommerce usará esos | |
archivos como plantilla en ves de los predeterminados. | |
------------------------------------------------------------------- | |
MODIFICAR LOS CAMPOS DEL FORMULARIO DE CHECKOUT | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
// Filtro para empezar con los cambios | |
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields' ); | |
// Función que contiene los cambios | |
function custom_woocommerce_billing_fields( $fields ) | |
{ | |
// Modificar la etiqueta de un campo | |
$fields['billing_first_name']['label'] = 'Your label'; | |
// Modificar si un campo es requerido, o no | |
$fields['billing_first_name']['required'] = false; | |
// Hacer que el campo de dirección sea más ancho | |
$fields['billing_address_1']['class'] = array( 'form-row-wide' ); | |
$fields['billing_address_2']['class'] = array( 'form-row-wide' ); | |
// Todas las opciones de modificación | |
$fields['billing_postcode'] = array( | |
'label' => __('Postcode', 'woothemes'), | |
'placeholder' => __('Postcode', 'woothemes'), | |
'required' => true, | |
'class' => array('form-row-last update_totals_on_change') | |
); | |
// Nota: placeholder es el texto que aparece encima del | |
// campo y que desaparece al hacer clic para escribi | |
// Agregar un nuevo campo | |
$fields['nuevo'] = array( | |
'name' => 'nuevo_nombre', | |
'type' => 'checkbox', | |
'label' => __('Al enviar un pedido, usted acepta haber leído, entendido y aceptado nuestros Términos y Condiciones.', 'woothemes'), | |
'placeholder' => __('Texto por defecto que aparece en el campo', 'woothemes'), | |
'required' => true, | |
'class' => array('notes') | |
); | |
/* Totos los elementos que pueden modificarse: | |
billing_first_name | |
billing_last_name | |
billing_company | |
billing_address_1 | |
billing_address_2 | |
billing_city | |
billing_postcode | |
billing_country | |
billing_state | |
billing_email | |
billing_phone | |
*/ | |
return $fields; | |
} | |
------------------------------------------------------------------- | |
AGREGAR UN NUEVO TAB A LA VISTA DE PRODUCTO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_action('woocommerce_product_tabs','tab_name'); | |
add_action('woocommerce_product_tab_panels','tab_panel'); | |
function tab_name() | |
{ echo '<li><a href="#tab-name"> Tab Name </a></li>'; } | |
function tab_panel() | |
{ echo '<div class="panel" id="tab-name">'; | |
echo '<h2>This is a cool tab</h2>'; | |
echo '<p>Why yes it is.</p>'; | |
echo '</div>'; | |
} | |
------------------------------------------------------------------- | |
DEJAR DE USAR LOS ESTILOS PROPIOS DE WOOCOMMERCE | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
Con este snippet los estilos propios de WooCommerce (como botones, | |
formularios, tabs, etc) dejarán de funcionar con el objetivo de | |
aplicar únicamente los definidos en las hojas de estilo del tema: | |
define('WOOCOMMERCE_USE_CSS', false); | |
------------------------------------------------------------------- | |
DEJAR DE USAR CSS DE WOOCOMMERCE EN LA PÁGINA DE PRODUCTO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_action( 'wp_enqueue_scripts', 'rcd_exclude_css_from_shop' ); | |
function rcd_exclude_css_from_shop() | |
{ if( is_shop() ) | |
{ wp_dequeue_style('woocommerce_frontend_styles'); } | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
EJEMPLO DE LOOP DE PRODUCTOS | |
------------------------------------------------------------------- | |
<ul class="products"> | |
<?php | |
$args = array( 'post_type' => 'product', 'posts_per_page' => 12 ); | |
$loop = new WP_Query( $args ); | |
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> | |
<li class="product"> | |
<a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> | |
<?php woocommerce_show_product_sale_flash( $post, $product ); ?> | |
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.$woocommerce->plugin_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_catalog_image_width').'px" height="'.$woocommerce->get_image_size('shop_catalog_image_height').'px" />'; ?> | |
<h3><?php the_title(); ?></h3> | |
<span class="price"><?php echo $product->get_price_html(); ?></span> | |
</a> | |
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?> | |
</li> | |
<?php endwhile; ?> | |
</ul> | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CAMBIAR EL ORDEN DE LOS PRODUCTOS EN EL CATALOGO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
OPCIÓN 1: | |
--------------------- | |
add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby'); | |
function custom_default_catalog_orderby() | |
{ // También puedes usar title y price | |
return 'date'; } | |
OPCIÓN 2: | |
--------------------- | |
add_filter('woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args'); | |
function custom_woocommerce_get_catalog_ordering_args( $args ) { | |
if (isset($_SESSION['orderby'])) { | |
switch ($_SESSION['orderby']) : | |
case 'date_asc' : | |
$args['orderby'] = 'date'; | |
$args['order'] = 'asc'; | |
$args['meta_key'] = ''; | |
break; | |
case 'price_desc' : | |
$args['orderby'] = 'meta_value_num'; | |
$args['order'] = 'desc'; | |
$args['meta_key'] = '_price'; | |
break; | |
case 'title_desc' : | |
$args['orderby'] = 'title'; | |
$args['order'] = 'desc'; | |
$args['meta_key'] = ''; | |
break; | |
endswitch; | |
} | |
return $args; | |
} | |
add_filter('woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby'); | |
function custom_woocommerce_catalog_orderby( $sortby ) { | |
$sortby['title_desc'] = 'Reverse-Alphabetically'; | |
$sortby['price_desc'] = 'Price (highest to lowest)'; | |
$sortby['date_asc'] = 'Oldest to newest'; | |
return $sortby; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CAMBIAR EL ASUNTO DE LOS MAILS ENVIADOS POR WOOCOMMERCE | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
/* Filtros disponibles: | |
* woocommerce_email_subject_new_order | |
* woocommerce_email_subject_customer_procesing_order | |
* woocommerce_email_subject_customer_completed_order | |
* woocommerce_email_subject_customer_invoice | |
* woocommerce_email_subject_customer_note | |
* woocommerce_email_subject_low_stock | |
* woocommerce_email_subject_no_stock | |
* woocommerce_email_subject_backorder | |
* woocommerce_email_subject_customer_new_account | |
*/ | |
add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2); | |
function change_admin_email_subject( $subject, $order ) | |
{ global $woocommerce; | |
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); | |
$subject = sprintf( '[%s] New Customer Order (# %s) from Name %s %s', $blogname, $order->id, $order->billing_first_name, $order->billing_last_name ); | |
return $subject; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CREAR UN ENLACE QUE VAYA A "MI CUENTA" | |
------------------------------------------------------------------- | |
<?php if ( is_user_logged_in() ) { ?> | |
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','woothemes'); ?>"><?php _e('My Account','woothemes'); ?></a> | |
<?php } | |
else { ?> | |
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','woothemes'); ?>"><?php _e('Login / Register','woothemes'); ?></a> | |
<?php } ?> | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CAMBIAR EL LUGAR AL QUE LLEGA EL USUARIO LUEGO DE LOGEARSE | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
/* | |
* goes in theme functions.php or a custom plugin | |
* | |
* By default login goes to my account | |
**/ | |
add_filter('woocommerce_login_widget_redirect', 'custom_login_redirect'); | |
function custom_login_redirect( $redirect_to ) { | |
$redirect_to = 'http://anypage.com'; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
PERMITIR SHORTCODES EN EL RESUMEN (EXCERPT) DE PRODUCTOS | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
if (!function_exists('woocommerce_template_single_excerpt')) | |
{ function woocommerce_template_single_excerpt( $post ) | |
{ global $post; | |
if ($post->post_excerpt) echo '<div itemprop="description">' . do_shortcode(wpautop(wptexturize($post->post_excerpt))) . '</div>'; | |
} | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CÓDIGO BASE PARA HACER UN PLUGIN DE PASARELA DE PAGO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
<?php | |
/* | |
Plugin Name: WooCommerce <enter name> Gateway | |
Plugin URI: http://woothemes.com/woocommerce | |
Description: Extends WooCommerce with an <enter name> gateway. | |
Version: 1.0 | |
Author: WooThemes | |
Author URI: http://woothemes.com/ | |
Copyright: © 2009-2011 WooThemes. | |
License: GNU General Public License v3.0 | |
License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_action('plugins_loaded', 'woocommerce_gateway_name_init', 0); | |
function woocommerce_gateway_name_init() { | |
if ( !class_exists( 'WC_Payment_Gateway' ) ) return; | |
/** | |
* Localisation | |
*/ | |
load_plugin_textdomain('wc-gateway-name', false, dirname( plugin_basename( __FILE__ ) ) . '/languages'); | |
/** | |
* Gateway class | |
*/ | |
class WC_Gateway_Name extends WC_Payment_Gateway { | |
// Go wild in here | |
} | |
/** | |
* Add the Gateway to WooCommerce | |
**/ | |
function woocommerce_add_gateway_name_gateway($methods) { | |
$methods[] = 'WC_Gateway_Name'; | |
return $methods; | |
} | |
add_filter('woocommerce_payment_gateways', 'woocommerce_add_gateway_name_gateway' ); | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
MOSTRAR EL NÚMERO DE ITEMS EN EL CARRITO Y TAMBIEN EL TOTAL | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
<?php global $woocommerce; ?> | |
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"> | |
<?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?> | |
</a> | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CAMBIAR LA IMAGEN POR DEFECTO CUANDO EL PRODUCTO NO TIENE FOTO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src'); | |
function custom_woocommerce_placeholder_img_src( $src ) { | |
$src = 'http://yoursite.com/urltoimagesrc.jpg'; | |
return $src; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CREAR UNA NUEVA FORMA DE HACER QUE UN CUPÓN FUNCIONE | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_filter( 'woocommerce_coupon_is_valid', 'custom_woocommerce_coupon_is_valid', 1, 2 ); | |
function custom_woocommerce_coupon_is_valid( $valid, $coupon ) { | |
if ($coupon=='YOURCOUPONCODE') { | |
$min_quantity = 12; | |
if (sizeof( $this->product_ids )>0) { | |
$valid = false; | |
if (sizeof($woocommerce->cart->get_cart())>0) { | |
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { | |
if (in_array($cart_item['product_id'], $coupon->product_ids) || in_array($cart_item['variation_id'], $coupon->product_ids)) { | |
if ( $cart_item['qty'] > $min_quantity ) $valid = true; | |
} | |
} | |
} | |
} | |
} | |
return $valid; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
CAMBIAR EL LUGAR AL QUE SE REDIRIGE AL AÑADIR UN PRODUCTO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect'); | |
function custom_add_to_cart_redirect() | |
{ | |
return get_permalink(get_option('woocommerce_checkout_page_id')); // Reemplazar con la dirección que desees | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
AGREGAR UN CAMPO ESPECIAL AL CHECKOUT, EMAILS y USER/ORDER META | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
/** | |
* Add the field to the checkout | |
**/ | |
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field'); | |
function my_custom_checkout_field( $checkout ) { | |
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>'; | |
/** | |
* Output the field. This is for 1.4. | |
* | |
* To make it compatible with 1.3 use $checkout->checkout_form_field instead: | |
$checkout->checkout_form_field( 'my_field_name', array( | |
'type' => 'text', | |
'class' => array('my-field-class orm-row-wide'), | |
'label' => __('Fill in this field'), | |
'placeholder' => __('Enter a number'), | |
)); | |
**/ | |
woocommerce_form_field( 'my_field_name', array( | |
'type' => 'text', | |
'class' => array('my-field-class orm-row-wide'), | |
'label' => __('Fill in this field'), | |
'placeholder' => __('Enter a number'), | |
), $checkout->get_value( 'my_field_name' )); | |
echo '</div>'; | |
/** | |
* Optional Javascript to limit the field to a country. This one shows for italy only. | |
**/ | |
?> | |
<script type="text/javascript"> | |
jQuery('select#billing_country').live('change', function(){ | |
var country = jQuery('select#billing_country').val(); | |
var check_countries = new Array(<?php echo '"IT"'; ?>); | |
if (country && jQuery.inArray( country, check_countries ) >= 0) { | |
jQuery('#my_custom_checkout_field').fadeIn(); | |
} else { | |
jQuery('#my_custom_checkout_field').fadeOut(); | |
jQuery('#my_custom_checkout_field input').val(''); | |
} | |
}); | |
</script> | |
<?php | |
} | |
/** | |
* Process the checkout | |
**/ | |
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process'); | |
function my_custom_checkout_field_process() { | |
global $woocommerce; | |
// Check if set, if its not set add an error. This one is only requite for companies | |
if ($_POST['billing_company']) | |
if (!$_POST['my_field_name']) | |
$woocommerce->add_error( __('Please enter your XXX.') ); | |
} | |
/** | |
* Update the user meta with field value | |
**/ | |
add_action('woocommerce_checkout_update_user_meta', 'my_custom_checkout_field_update_user_meta'); | |
function my_custom_checkout_field_update_user_meta( $user_id ) { | |
if ($user_id && $_POST['my_field_name']) update_user_meta( $user_id, 'my_field_name', esc_attr($_POST['my_field_name']) ); | |
} | |
/** | |
* Update the order meta with field value | |
**/ | |
add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta'); | |
function my_custom_checkout_field_update_order_meta( $order_id ) { | |
if ($_POST['my_field_name']) update_post_meta( $order_id, 'My Field', esc_attr($_POST['my_field_name'])); | |
} | |
/** | |
* Add the field to order emails | |
**/ | |
add_filter('woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys'); | |
function my_custom_checkout_field_order_meta_keys( $keys ) { | |
$keys[] = 'My Field'; | |
return $keys; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
COLOCAR "LLÁMENOS PARA CONOCER EL PRECIO" SI NO ESTÁ DEFINIDO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2); | |
function custom_variation_price( $price, $product ) { | |
$price = ''; | |
if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) $price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>'; | |
$price .= woocommerce_price($product->get_price()); | |
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) { | |
$price .= '<span class="to"> ' . _x('to', 'max_price', 'woocommerce') . ' </span>'; | |
$price .= woocommerce_price($product->max_variation_price); | |
} | |
return $price; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
AGREGAR NUEVAS MONEDAS Y SÍMBOLOS MONETARIOS | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
En este caso añadiré el "Nuevo Sol" peruano: | |
add_filter( 'woocommerce_currencies', 'add_my_currency' ); | |
function add_my_currency( $currencies ) { | |
$currencies['NUEVO_SOL'] = __( 'Nuevo Sol', 'woocommerce' ); | |
return $currencies; | |
} | |
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2); | |
function add_my_currency_symbol( $currency_symbol, $currency ) { | |
switch( $currency ) { | |
case 'NUEVO_SOL': $currency_symbol = 'S/. '; break; | |
} | |
return $currency_symbol; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
AGREGAR ENLACE A LOS PRODUCTOS EN LOS EMAILS DEL PEDIDO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_filter('woocommerce_order_product_title', 'custom_order_product_title', 10, 2); | |
function custom_order_product_title( $name, $product ) { | |
if ($product->id) return '<a href="'.home_url( '?p=' . $product->id ).'">'. $name .'</a>'; | |
return $name; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
AGREGAR UN CÓDIGO DE SEGUIMIENTO U OTRA COSA EN LOS EMAILS DE PEDIDO | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
/* To use: | |
1. Add this snippet to your theme's functions.php file | |
2. Change the meta key names in the snippet | |
3. Create a custom field in the order post - e.g. key = "Tracking Code" value = abcdefg | |
4. When next updating the status, or during any other event which emails the user, they will see this field in their email | |
*/ | |
add_filter('woocommerce_email_order_meta_keys', 'my_custom_order_meta_keys'); | |
function my_custom_order_meta_keys( $keys ) { | |
$keys[] = 'Tracking Code'; // This will look for a custom field called 'Tracking Code' and add it to emails | |
return $keys; | |
} | |
------------------------------------------------------------------- | |
*** NO VERIFICADO *** | |
ALTERAR LA CANTIDAD DE PRODUCTOS RELACIONADOS | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
Mostrar 3 productos relacionados en filas de 3 | |
function woocommerce_output_related_products() | |
{ | |
woocommerce_related_products(3,3); | |
} | |
------------------------------------------------------------------- | |
ALTERAR CANTIDAD DE PRODUCTOS RELACIONADOS: SOLO UP-SELLING | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
remove_action( 'woocommerce_after_single_product', 'woocommerce_upsell_display'); | |
add_action( 'woocommerce_after_single_product', 'woocommerce_output_upsells', 20); | |
if (!function_exists('woocommerce_output_upsells')) { | |
function woocommerce_output_upsells() { | |
woocommerce_upsell_display(3,3); // Display 3 products in rows of 3 | |
} | |
} | |
------------------------------------------------------------------- | |
CAMBIAR EL TEXTO DEL BOTÓN DE "AÑADIR AL CARRITO" | |
Incluir dentro de: tema/functions.php | |
------------------------------------------------------------------- | |
add_filter('single_add_to_cart_text', 'woo_custom_cart_button_text'); | |
function woo_custom_cart_button_text() | |
{ return __('Añade a tu lista de compra', 'woocommerce'); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment