I'm new to cartthrob and I want a functionality where if a user has purchased a product already then show out of stock to that user so that user can not make an order again. I'm using this code currently, it's working but as soon as I change entry status of that product purchased then this condition does not work. Please help
{if {exp:cartthrob:is_purchased_item entry_id="{entry_id}"} }
You have already purchased this item!
{if:elseif {exp:cartthrob:is_in_cart entry_id="{entry_id}"}}
<p class="text-center cart-button"><a href="/sample-products/cart" class="green-button">Go to cart</a></p>
{if:else}
{exp:cartthrob:add_to_cart_form class="form" secure_action="yes" return="/sample-products/cart" entry_id="{entry_id}" quantity="1"}
<style>.form{border:0;}</style>
<input type="hidden" name="item_options[purchased_type]" value="Sample Product"/>
<input type="submit" name="submit" value="Add to Cart" class="green-button">
{/exp:cartthrob:add_to_cart_form}
{/if}