Page 1 of 1

Zen Cart - no input If product out of stock

Posted: Mon Aug 04, 2008 9:22 am
by wiggst3r
Hi

On the page in which customers can enter a quantity to buy products, I have some input boxes that they can fill in.

As some products have more than one product attribute, for example, a product can be either a single or a double.

so far, the input boxes display if either is in stock and doesnt display if all are out of stock.

What I want to do is to make it so, if one of the attributes, for example, single's are out of stock, then the input box is disabled, and maybe replaced wih an 'Out Of Stock' image.

The code I'm trying to modify is below. I'm quite sure this is the page which displays the input boxes, but I'm not sure how to change code so it only displays the input box if the specific attribute is in stock

code (tpl_modules_attributes.php):

Code: Select all

<?php
/**
 * Module Template
 *
 * Template used to render attribute display/input fields
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_modules_attributes.php 3208 2006-03-19 16:48:57Z birdbrain $
 */
 
if($products_quantity)
{
 
    global $db;
    //instead of using the currrent attributes.php field. Get the here manually and create the text fields
    $sql = " SELECT * FROM products_attributes atr, products_options_values val, products_options opt " .
           " WHERE atr.products_id = '{$_GET['products_id']}' " .
           " AND val.products_options_values_id = atr.options_values_id " .
           " AND opt.products_options_id = atr.options_id " .
           " ORDER BY val.products_options_values_sort_order ";
    $count = 0;
    $result = $db->Execute($sql);
    $num_attributes = mysql_num_rows($result->resource);
    if($num_attribute)
    {
        ?><h4>Purchase Options</h4><?php
    }
    else
    {
        ?><h4>Purchase Options</h4><?php
    }
 
    ?>
 
    <div id="purchase_options_selections">
    <script type="text/javascript" src="includes/templates/bullbrand/scripts/product_page_price_updator.js"></script>
 
    <?php
 
    while(!$result->EOF)
    {
        $count++;
        ?>
 
        <div style="position: relative">
 
        <p class="left_option"><?=$result->fields['products_options_values_name']?></p>
 
            <div class="yeah"><label  class="test" for="product_quantity_<?=$count?>">Quantity</label>
            <input  class="test" name="id[1][<?=$result->fields['products_options_values_id']?>]" id="product_quantity_<?=$count?>" onkeyup="update_total_price();" />
            <input type="hidden" id="product_price_<?=$count?>" value="<?=$result->fields['options_values_price']?>"></input></div>
 
        </div>
 
        <?php
        $result->MoveNext();
    }
    if(!$count)
    {
        //must be a normal product with just 1 price. Display the 1 field
        $sql = " SELECT * FROM products pro, products_description des " .
               " WHERE pro.products_id = '{$_GET['products_id']}' " .
               " AND pro.products_id = des.products_id ";
        $result = $db->Execute($sql);
 
        ?>
<div>
        <p class="left_option" ><?=$result->fields['products_name']?></p>
            <label class="testie" for="product_quantity_<?=$count?>">Quantity</label>
            <input class="testie" type="text" name="cart_quantity" id="product_quantity_1" value="0" onkeyup="update_total_price();" />
            <input type="hidden" id="product_price_1" value="<?=$result->fields['products_price']?>"></input>
 
        </div>
 
        <?php
    }
        ?>
    <p class="product_add_to_basket"><input type="image" src="includes/templates/bullbrand/images/add_to_basket_button2.gif" class="add_to_basket_button" title="Add to Basket" value="Add to Basket"></input></p>
    <p class="product_price_total" id="product_price_total">Total &pound;0</p>
 
    </div>
<?php
 
}
else
{
    ?><p><br/> &nbsp;&nbsp;&nbsp;Please click <a href="index.php">here</a> to return to the homepage.</p><?php
}
?><?php
 
Thanks in advance

Re: Zen Cart - no input If product out of stock

Posted: Mon Aug 04, 2008 9:15 pm
by it2051229
ohh so you're modifying some page... hmmm do you program PHP?? cause if you do, that's quite easy to do..

Re: Zen Cart - no input If product out of stock

Posted: Tue Aug 05, 2008 3:53 am
by wiggst3r
I do a little bit of php.

Could you possibly help me with this?

Thanks