One of my products renders a sold label on its product page while the add to cart button shows (and works).
What I tried and verified:
inventory_source_item: qty 1, status 1
cataloginventory_stock_item and cataloginventory_stock_status: is_in_stock = 1, stock_status = 1
Reservations for the SKU sum to zero (order placed −1, order cancelled +1) – later deleted entirely
inventory:reservation:list-inconsistencies does not list this SKU
IsProductSalableInterface::execute() → true; GetProductSalableQtyInterface::execute() → 1.0
All rows in cataloginventory_stock_item are the same to a working product
Full reindex, cache:flush, Redis page-cache DB flushed to empty, var/view_preprocessed cleared, static content redeployed
Cloudflare cache bypassed when curl url for checking so not cache
No third-party plugin on StockRegistry, StockStateProvider or IsProductSalable* beyond core MSI
I tested the file extensively but the template file seems fine and returns true for availability and other products do not have this issue.
Below is a snippet of my template:
$currency = $objectManager->create('MagentoDirectoryModelCurrencyFactory')->create()->load($currencyCode);
global $productk;if(isset($productk))
$product = $productk;
if($product):
$categoryIds = $product->getCategoryIds(); ?>
<?php if ($product->isAvailable()):?>
<span class="price-wrapper by_cbn">
<span class="price"><?php echo $currency->getCurrencySymbol().''. $block->getDisplayValue(); ?></span>
</span>
<?php else:?>
<div class="stock unavailable">
<span><?= $escaper->escapeHtml(__("Sold")) ?></span></div>
<?php endif; ?>
<?php if(!in_array(14, $categoryIds) ) : ?>
<span class="price-container <?= /* @escapeNotVerified */ $block->getAdjustmentCssClasses() ?>"
<?= $block->getSchema() ? '' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?= /* @escapeNotVerified */ $block->getDisplayLabel() ?></span>
<?php endif; ?>
<!-- <span <?php if ($block->getPriceId()): ?> id="<?= /* @escapeNotVerified */ $block->getPriceId() ?>"<?php endif;?>
<?= ($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
data-price-amount="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>"
data-price-type="<?= /* @escapeNotVerified */ $block->getPriceType() ?>"
class="price-wrapper <?= /* @escapeNotVerified */ $block->getPriceWrapperCss() ?>"
><?= /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer(),0) ?></span> -->
<!-- <?php if ($product->isAvailable()):?>
<span class="price-wrapper by_cbn">
<span class="price"><?php echo $currency->getCurrencySymbol().''. $block->getDisplayValue(); ?></span>
</span>
<?php else:?>
<div class="stock unavailable">
<span><?= $escaper->escapeHtml(__("Sold")) ?></span></div>
<?php endif; ?> -->
Worth noting: when changing the display price to a different currency, that currency shows the price.