| Server IP : 13.126.101.145 / Your IP : 216.73.217.50 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.3.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/rentals_updated/wp-content/themes/hello-elementor-child/ |
Upload File : |
// Displaying Short Description content in "Category Product List"
add_action('wp', 'conditionally_modify_product_archive_hooks');
function conditionally_modify_product_archive_hooks() {
if (is_post_type_archive('product')) {
// Remove default WooCommerce hooks
remove_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10);
remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10);
remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
remove_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10);
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5);
// Add your custom card HTML
add_action('woocommerce_before_shop_loop_item', 'custom_product_card_html', 10);
}
}
function custom_product_card_html()
{
global $product;
if (!$product || !$product->is_visible())
return;
$product_id = $product->get_id();
$image_url = wp_get_attachment_image_url($product->get_image_id(), 'medium');
$price = $product->get_price_html();
$link = get_permalink($product_id);
$title = get_the_title($product_id);
// ACF Fields
$yard_location = get_field('yard_location', $product_id);
$specs = get_field('pl_details', $product_id);
$brochure_url = get_field('brochure_url', $product_id);
?>
<div class="product-card">
<div class="row">
<!-- Product Image -->
<div class="col-md-3">
<a href="<?php echo esc_url($link); ?>">
<img class="product_img" src="<?php echo esc_url($image_url); ?>" alt="<?php echo esc_attr($title); ?>">
</a>
</div>
<!-- Product Details -->
<div class="col-md-6">
<h2><a href="<?php echo esc_url($link); ?>"><?php echo esc_html($title); ?></a></h2>
<?php if ($yard_location): ?>
<div class="location"><img src="/rms/wp-content/uploads/2025/06/location.png"
alt="location-icon" width="16" /> Location <span><?php echo esc_html($yard_location); ?></span>
</div>
<?php endif; ?>
<div class="specs">
<?php echo $specs; ?>
</div>
</div>
<!-- Product Action -->
<div class="col-md-3 product-action d-flex flex-column justify-content-between">
<p class="product-price">
<?php
$raw_price = $product->get_price();
if ($raw_price && $raw_price > 0) {
// Price exists and > 0
$formatted_number = number_format_i18n(floatval($raw_price), 0);
$currency_symbol = '₹';
$final_price = $currency_symbol . $formatted_number . '/-';
echo esc_html($final_price);
} else {
// No price or zero price
echo 'Price is Available on Order';
}
?>
<small> Taxes applicable</small>
</p>
<?php if ($brochure_url): ?>
<a href="<?php echo esc_url($brochure_url); ?>" target="_blank" class="btn yellow">Download Brochure</a>
<?php endif; ?>
<button class="btn yellow">Download Brochure</button>
<button class="btn white" onclick="window.location.href='<?php echo esc_url($link); ?>'">Rent Now</button>
<button class="btn black" onclick="window.location.href='<?php echo esc_url($link); ?>'">Buy Now</button>
</div>
</div>
</div>
<?php
}