+add_action( 'woocommerce_before_shop_loop_item_title', function() {
+ echo woocommerce_get_product_thumbnail();
+ echo '<div class="flagcontainer">';
+ //1.Show discount percentage in a tag
+ if( $product->is_on_sale() )
+ if( $product->is_on_sale() )
+ $available_variations = $product->get_available_variations();
+ for ($i = 0; $i < count($available_variations); ++$i) {
+ $variation_id=$available_variations[$i]['variation_id'];
+ $variable_product1= new WC_Product_Variation( $variation_id );
+ $regular_price = $variable_product1 ->regular_price;
+ $sales_price = $variable_product1 ->sale_price;
+ $percentage= round((( ( $regular_price - $sales_price ) / $regular_price ) * 100),1) ;
+ if ($percentage > $maximumper) {
+ $maximumper = $percentage;
+ echo '<span class="flag discount">'.sprintf( __('%s', 'woocommerce' ), '-'.round($maximumper) . '%' ).'</span>';
+ if((int)$product->price >= 499)
+ echo '<span class="flag free-shipping">Fri frakt</span>';
+ $terms = get_the_terms( get_the_ID(), 'product_tag' );
+ if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
+ foreach ( $terms as $term ){
+ echo '<span class="flag new">'.$term->name.'</span>';