Last active
February 3, 2023 09:52
-
-
Save jjmontalban/ada4b9386e4be7c7aeab46a3bce6c25e to your computer and use it in GitHub Desktop.
Añadir atributos de producto en los emails de pedidos
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
<?php | |
/* Mostrar atributos del producto en el email */ | |
add_action('woocommerce_order_item_meta_end', 'custom_item_meta', 10, 4); | |
function custom_item_meta($item_id, $item, $order, $plain_text) | |
{ | |
$product_id = $item->get_product_id(); | |
$product = wc_get_product( $product_id ); | |
if ( $product->is_type('simple') ) | |
{ | |
$color = $product->get_attribute( 'pa_color' ); | |
$medida = $product->get_attribute( 'pa_medida' ); | |
if ($color) { | |
$label_color = get_taxonomy( 'pa_color' )->labels->singular_name; | |
echo "<br><p> $label_color : $color</p>"; | |
} | |
if ($medida) { | |
$label_medida = get_taxonomy( 'pa_medida' )->labels->singular_name; | |
echo "<br><p> $label_medida : $medida</p>"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment