<?php
/**
 * The template for displaying product content within loops
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://woocommerce.com/document/template-structure/
 * @package WooCommerce\Templates
 * @version 9.4.0
 */

defined( 'ABSPATH' ) || exit;

global $product;

// Check if the product is a valid WooCommerce product and ensure its visibility before proceeding.
if ( ! is_a( $product, WC_Product::class ) || ! $product->is_visible() ) {
	return;
}

$shop_display_mode  = Draly_Dropshipping_Starter_Helper::get_option( 'shop_style', 'grid' );
$shop_product_style = Draly_Dropshipping_Starter_Helper::get_option( 'shop_product_style', 'style-01' );

$classes = array( 'product-item' );
if ( $shop_display_mode == 'list' ) {
	$classes[]     = 'list col-12';
	$template_part = 'list';
} else {
	$classes[]     = $shop_product_style;
	$classes[]     = 'col-' . Draly_Dropshipping_Starter_Helper::get_option( 'woo_items', 12 );
	$classes[]     = 'col-sm-' . Draly_Dropshipping_Starter_Helper::get_option( 'woo_sm_items', 6 );
	$classes[]     = 'col-md-' . Draly_Dropshipping_Starter_Helper::get_option( 'woo_md_items', 6 );
	$classes[]     = 'col-lg-' . Draly_Dropshipping_Starter_Helper::get_option( 'woo_lg_items', 4 );
	$classes[]     = 'col-xl-' . Draly_Dropshipping_Starter_Helper::get_option( 'woo_xl_items', 3 );
	$classes[]     = 'col-xxl-' . Draly_Dropshipping_Starter_Helper::get_option( 'woo_xxl_items', 3 );
	$template_part = $shop_product_style;
}
?>
<li <?php wc_product_class( $classes, $product ); ?>>
	<?php get_template_part( 'woocommerce/shop-styles/content-product', $template_part ); ?>
</li>