Tagged: archive, attributes, woocommerce
-
AuthorPosts
-
June 8, 2017 at 11:44 am #805534
I have 2 product attributes:
first attribute is ‘unit weight’ (which is 100gr/150gr/250gr usually)
second attribute is ‘price per 100gr’for some reason the first attribute shows up under the quantities button in the main shop page and other categories – which is great!
but I want the second attribute to be shown too!
and I can’t find any setting to tweak to make that happen
..is there any way to do that?i pasted screen shot and a link the in private content
- This topic was modified 7 years, 4 months ago by Sarah.
June 12, 2017 at 1:21 pm #806873UPDATE:
o.k.. i think that the flowing code snippet in my child theme function.php is the one responsible for displaying the weight attributeadd_action( 'woocommerce_after_shop_loop_item', 'rs_show_weights', 9 ); function rs_show_weights() { global $product; $weight = $product->get_weight(); if ( $product->has_weight() ) { echo '<div class="product-meta"><span class="product-meta-label">משקל ליחידה: </span>' . $weight . get_option('woocommerce_weight_unit') . '</div></br>'; } }
my question is: is it possible to display other attributes in archive pages in the same way?
Any help would be very appreciatedJune 12, 2017 at 7:06 pm #807020Hi Doron,
You can add the other attribute to this snippet, you just have to know the name of the attribute.
Best regards,
VictoriaJune 13, 2017 at 8:46 am #807276HI Victoria
I’m not sure about that
if you go to the attributes page (there is a a screen shot in the private content) you will see
all attributes, including weight, has only Hebrew name (which is this websites’s front end language) none are in english
(weight is the pink number 1 in the screen shot and number 2 is ‘price per 100gr’)I’m pretty sure the code snippet above uses the weight specified in the product shipping values (look at the second screen shot in the private content) and not the weight attribute
if I give you login details, would it help?
June 15, 2017 at 9:28 am #808464by googling I found something that might do the trick
https://stackoverflow.com/questions/38487561/woocommerce-get-custom-product-attribute
But I’m still not sure how to Combine it with the current code
(and especially not sure if its possible when the attribute name isn’t in English)
Victoria? can you help me?- This reply was modified 7 years, 5 months ago by Doron.
June 15, 2017 at 10:58 am #808503Hi Doron,
Did you create the attribute yourself? The “price per 100gr” one?
Best regards,
VictoriaJune 15, 2017 at 11:34 am #808521yes
by the way – I’m able to change the attribute name to English but I’m not sure if I can because than it will also display in English in the inner product pages ‘more info’ tab and the client needs the websites language to be HebrewJune 19, 2017 at 7:29 pm #809914Hi Doron,
The name of the attribute has to be in English, and then you translate it. What is the name and what code are you using?
Best regards,
VictoriaJune 19, 2017 at 9:18 pm #809977o.k
I’ve changed from Hebrew (מחיר ל 100 גרם) to English (price per 100gr)
so the attribute name is now price per 100gr
whats the next step?
I’m note sure what code to use or how to use each code
(I’m o.k with CSS but not so strong with PHP, was hoping you could guide me with this?)June 20, 2017 at 6:03 am #810153Hi,
Please, may you provide to us your WP credentials and the FTP too?
Best regards,
John TorvikJune 20, 2017 at 4:37 pm #810462Yes
thank you
I posted them in the private contentJune 26, 2017 at 8:38 am #812915hi.. is there any news?
June 28, 2017 at 6:08 am #813675Hi,
Please replace the filter with the following code.
/* * show product weights */ add_action( 'woocommerce_after_shop_loop_item', 'rs_show_weights', 9 ); function rs_show_weights() { global $product; $weight = $product->get_weight(); $pergram = $product->get_attribute( 'pa_price-per-100gr' ); if ( $product->has_weight() ) { echo '<div class="product-meta"><span class="product-meta-label">משקל ליחידה: </span>' . $weight . get_option('woocommerce_weight_unit') . '</div></br>'; } if ( $pergram ) { echo '<div class="product-meta"><span class="product-meta-label">משקל ליחידה: </span>' . $pergram . '</div></br>'; } }
Best regards,
IsmaelJune 28, 2017 at 9:08 am #813715It works!!
thank you so much!!June 28, 2017 at 5:52 pm #814022Hi,
We’re happy to help!
Please let us know here in the forums if you have any other questions.
Thank you for using Enfold.
Cheers!
Sarah -
AuthorPosts
- The topic ‘WooCommerce display product attributes in archive page’ is closed to new replies.