ดูดีลออนไลน์
ตรวจสอบการสั่งจอง/ยืนยันการชำระเงิน
Hot Deals !!!
Special Deal
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>21,950.-
22,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>21,950.-
22,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>49,500.-
55,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>1,900.-
2,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>3,596.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>59,400.-
69,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>59,400.-
85,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>178,500.-
250,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>82,500.-
82,501.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>269,000.-
300,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>16,400.-
900,000.-
<?php
// Get WooCommerce product stock
$product = wc_get_product(get_the_ID());
$stock_quantity = $product->get_stock_quantity();
$manage_stock = $product->get_manage_stock();
$stock_status = $product->get_stock_status();
// Check if product manages stock or just uses in-stock/out-of-stock
if ($manage_stock && $stock_quantity !== null) {
// STOCK MANAGED PRODUCTS
// You can set max_stock as a custom field or use a fixed value
$max_stock = get_post_meta(get_the_ID(), '_max_stock', true);
if (!$max_stock) {
$max_stock = 50; // Default max stock (changed to 50 as requested)
}
$stock_percentage = ($stock_quantity / $max_stock) * 100;
$stock_percentage = max(0, min(100, $stock_percentage)); // Keep between 0-100%
// Handle zero stock case
if ($stock_quantity == 0) {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: ' . $stock_percentage . '%;">';
echo ' <div class="stock-text">' . $stock_quantity . ' สิทธิ์สุดท้าย</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
} else {
// NON-STOCK MANAGED PRODUCTS (Simple In-Stock/Out-of-Stock)
if ($stock_status === 'instock') {
// In Stock - Red bar, full width
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%;">';
echo ' <div class="stock-text">มีสิทธิ์</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
} else {
// Out of Stock - Gray bar
echo '<div class="stock-progress-container">';
echo ' <div class="stock-progress-bar">';
echo ' <div class="stock-progress-fill" style="width: 100%; background-color: #cccccc;">';
echo ' <div class="stock-text" style="color: #666666;">สิทธิ์หมดแล้ว</div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
}
}
?>9,900.-
19,000.-



