Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_after_shop_loop_item', 'add_attr_catalog', 3 );
- function add_attr_catalog() {
- global $product;
- $attributes = $product->get_attributes();
- foreach ($attributes as $attribute) {
- //print_r($attribute);
- $attr_name = substr($attribute['name'], 3);
- $attr_value = $attribute['value'];
- $attr_nice_name = get_attr_name($attr_name);
- if (!empty($attr_value)) {
- if ($attr_name == "vysota-matrasa-sm") {
- echo '<p class = "attr_in_loop">Высота матраса: ' . $attr_value . ' см</p>';
- }
- else {
- echo '<p class = "attr_in_loop">' . $attr_nice_name . ': ' . $attr_value . '</p>';
- }
- }
- }
- }
- function get_attr_name($attr_slug) {
- global $wpdb;
- $query = $wpdb->get_results("SELECT `attribute_label` FROM wp_woocommerce_attribute_taxonomies WHERE `attribute_name` = '$attr_slug';", ARRAY_A);
- return $query[0]['attribute_label'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement