A
A
Alexey2019-06-03 13:40:08
WordPress
Alexey, 2019-06-03 13:40:08

How to display a list of tags in a product card in woocommerce?

Good afternoon! Tell me, please, I got a site, shoveled, none of the standard outputs of various information works. For example, in a product card, the code looks like this:

<div class="productinfo">
      <h1><?php the_title();?></h1>
      <span class="articulproduct">Артикул <?php echo $product->get_sku(); ?></span>			
      <span class="productprice"><?php echo $product->get_price_html(); ?></span>
      <a rel="nofollow" href="<?php echo $product->add_to_cart_url(); ?>" data-quantity="1" data-product_id="<?php echo $product->get_id(); ?>" data-product_sku="<?php echo $product->get_sku(); ?>" class="addtocart">В корзину</a>
</div>

Background: I need to display phrases like: "Out of stock", "On order", etc. in the product card. I did not come up with anything smarter than doing it through tags. I tried to add my fields, but nothing is displayed anyway.
The problem is that the labels are not displayed either. I tried to add a different code found on the Internet between the Article and the Price. Either the site crashes with a 500 error, or nothing changes.
I added the code to functions.php and inserted the shortcode in the same place. Doesn't work either.
Now I don’t know how I can bring these labels to the place I need?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2019-06-03
@HeadOnFire

For example, in a product card, the code looks like this:

Normal code, what confuses you in it? The $product variable contains the Product object with all properties and methods. This is an extended analog of the Post object, only from WooCommerce.
What for? WooCommerce has stock management (Stock Management, I don’t know how it is correct in the Russian version). And all this information will then be available in $product.
The problem is that the labels are not displayed either. I tried to add a different code found on the Internet between the Article and the Price. Either the site crashes with a 500 error, or nothing changes.
I added the code to functions.php and inserted the shortcode in the same place. Doesn't work either.
Apparently you are not a developer, so it is so hard for you. But you are absolutely not digging there. I advise you to contact a WooCommerce specialist, he will solve this problem quickly and efficiently. Teaching you on Toaster how to work with the WooCommerce platform, the basics of OOP is not an option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question