<?php\n/**\n * Plugin Name: Astrozin Homepage Helpers\n * Description: Two tiny shortcodes used by the Elementor product loop cards: [astrozin_rating] and [astrozin_discount].\n */\nif ( ! defined( "ABSPATH" ) ) { exit; }
/** Astrozin homepage helpers: product rating line + computed discount badge (used in Elementor loop item templates). */
if ( ! function_exists( 'astrozin_rating_sc' ) ) {
	function astrozin_rating_sc() {
		if ( ! function_exists( 'wc_get_product' ) ) { return ''; }
		$p = wc_get_product( get_the_ID() );
		if ( ! $p ) { return ''; }
		$r = (float) $p->get_average_rating();
		$n = (int) $p->get_review_count();
		if ( ! $r ) { return ''; }
		$c = $n >= 1000 ? rtrim( rtrim( number_format( $n / 1000, 1 ), '0' ), '.' ) . 'k' : (string) $n;
		return '<span class="az-rating"><span style="color:var(--e-global-color-az_red);font-weight:800">&#9733; ' . esc_html( number_format( $r, 1 ) ) . '</span> <span style="color:var(--e-global-color-az_muted)">(' . esc_html( $c ) . ')</span></span>';
	}
	add_shortcode( 'astrozin_rating', 'astrozin_rating_sc' );
	function astrozin_discount_sc( $atts ) {
		$a = shortcode_atts( array( 'suffix' => '% OFF' ), $atts );
		if ( ! function_exists( 'wc_get_product' ) ) { return ''; }
		$p = wc_get_product( get_the_ID() );
		if ( ! $p || ! $p->is_on_sale() ) { return ''; }
		$reg = (float) $p->get_regular_price(); $sale = (float) $p->get_price();
		if ( $reg <= 0 || $sale >= $reg ) { return ''; }
		return esc_html( round( ( $reg - $sale ) / $reg * 100 ) . $a['suffix'] );
	}
	add_shortcode( 'astrozin_discount', 'astrozin_discount_sc' );
}<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://store.astrozin.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://store.astrozin.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://store.astrozin.com/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://store.astrozin.com/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://store.astrozin.com/wp-sitemap-taxonomies-product_tag-1.xml</loc></sitemap><sitemap><loc>https://store.astrozin.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
