Skip to content

Instantly share code, notes, and snippets.

@jjmontalban
Last active February 3, 2023 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjmontalban/ada4b9386e4be7c7aeab46a3bce6c25e to your computer and use it in GitHub Desktop.
Save jjmontalban/ada4b9386e4be7c7aeab46a3bce6c25e to your computer and use it in GitHub Desktop.
Añadir atributos de producto en los emails de pedidos
<?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