Forum for discussing general topics related to Couch.
7 posts Page 1 of 1
Hi,

Is it possible at all to set a product as "not available" so it can remain on the page for SEO purposes but cannot be purchased?

Thanks
Hi Tony,

This, I think, can be done using a simple conditional.

Define a checkbox named 'not_available' in the products template.
Now while displaying the products using cms:pages, simply check for the checkbox's value and if set, do not output the cms:pp_product_form - just show the product's options and description (and a 'Not in stock' message).

Hope this helps.
KK wrote: Hi Tony,
and if set, do not output the cms:pp_product_form - just show the product's options and description (and a 'Not in stock' message).


Woukd you have an example of this part? I am not sure how to add it to the code

Thanks
Don't have a ready-to-use snippet.
Please give me some time - I'll post one later this evening.

Thanks
Hi,

As promised, here is a working example (I'll be using the sample site that comes with our Cart tutorial - http://www.couchcms.com/docs/concepts/s ... art-1.html).

Add the following editable region to the products template (i.e. index.php) -
Code: Select all
<cms:editable name='out_of_stock' label='Out of stock' type='checkbox' opt_values='Yes=1'  />

This checkbox can be ticked if a product goes out of stock.

Next, we use the value within the checkbox to either display the 'Add to cart' button or show a 'Out of stock' message while displaying each product.

The original portion of the 'index.php' template that displays the products is this (excerpted for clarity) -
Code: Select all
<div class="product-details">
    <cms:pp_product_form class="cart-form">
        ..
        ..
        <div class="purchase-box">
            <label class="quantity-label">Qty:</label>
            <input class="product-quantity" type="number" name="qty" min="1" step="1" value="1" title="Quantity">
            <input class="button product-add" type="submit" value="Add to Cart">
        </div>
        ..
        ..
    </cms:pp_product_form>
</div>

We amend the code above to incorporate the checkbox's value like this -
Code: Select all
<div class="product-details">
    <cms:pp_product_form class="cart-form">
        ..
        ..
        <div class="purchase-box">
            <cms:if out_of_stock>
                <label class="quantity-label">Out of stock</label>    
            <cms:else />
                <label class="quantity-label">Qty:</label>
                <input class="product-quantity" type="number" name="qty" min="1" step="1" value="1" title="Quantity">
                <input class="button product-add" type="submit" value="Add to Cart">
            </cms:if>    
        </div>
        ..
        ..    
    </cms:pp_product_form>
</div>

Hope this helps.
Thanks, will try it out this evening and let you know.

The list for new couchcart is getting longer :D
Great, worked perfectly :)

Thanks KK
7 posts Page 1 of 1
cron