get_date_created() ) > strtotime( '-' . (int) alpha_get_option( 'new_product_period' ) . ' day' ) ) { $html .= ''; } // Featured label if ( $product->is_featured() && in_array( 'hot', $show_labels ) ) { $html .= ''; } // Sale label if ( $product->is_on_sale() && in_array( 'sale', $show_labels ) ) { $percentage = 0; if ( $product->get_regular_price() ) { $percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 ); } elseif ( 'variable' == $product->get_type() && $product->get_variation_regular_price() ) { $percentage = round( ( ( $product->get_variation_regular_price() - $product->get_variation_sale_price() ) / $product->get_variation_regular_price() ) * 100 ); } if ( $percentage ) { /* translators: %d represents sale rate. */ $html .= ''; } } // Out of stock label if ( in_array( 'stock', $show_labels ) && 'outofstock' == $product->get_stock_status() ) { $html .= ''; } } // Custom Label $custom_labels = get_post_meta( get_the_ID(), 'alpha_custom_labels', true ); if ( is_array( $custom_labels ) ) { foreach ( $custom_labels as $custom_label ) { if ( $custom_label['type'] ) { if ( isset( $custom_label['img_id'] ) ) { $html .= ''; } } else { $style_escaped = ' style="'; if ( ! empty( $custom_label['color'] ) ) { $style_escaped .= 'color:' . esc_attr( $custom_label['color'] ) . ';'; } else { $style_escaped .= 'color: #fff;'; } if ( ! empty( $custom_label['bgColor'] ) ) { $style_escaped .= 'background-color:' . esc_attr( $custom_label['bgColor'] ); } else { $style_escaped .= 'background-color: ' . esc_attr( alpha_get_option( 'primary_color' ) ); } $style_escaped .= '"'; $html .= ''; } } } // Finally, print labels if ( $html ) { /** * Filters the class of product label group. * * @since 1.0 */ $html = '
' . $html . '
'; echo apply_filters( 'woocommerce_sale_flash', $html, $post, $product ); }