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
/* Casilla de verificación de privacidad después del formulario de comentarios */ | |
add_filter( 'comment_form_field_comment', 'mi_campo_de_privacidad_en_comentarios' ); | |
function mi_campo_de_privacidad_en_comentarios( $comment_field ) { | |
return $comment_field.'<input type="checkbox" name="privacy" value="privacy-key" class="privacyBox" aria-req="true"><p class="pprivacy">Acepto la <a target="blank" href="https://ayudawp.com/legal/">política de privacidad</a><p>'; | |
} | |
//validación por javascript | |
add_action('wp_footer','valdate_privacy_comment_javascript'); | |
function valdate_privacy_comment_javascript(){ | |
if (is_single() && comments_open()){ | |
wp_enqueue_script('jquery'); |
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
// Personalizar la página de Mi Cuenta, eliminando pestañas que no quieres usar | |
if ( in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) ) ){ | |
add_filter( 'woocommerce_account_menu_items', 'wcfb_custom_my_account_remove_items' ); | |
function wcfb_custom_my_account_remove_items( $items ) { | |
unset( $items['downloads'] ); // Eliminar pestaña Descargas | |
unset( $items['orders'] ); // Eliminar pestaña Pedidos | |
unset( $items['edit-address'] ); // Eliminar pestaña Editar Direcciones | |
unset( $items['edit-account'] ); // Eliminar pestaña Editar Cuenta | |
unset( $items['customer-logout'] ); // Eliminar pestaña Cerrar Sesión | |
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
// Añadir un producto automáticamente al carrito a partir de un gasto concreto | |
if ( in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) ) ){ | |
add_action( 'init', 'wcfb_add_auto_product_to_cart_minimum_order_amount' ); | |
function wcfb_add_auto_product_to_cart_minimum_order_amount() { | |
if ( ! is_admin() ) { | |
global $woocommerce; | |
$product_id = 54; //ID del producto | |
$found = false; | |
$cart_total = 50; //Importe total mínimo del carrito |
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
// Añadir producto automáticamente al carrito al visitar la tienda | |
if ( in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) ) ){ | |
add_action( 'template_redirect', 'wcfb_add_auto_product_to_cart' ); | |
function wcfb_add_auto_product_to_cart() { | |
if ( ! is_admin() ) { | |
$product_id = 54; //El ID del producto | |
$found = false; | |
//primero comprobamos que no esté ya en el carrito | |
if ( sizeof( WC()->cart->get_cart() ) > 0 ) { | |
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { |
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
// Mostrar la imagen de la taxonomía en la página de archivo delante de la descripción | |
if ( in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) ) ){ | |
add_action( 'woocommerce_archive_description', 'wcfb_taxonomy_archive_image', 2 ); | |
function wcfb_taxonomy_archive_image() { | |
if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) { | |
$term = get_queried_object(); | |
$image = ''; | |
if( !empty($term->term_id) ){ | |
$thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ); |
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
// Quitar notas de envío del checkout | |
add_filter( 'woocommerce_checkout_fields' , 'wcfb_remove_order_notes' ); | |
function wcfb_remove_order_notes( $fields ) { | |
unset($fields['order']['order_comments']); | |
return $fields; | |
} | |
// Quitar el título del campo | |
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' ); |
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
// Limpiar el carrito y dejar sólo el último producto añadido | |
add_action( 'woocommerce_before_checkout_form', 'wcfb_allow_only_the_last_product_added' ); | |
function wcfb_allow_only_the_last_product_added() { | |
if ( WC()->cart->get_cart_contents_count() > 1 ) { | |
// Coger la key del último producto añadido | |
$cart_content = WC()->cart->get_cart(); | |
$lastone_key = key( array_slice( $cart_content, -1, 1, TRUE ) ); |
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
// Redirigir al checkout al añadir un producto al carrito | |
add_filter ('woocommerce_add_to_cart_redirect', 'redirect_to_checkout'); | |
function redirect_to_checkout() { | |
global $woocommerce; | |
$checkout_url = $woocommerce->cart->get_checkout_url(); | |
return $checkout_url; | |
} |
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
// Establecer un importe de pedido mínimo para tu tienda online. Si el pedido es inferior a esa cantidad se mostrará un mensaje en el checkout. | |
add_action( 'woocommerce_checkout_process', 'wcfb_minimum_order_amount' ); | |
add_action( 'woocommerce_before_cart' , 'wcfb_minimum_order_amount' ); | |
function wcfb_minimum_order_amount() { | |
// Cambiar este valor por el importe de pedido mínimo de tu tienda | |
$minimum = 20; | |
if ( WC()->cart->total < $minimum ) { | |
if( is_cart() ) { | |
wc_print_notice( |
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
// Comprobar si el cliente ya ha comprado un producto. Muestra un mensaje al cliente debajo del producto que ya ha comprado anteriormente. | |
add_action ( 'woocommerce_after_shop_loop_item', 'wcfb_user_logged_in_product_already_bought', 30); | |
function wcfb_user_logged_in_product_already_bought() { | |
if ( is_user_logged_in() ) { | |
global $product; | |
$current_user = wp_get_current_user(); | |
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product->id ) ) { | |
echo '<div class="user-bought">♥ Hola ' . $current_user->first_name . ', has comprado esto anteriormente. ¿Comprar otra vez?</div>'; | |
} | |
} |
NewerOlder