Jump to content

[SOLVED] Grabbing variables for a shopping cart


envexlabs

Recommended Posts

I'm trying to add some drag and drop functionality to a site i'm developing, but i'm having some troubles.

 

I have some catagory buttons, and some products.

 

You can drag the products, and when you drop them on a certain catagory, an AJAX function changes the catagory of the selected product.

 

The problem i am having is that i dont know how to grab the product ID and the catagory ID depending on what has been dragged and dropped.

 

Here is some code:

 

Renders out the products

 

function display_products($store_id, $catagory_id){

    $store_id = mysql_escape_string($store_id);
    
    //displays the what's hot if cat_id = 0
    if($catagory_id == 0)
    {
        $product_info_query = mysql_query('SELECT * FROM `products` WHERE store_id = ' . $store_id . ' & display = 1 LIMIT 0, 12');
    }else{
    //displays the chosen catagory
        $product_info_query = mysql_query('SELECT * FROM `products` WHERE store_id = ' . $store_id . ' &  `catagory` = ' . $catagory_id . ' & display = 1 LIMIT 0, 12');
    }
                
    while($product = mysql_fetch_row($product_info_query))
    {
    
        echo '

        <!-- START PRODUCT -->
        
        <div class="product_container" id="product' . $product[0] . '">
        
        <div class="product_info">
        
            <p class="fstore_name">' . $product[2] . '</p>
            <p class="product_price">Price: $' . $product[3] . '
        ';
        
        on_sale();
        
        echo'<p class="fstore_content">' . $product[6] . '</p>
                
            <div class="sub_links">
                <p class="nav_images"><img src="images/icons/page_white_add.gif" height="16px" width="16px" alt="" /><a href="#">add to shopping list</a></p>
                
        </div> <!-- sub_links div -->
            
        </div> <!-- product_info div -->
        
        <div class="product_img_border">
        
        <div class="product_img" style="background: url(uploads/product_images/' . $product[5] .'.jpg);">                    
        </div> <!-- product_img -->
                
        </div> <!-- product_img_border -->';
            
        product_edit_nav($product[0]);
            
        echo '</div> <!-- product_container div -->  
            
        <script type="text/javascript">
             new Draggable(\'product' . $product[0] . '\',{revert:true});
        </script>
            
        <!-- END PRODUCT -->';
    
    }
}

 

Renders out the catagories

 

function display_catagories($owner_id, $store_id){
    
    $display_cat_query = mysql_query('SELECT * FROM `catagories` WHERE `owner_id` = \'' . $owner_id . '\'');
                
    while($cat_info = mysql_fetch_row($display_cat_query)){
                
        echo '<div class="catagorie_button" id="cat_cont' . $cat_info[0] . '"><a href="?store_id=' . $store_id .'&cat=' . $cat_info[0] . '">' . $cat_info[2] . '</a></div>';
                
        echo'<script type="text/javascript">
                Droppables.add(\'cat_cont' . $cat_info[0] . '\', {
                onDrop: 
                function(){change_cat(\'product87\',\'inc/ajax/edit_cat.php?state=approve\');}
                });         
            </script>';
            
            
    }
    
}

 

Any help would be great!

 

envex

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.