motayeb/woocommerce/content-product.php
Kazem Alghasi f408faac54 build(theme): scaffold initial theme directory structure and assets
Initialize the base WordPress theme files, including core template
hierarchy (index, page, single, archive, 404), WooCommerce template
overrides, and essential asset directories.
2026-08-15 22:11:08 +03:30

52 lines
2.2 KiB
PHP

<?php
/**
* کارت محصول - سازگار با طرح مطیب
*/
defined( 'ABSPATH' ) || exit;
global $product;
// اگر محصول معتبر نبود، رد شو
if ( ! is_a( $product, WC_Product::class ) ) {
return;
}
?>
<div <?php wc_product_class( 'product-card group bg-cream-50 dark:bg-dark-bg rounded-2xl overflow-hidden border border-cream-200/50 dark:border-dark-border/50 hover:shadow-xl transition-all', $product ); ?>>
<!-- لینک عکس -->
<a href="<?php the_permalink(); ?>" class="block relative overflow-hidden">
<?php
// نمایش عکس محصول
woocommerce_show_product_loop_sale_flash();
?>
<img src="<?php echo wp_get_attachment_image_url( $product->get_image_id(), 'medium' ); ?>" alt="<?php echo esc_attr( $product->get_name() ); ?>" class="product-img w-full h-48 md:h-56 object-cover">
<!-- دکمه افزودن به سبد (هاور در دسکتاپ - همیشه در موبایل طبق CSS قبلی) -->
<div class="quick-actions absolute bottom-3 left-3 right-3 flex gap-2">
<?php woocommerce_template_loop_add_to_cart(); ?>
</div>
</a>
<!-- اطلاعات محصول -->
<div class="p-4">
<!-- عنوان -->
<a href="<?php the_permalink(); ?>" class="block font-bold text-sm line-clamp-2 mb-3 group-hover:text-forest-500 dark:group-hover:text-forest-300 transition leading-relaxed">
<?php echo wp_kses_post( $product->get_name() ); ?>
</a>
<!-- ستاره‌ها (اگر فعال بود) -->
<?php if ( $product->get_average_rating() > 0 ) : ?>
<div class="flex items-center gap-1 mb-2">
<span class="text-honey-400 text-xs">★</span>
<span class="text-xs font-medium"><?php echo esc_html( $product->get_average_rating() ); ?></span>
</div>
<?php endif; ?>
<!-- قیمت -->
<div class="flex items-end gap-2">
<span class="font-extrabold text-forest-500 dark:text-forest-300 text-sm md:text-base"><?php echo $product->get_price_html(); ?></span>
</div>
</div>
</div>