C
C
cdelphi782020-03-02 19:51:09
WordPress
cdelphi78, 2020-03-02 19:51:09

How to display product attribute in a card?

Hello! How to display the product attribute in the product card so that it is tied to a certain variation but not in the select, that is, so that the user cannot choose himself, but so that it is displayed to him simply after the fact as reference information?
5e5d3975976dd511235227.jpeg

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pychev Anatoly, 2020-03-02
@pton

The attribute used in the variation is supposed to be selectable.
If it does not need to be selected, then this is already a metafield.
But if you want to use exactly the attributes, then as an example -
Recipe for quick happiness on the knee.
1 - For non-selectable attributes, disable the "used for variations" parameter in the admin panel, and leave the "Display on the product page" parameter enabled.
2 - add some code

add_action('woocommerce_before_add_to_cart_button', function(){
  global $post;
  $product = wc_get_product($post);
  wc_display_product_attributes($product);
});

and as a result

5e5d599f2a9cc466996625.png

3 - finish the rest with a file (in the sense of the logic of hiding elements through JS).

C
Cdelphi78, 2020-03-03
@Cdelphi78

Is there anyone?

G
Grizar, 2020-03-04
@Grizar

Use the description for variations
example here
---
move the price with styles and everything you need to the right place on the page
--
and don't load the site with extra JS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question