A
A
Anonimmus2021-03-14 18:38:18
WordPress
Anonimmus, 2021-03-14 18:38:18

How to display a label in a product?

How to display the product tag of Wookomers?

1. <?php woocommerce_show_product_loop_sale_flash(); ?>
2. <?php print_r($product) ?>

1. the output is null empty
2. $product in the array does not store the label

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anonimmus, 2021-03-23
@Anonimmus

In general, without waiting for an answer ....... I post the answer that I got

<div class="prod__tags">
            <?php if ( !empty(woocommerce_show_product_loop_sale_flash()) ) : ?>
                <?php woocommerce_show_product_loop_sale_flash(); ?>
            <?php else : ?>
          <?php endif; ?>

      <?php if ( has_term('hit', 'product_tag') ) : ?>
      <?php $tagz = get_term_by('slug', 'hit', 'product_tag'); ?>
      <div class="prod__tags-item prod__tags-fire">
        <span class="prod__tags-item-text"><?php echo $tagz->name; ?></span>
      </div>
      <?php endif; ?>

in loop/sale-flash.php
<?php if ( $product->is_on_sale() ) : ?>
  <div class="prod__tags-item prod__tags-sale">
  <?php echo apply_filters( 'woocommerce_sale_flash', '<span class="prod__tags-item-text">' . esc_html__( 'Скидка', 'woocommerce' ) . '</span>', $post, $product ); ?>
  </div>

<?php endif;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question