Skip to content

Instantly share code, notes, and snippets.

View MarceloGlez's full-sized avatar
🎯
Manteniendo el foco emprendedor

MarceloGlez

🎯
Manteniendo el foco emprendedor
View GitHub Profile
@MarceloGlez
MarceloGlez / personaliza-tienes-un-cupon-checkout
Created February 13, 2021 02:06
Personaliza el texto de ¿Tienes un cupón? en la página de finalizar compra.
/*Personalizar texto en checkout "tienes un cupon..."*/
add_filter( 'woocommerce_checkout_coupon_message', 'bbloomer_have_coupon_message');
function bbloomer_have_coupon_message() {
return '¿Tienes un cupón? 🍀 <a href="#" class="showcoupon">Introduce tu código aquí</a>';
}
@MarceloGlez
MarceloGlez / checkbox-activo-crear-cuenta
Created February 13, 2021 01:42
Para habilitar el checkbox de crear cuenta en finalizar compra
/* Checkbox habilitado crear cuenta en checkout */
add_filter('woocommerce_create_account_default_checked' , function ($checked){
return true;
});
@MarceloGlez
MarceloGlez / taxonomy_shop_woocommerce.php
Last active July 13, 2021 17:20
Añadir taxonomías de productos en página de Tienda en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade taxonomías etiqueta y categoria a producto en tienda*/
add_action('woocommerce_shop_loop_item_title', 'add_tags_and_category', 15);
function add_tags_and_category() { ?>
<div class="tags">
<?php $product_tags = get_the_terms( get_the_ID(), 'product_tag') ;
if( $product_tags && ! is_wp_error( $product_tags ) ) :
foreach( $product_tags as $tag) : ?>
<a href="<?php echo get_term_link( $tag->slug, 'product_tag'); ?>" rel="tag" class="btn btn-primary btn-sm mb-4"><?php echo $tag->name; ?></a>
<?php endforeach;
endif;
@MarceloGlez
MarceloGlez / taxonomy_cat_shop_woocommerce.php
Last active July 13, 2021 17:20
Añadir taxonomía categoría de producto en tienda en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade taxonomía categoría a producto en Tienda*/
add_action('woocommerce_shop_loop_item_title', 'add_tags_and_category', 15);
function add_tags_and_category() { ?>
<div class="tags">
<?php $product_terms = get_the_terms( get_the_ID(), 'product_cat');
if( $product_terms && ! is_wp_error( $product_terms ) ) :
foreach( $product_terms as $term) : ?>
<a href="<?php echo get_term_link( $term->slug, 'product_cat'); ?>" rel="tag" class="btn btn-primary btn-sm mb-4"><?php echo $term->name; ?></a>
<?php endforeach;
endif; ?>
@MarceloGlez
MarceloGlez / taxonomy_cat_non_url_shop_woocommerce.php
Last active July 13, 2021 17:20
Añadir taxonomía categoría de producto en página de productos sin enlace a categorías en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade taxonomía categoria a producto en Tienda sin enlace a categorias*/
add_action('woocommerce_shop_loop_item_title', 'add_tags_and_category', 15);
function add_tags_and_category() { ?>
<div class="tags">
<?php $product_terms = get_the_terms( get_the_ID(), 'product_cat');
if( $product_terms && ! is_wp_error( $product_terms ) ) :
foreach( $product_terms as $term) : ?>
<span><?php echo $term->name; ?></span>
<?php endforeach;
endif; ?>
@MarceloGlez
MarceloGlez / contador_descargas_producto.php
Last active July 13, 2021 17:20
Contador de descargas de un producto en Woocommerce (Agregar líneas de código en function.php del child theme)
add_action( 'woocommerce_single_product_summary', 'show_number_of_downloads' ); function show_number_of_downloads() {
global $wpdb, $product;
if ( empty( $product->id ) ) return;
if ( $product->product_type == 'variable' ) {
$product_ids = $product->get_children();
} else {
$product_ids = array( $product->id );
}
$query = "SELECT SUM( download_count ) AS count
FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions
@MarceloGlez
MarceloGlez / quitar_enlace_producto_mis_descargas.php
Last active July 13, 2021 17:20
Quitar enlace al producto en Mis descargas en Woocommerce (Agregar líneas de código en function.php del child theme)
// Quitar enlace al nombre de producto en mis descargas
add_action( 'woocommerce_account_downloads_column_download-product', 'custom_account_downloads_product_column' );
function custom_account_downloads_product_column( $download ){
// Display the product name without the link
echo esc_html( $download['product_name'] );
}
@MarceloGlez
MarceloGlez / enlace_descarga-producto_comprado_wc.php
Last active July 13, 2021 17:20
Enlace de descarga directa de producto comprado en su propia página de producto en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Enlace de descarga directa de producto comprado en página de producto*/
add_action('woocommerce_after_add_to_cart_form', 'download_products');
function download_products()
{
global $product;
$downloads = array();
$user_id = get_current_user_id();
$downloads = wc_get_customer_available_downloads($user_id);
@MarceloGlez
MarceloGlez / añadir_categoría_producto_tienda_woocommerce.php
Last active July 13, 2021 17:21
Añade categoría a producto en Tienda en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade categoría a producto en Tienda*/
add_action('woocommerce_shop_loop_item_title', 'add_tags_and_category', 15);
function add_tags_and_category() { ?>
<span class="tags">
<?php $product_terms = get_the_terms( get_the_ID(), 'product_cat');
if( $product_terms && ! is_wp_error( $product_terms ) ) :
foreach( $product_terms as $term) : ?>
<span><?php echo $term->name; ?></span>
<?php endforeach;
endif; ?>
@MarceloGlez
MarceloGlez / fecha_pagina_producto.php
Last active July 13, 2021 17:21
Añade fecha de actualización de producto en página de producto en Woocommerce (Agregar líneas de código en function.php del child theme)
/*Añade fecha a producto único*/
add_action( 'woocommerce_single_product_summary','bloomer_echo_product_date',25 );
function bloomer_echo_product_date() {
if ( is_product() ) {
echo the_date('', '<span class="date_published"> 📂 Actualizado: ', '</span>', false);
}
}