Jump to content

Auto instock update Mod with extras


Recommended Posts

Guest ironfront

Franck's fix does not include the full view_cart file, but simply tells you what line to change. If you already have Albert's fix installed, Franck's fix won't affect it and everything should work just fine. :rolly:

I'll test it out later tonight. Thanks Franck.

Link to comment
Share on other sites

Guest ironfront

he;lp.

I installed the auto instock mod with franck's fix. It works fine, except that the thing its supposed to do to the view_product page does not work... when a product is out of stock, its supposed to get rid of the "add to cart" button. But mine stays.

Here is my view product php. Any ideas?

<?php



session_start();



include("admin/config.php");



include( "admin/settings.inc.php");



include( "shoppingcart.php");



include( "header.inc.php");



$cart = new Cart;



include("subheader.inc.php");



// start border

sb("100%",$la_view_prod_info,$colour_1,$bg_colour);



	// make sure product exists/has been selected

	if(empty($product))

  {

 	 echo "<div align='center'><br>$la_view_prod_sel</div>";

  }

	else

  {

 	 $select_prod = mysql_query( "SELECT * FROM ".$prefix."store_inventory WHERE product='$product'");

 	 $totalrows = mysql_num_rows($select_prod);



 	 if($totalrows==0)

    {

   	 echo"<br><br><p align=\"center\">$la_view_prod_noexist</p>";

    }



	// build page for product

	if($totalrows!==0)

  {

 	 while ($row = mysql_fetch_array($select_prod))

    {

      $title = $row["title"];

   	 $image = $row["image"];

   	 $image2 = $row["image2"];

   	 $description = $row["description"];

   	 $quantity = $row["quantity"];

   	 $price = $row["price"];

   	 $sale_price = $row["sale_price"];

                $instock = $row["instock"];

   	 $cat_id = $row["cat_id"];

   	 $popularity = $row["popularity"];

    }



	// add 1 to products popularity

	$new_pop = $popularity + 1;

	$sql_update = "update ".$prefix."store_inventory set popularity='$new_pop' where product='$product';";

	$result = mysql_query ($sql_update); 



	$title=stripslashes($title);

	$description = stripslashes($description);

	$description = nl2br($description);



	$select_cat = mysql_query( "SELECT * FROM ".$prefix."store_category WHERE cat_id='$cat_id'");

	while ($row = mysql_fetch_array($select_cat))

  {

 	 $category = $row["category"];

 	 $cat_image = $row["cat_image"];

  }



// navigation if directed from search.php

if($searchlink=="yes")

	{

  echo"<a href=\"index.php\" target=\"_self\">$la_search_home</a> > <a href=\"search.php?search=$search&page=$page\" target=\"_self\">$la_view_prod_search_res</a> > $title<br>";

	}



// navigation if directed from elsewhere

else

	{

  include( "link_navi.php");

	}





if ($cat_image!='catnophoto.gif')

	{

  echo"</p><img src='images/$cat_image'><br>";

	}

if($image2 == "nophoto.jpg")

{

	$imag = "<a href=\"#\"><img src='images/$image' WIDTH=\"200\" HEIGHT=\"200\" onClick=\"MM_openBrWindow('admin/image.php?image=$image','image',' scrollbars=yes,resizable=yes')\" border=\"0\"></a>";

	

	echo"<br><FORM ACTION=\"view_cart.php?add=$product\" name=\"add_product\" method=\"post\">

 	 <table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">

    <tr>

   	 <td bgcolor=\"$colour_2\">

      <table cellpadding=\"3\" border=\"0\" cellspacing=\"1\" width=\"100%\" align=\"center\">

     	 <tr bgcolor=\"$colour_1\" valign='top'>	

        <td width=\"33%\"><b>$title</b>

        <p><div align='center'>$imag<br><a href=\"#\" onClick=\"MM_openBrWindow('admin/image.php?image=$image','image',' scrollbars=yes,resizable=yes')\" border=\"0\">$title</a>

   	 <br><br>Click Image to Enlarge!</p>

   	 <p align ='left'>...</div></p></td>



        <td align='left' valign='top' width=\"66%\" colspan=\"2\"><p><b>$la_store_description:</b></p>$description"; 

    

        // next line for when stock quanity mod is made

        //<p><b>$la_order_quan:</b> $quantity</p>

   	 

        if(($sale=="Y")and($sale_price!=="0.00"))

       	 {

          echo"<p><b>$la_normal_price</b> $currency<s>$price</s></p>";

          echo"<p><b>$la_sale_price</b> $currency<font color=\"990000\">$sale_price</font></p>";

       	 }

   	 

        if(($sale=="Y")and($sale_price=="0.00"))

       	 {

          echo"<p><b>$la_store_price:</b> $currency$price</p>";

       	 }

   	 

        if($sale=="N")

       	 {

          echo"<p><b>$la_store_price:</b> $currency$price</p>";

       	 }

        

        echo"<p><img src='images/bullet.gif' border='0'> <a href='tellafriend.php?product=$product&session=$session'>$la_view_prod_tellfriend</a></p>";

        // future link to wishlist.php;)

        //echo"<p><img src='images/bullet.gif' border='0'> <a href='wishlist.php?product=$product&session=$session'>$la_view_prod_add_wish</a></p></td>



        // START PRODUCT OPTIONS

        $select = mysql_query("SELECT distinct option_id FROM ".$prefix."store_options_bot WHERE product='$product'");

        $count = mysql_num_rows($select);



        if($count>0)

       	 {

          echo"<b>$la_product_options_view</b><br>";



          //start table

          echo"<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";

   	 

          // find options

   	 

          $option_number = 0;

   	 

          while ($row = mysql_fetch_array($select))

         	 {

            $option_id = $row["option_id"];

  

            $option_number = $option_number + 1;

      

            echo"<tr>

              <td align=\"left\">";

              

              // build option name

              $query = "select * from ".$prefix."store_options_top where option_id = '$option_id'"; 

              $result = mysql_query($query)or die("Error: " . mysql_error()); 

              while ($row = mysql_fetch_array($result))

             	 {

                $option_name=$row["option_name"];

             	 }

              

              echo"$option_name:";

     	 

              echo"</td><td align=\"left\">";

     	 

              // build select

              echo"<select name=\"dyn_opt$option_number\">

                <option value=\"\">$la_please_choose</option>";

                

                $select_value = mysql_query("SELECT * FROM ".$prefix."store_options_bot WHERE product='$product' and option_id = '$option_id'");



                while ($row_value = mysql_fetch_array($select_value))

               	 {

                  $assign_id = $row_value["assign_id"];

                  $value_id = $row_value["value_id"];

                  $option_price = $row_value["option_price"];

                  $option_symbol = $row_value["option_symbol"];

          

                  // get value name :)

                  $query_name = "select * from ".$prefix."store_options_mid where value_id = '$value_id'"; 

                  $result_name = mysql_query($query_name)or die("Error: " . mysql_error()); 

                  

                  while ($row_name = mysql_fetch_array($result_name))

                 	 {

                    $value_name=$row_name["value_name"];

                 	 }

          

             	 echo"<option value=\"$assign_id\">$value_name";

             	 if($option_price!=0){

             	 echo" ($option_symbol $currency$option_price)";}

             	 echo"</option>";

       	 

               	 }

     	 

              echo"</select>";

            echo"</td>

         	 </tr>";

          }



     	 echo"</table>";

   	 } //end if($count>0)

   	 // END PRODUCT OPTIONS



     //big change for instock mod

 	 echo"</tr>

 	 <tr height=\"30\">

    <td width=\"33%\" height=\"30\" background=\"images/grey_bev.gif\">$la_view_prod_code $product</td>

    <td height=\"30\" align=\"right\" valign=\"middle\" background=\"images/grey_bev.gif\">$la_order_quan: <INPUT TYPE=\"text\" class=\"textbox\" size=\"3\" value=\"1\" name=\"quan\"></td>

    <td height=\"30\" align=\"center\" background=\"images/grey_bev.gif\" align=\"right\" valign=\"middle\">

    <table width=\"94\" height=\"24\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">

     	 <tr valign=\"middle\">";

          if($instock=="0"){

          echo("<td align=\"center\"><font color=red><b>$la_sold_out</b></font>");

           	 

  }

        else

        {

        echo("<td height=\"24\" width=\"94\" background=\"images/white_button.gif\" align=\"center\" style='cursor:hand;' onClick='add_product.submit();'><a href='#'><font class=\"wht_btn\">$la_add_to_basket</font></a>");

        }

        echo"</td></tr>

      </table>

   	 </td></form>

    </tr>

 	 </table>

  </td>

	</tr>

</table>";

         echo"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"21\">

        <tr>

          <td width=\"100%\" height=\"5\"><center>We have $instock in our inventory</center></td>

        </tr>

      </table>";}

   //end big change for instock mod

}

else

{

	$imag = "<a href=\"#\"><img src='images/$image' WIDTH=\"200\" HEIGHT=\"200\" onClick=\"MM_openBrWindow('admin/image.php?image=$image','image',' scrollbars=yes,resizable=yes')\" border=\"0\"></a>&nbsp;<a href=\"#\"><img src='images/$image2' WIDTH=\"200\" HEIGHT=\"200\" onClick=\"MM_openBrWindow('admin/image.php?image=$image2','image2',' scrollbars=yes,resizable=yes')\" border=\"0\"></a>";

	echo"<br><FORM ACTION=\"view_cart.php?add=$product\" name=\"add_product\" method=\"post\">

 	 <table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">

    <tr>

   	 <td bgcolor=\"$colour_2\">

      <table cellpadding=\"3\" border=\"0\" cellspacing=\"1\" width=\"100%\" align=\"center\">

     	 <tr bgcolor=\"$colour_1\" valign='top'>	

        <td colspan=\"3\"><b>$title</b>

        <p><div align='center'>

        <table width=\"100%\" border=\"0\" cellpadding=\"5\">

                                   <tr> 

                                       <td><div align=\"center\"><a href=\"#\"><img src='images/$image' WIDTH=\"200\" HEIGHT=\"200\" onClick=\"MM_openBrWindow('admin/image.php?image=$image','image',' scrollbars=yes,resizable=yes')\" border=\"0\"></a></div></td>

                                       <td><div align=\"center\"><a href=\"#\"><img src='images/$image2' WIDTH=\"200\" HEIGHT=\"200\" onClick=\"MM_openBrWindow('admin/image.php?image=$image2','image2',' scrollbars=yes,resizable=yes')\" border=\"0\"></a></div></td>

                                   </tr>

                                   <tr> 

                                       <td><div align=\"center\"><a href=\"#\" onClick=\"MM_openBrWindow('admin/image.php?image=$image','image',' scrollbars=yes,resizable=yes')\" border=\"0\">$la_product_desc1</a></div></td>

                                       <td><div align=\"center\"><a href=\"#\" onClick=\"MM_openBrWindow('admin/image.php?image=$image2','image',' scrollbars=yes,resizable=yes')\" border=\"0\">$la_product_desc2</a></div></td>

                                   </tr>

           <tr>

               <td colspan=\"2\"><div align=\"center\">Click Either Image To Enlarge!</div></td>

           </tr>

            

                         </table>



                                </div></p></td>

        </tr><tr><td align='left' valign='top'><p><b>$la_store_description:</b></p>$description"; 

        // next line for when stock quanity mod is made

        //<p><b>$la_order_quan:</b> $quantity</p>

   	 

        if(($sale=="Y")and($sale_price!=="0.00"))

       	 {

          echo"<p><b>$la_normal_price</b> $currency<s>$price</s></p>";

          echo"<p><b>$la_sale_price</b> $currency<font color=\"990000\">$sale_price</font></p>";

       	 }

   	 

        if(($sale=="Y")and($sale_price=="0.00"))

       	 {

          echo"<p><b>$la_store_price:</b> $currency$price</p>";

       	 }

   	 

        if($sale=="N")

       	 {

          echo"<p><b>$la_store_price:</b> $currency$price</p>";

       	 }

        

        echo"<p><img src='images/bullet.gif' border='0'> <a href='tellafriend.php?product=$product&session=$session'>$la_view_prod_tellfriend</a></p>";

        // future link to wishlist.php;)

        //echo"<p><img src='images/bullet.gif' border='0'> <a href='wishlist.php?product=$product&session=$session'>$la_view_prod_add_wish</a></p></td>



        // START PRODUCT OPTIONS

        $select = mysql_query("SELECT distinct option_id FROM ".$prefix."store_options_bot WHERE product='$product'");

        $count = mysql_num_rows($select);



        if($count>0)

       	 {

          echo"<b>$la_product_options_view</b><br>";



          //start table

          echo"<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";

   	 

          // find options

   	 

          $option_number = 0;

   	 

          while ($row = mysql_fetch_array($select))

         	 {

            $option_id = $row["option_id"];

  

            $option_number = $option_number + 1;

      

            echo"<tr>

              <td align=\"left\">";

              

              // build option name

              $query = "select * from ".$prefix."store_options_top where option_id = '$option_id'"; 

              $result = mysql_query($query)or die("Error: " . mysql_error()); 

              while ($row = mysql_fetch_array($result))

             	 {

                $option_name=$row["option_name"];

             	 }

              

              echo"$option_name:";

     	 

              echo"</td><td align=\"left\">";

     	 

              // build select

              echo"<select name=\"dyn_opt$option_number\">

                <option value=\"\">$la_please_choose</option>";

                

                $select_value = mysql_query("SELECT * FROM ".$prefix."store_options_bot WHERE product='$product' and option_id = '$option_id'");



                while ($row_value = mysql_fetch_array($select_value))

               	 {

                  $assign_id = $row_value["assign_id"];

                  $value_id = $row_value["value_id"];

                  $option_price = $row_value["option_price"];

                  $option_symbol = $row_value["option_symbol"];

          

                  // get value name :)

                  $query_name = "select * from ".$prefix."store_options_mid where value_id = '$value_id'"; 

                  $result_name = mysql_query($query_name)or die("Error: " . mysql_error()); 

                  

                  while ($row_name = mysql_fetch_array($result_name))

                 	 {

                    $value_name=$row_name["value_name"];

                 	 }

          

             	 echo"<option value=\"$assign_id\">$value_name";

             	 if($option_price!=0){

             	 echo" ($option_symbol $currency$option_price)";}

             	 echo"</option>";

       	 

               	 }

     	 

              echo"</select>";

            echo"</td>

         	 </tr>";

          }



     	 echo"</table>";

   	 } //end if($count>0)

   	 // END PRODUCT OPTIONS



 	 echo"</tr>

 	 <tr height=\"30\">

    <td width=\"50%\" height=\"30\" background=\"images/grey_bev.gif\" nowrap>$la_view_prod_code $product</td>

    <td height=\"30\" align=\"right\" valign=\"middle\" background=\"images/grey_bev.gif\">$la_order_quan: <INPUT TYPE=\"text\" class=\"textbox\" size=\"3\" value=\"1\" name=\"quan\"></td>

    <td height=\"30\" align=\"center\" background=\"images/grey_bev.gif\" align=\"right\" valign=\"middle\">

    

      <table width=\"94\" height=\"24\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">

     	 <tr valign=\"middle\">

        <td height=\"24\" width=\"94\" background=\"images/white_button.gif\" valign=\"middle\" align=\"center\" style='cursor:hand;' onClick='add_product.submit();'><a href='#'><font class=\"wht_btn\">$la_add_to_basket</font></a></td>

     	 </tr>

      </table>

   	 </td></form>

    </tr>

 	 </table>

  </td>

	</tr>

</table><br><br>";

}

	

}//end if there is a result



// end border

eb($bg_colour,$colour_1);



include("subfooter.inc.php");



include("footer.inc.php");



?>

Link to comment
Share on other sites

Guest franck~

You have twice the same piece of code in your file.

The "//PRODUCT OPTION" part and more.

Erase from line 230 (in your file), right after:

//en big change for Instock mod


to line 373 (including this last one).



So that you have:




 </table>";}

  //end big change for instock mod





}//end if there is a result



// end border

eb($bg_colour,$colour_1);

Should work. Let us know. :rolly:

Link to comment
Share on other sites

This is a great idea to add to this shopping cart. However, after spending hours attempting to install this hack (and the fix) it will not function properly or contains errors. Someone who has this hack working properly should provide all the files in there modified form. I can host the files if needed.

Link to comment
Share on other sites

Hello All

I want to apologize for all the mistakes in the instock mod that i created

Mine Has worked fine from day 1 and if you guys want i can post my pages here or for download, then just upload them into your cart.

And ironfront the code you pasted is way off!! :rolly:

The Pages That I Paste Will Have Alberts Fix Already In Them and Will Be Posted Sunday Nov 23, around 5:00pm eastern standard Time, "I Live In Michigan"

Once Again This Was My First MOD Of Any Type and I apologize the stress this has caused. Alot Of The Errors Are Missing } because I put Them at the bottom Of The Page When i was coded This Thing, so when i copy pasted the codes I added They were left out */*

This will be resolved Soon I promise :D

Best Regards All

Wildbill

Link to comment
Share on other sites

Guest franck~

Hi Wildbill, thanks for your post. May I encourage you to check my fix above in this post, because I am 100% sure that all the small syntax errors (mostly extra } and ; ) are fixed.

You may confirm that if you wish.

And thank you for this MOD, it's agreat and useful one. :rolly:

Link to comment
Share on other sites

Hi all,

I installed this mod on the shop of my girlfriend, but she discovered a problem.

She uses the Product Options to make color and size selections for items possible. You cannot define the number of in stock for 1 specific color/size/option.

I don't see how this could be solved, i just wanted to bring it to the attention.

Otherwise i very nice an most usefull mod, specialy with the fixes from Franck.

Link to comment
Share on other sites

Guest readitag

This is my second request for this. The first was missed or ignored by all.

In add product when I put the stock amount in and click add product the stock amount appears in the next screen but the database is not updated. Instead the database says the item is out of stock. It is not until I edit the product that the number in stock is fixed.

WHY!

PLEASE HELP - this is a great mod, I just don't like taking the unncessary step of editing the product to fix the stock amount.

Thanks

Link to comment
Share on other sites

This is my second request for this. The first was missed or ignored by all.

In add product when I put the stock amount in and click add product the stock amount appears in the next screen but the database is not updated. Instead the database says the item is out of stock. It is not until I edit the product that the number in stock is fixed.

WHY!

PLEASE HELP - this is a great mod, I just don't like taking the unncessary step of editing the product to fix the stock amount.

Thanks

I think you have forgotten to update a sql line.

Re-check al the changes again as given in the Franck edited file. I works, tryed it on 2 servers without problems.

Link to comment
Share on other sites

Guest readitag

I think you have forgotten to update a sql line.

Re-check al the changes again as given in the Franck edited file. I works, tryed it on 2 servers without problems.

I don't think so. My sql line in store inventory is as follows:

instock int(30) Not null Default 0

I've dowloaded Franck's file and made all the changes suggested many of which I had already fixed myself.

BTW if my sql line were wrong why would my edit product page be able to work with the sql?

Thanks. Any other ideas, or am I wrong? Could be :rolly:

Link to comment
Share on other sites

What i ment was, did you update the sql query lines in the different files.

It sounds like the value's are not written to the db when you insert them.

There are a few long lines, where the code inputs the given data tot the db, and there where some new fields.

From what i understand from your posting, it sounds to me like the problem is in that area.

Keep hunting :rolly:

Link to comment
Share on other sites

Guest franck~

readitag,

I don't think so. My sql line in store inventory is as follows:

instock int(30) Not null Default 0

In my fix it says:

`instock` INT( 30 ) DEFAULT '100'

instead of default o

Did you try that? :rolly:

Link to comment
Share on other sites

Guest readitag

Thanks franck~

I missed that fix in the discussion thread but that was exactly it!

Appreciate everyones help!

Erwin, thanks for the try, please keep it up - thats what keeps cubecart alive - everybody trying to help each other. You at least forced me to go back and look things over again - maybe more php got stuck in my head :rolly:

Mark

Link to comment
Share on other sites

Work harder, cYon.

:D

I'm a busy man. Besides if someone has this working it would take but 30 seconds to zip up the files and make life easier for everyone else. After all were here to support each other. :rolly:

Link to comment
Share on other sites

Guest readitag

People, I've created a new instockmod with all the fixes of franck~ and all the fixes of albert.

I don't have a zip program. Either somebody point me to where I can get a freeware copy or zip these files for me so that I can post them.

They work!

Mark :rolly:

Link to comment
Share on other sites

Guest noodlenugget

i lied! i found a hitch! when you view an item, or a catergory for that matter...it places the image of the catergory right above either the item, or the table that shows the items in the catergory. you can check out what I mean by going to www.hilliersfinetreasures.com and click on an item. if you know how to remedy this, please email me @ [email protected] and let me know. thank you!

Link to comment
Share on other sites

Guest readitag

I'm not sure. Mine doesn't do that. This problem seems to have to do with view_product.php. If you backed up your files. Edit the old one again, upload it over your current file, and see if you get the same problem. It may be that some of your other mods are getting in the way. Le me know if this works and we'll go from there.

Link to comment
Share on other sites

Hi u

Thanks for this great mod.

But it would be great if the customer could place a non stock product,

to a wishinglist ??.

or another function like preorder etc.

Some one who have an ide how to make this happen.?? :D

Link to comment
Share on other sites

Guest noodlenugget

apparently..it's supposed to do that haha..theres a line in the view_product.php that basically says...if the category image is not equal to catnoimage.gif, show the category image at the top of the page...and since the page that I added the mod to uses custom category images...it shows the category image at the top. I just added your mod to another cart by copying your files over, not modifying mine and the images dont show up. then again...im not using custom images. i just checked another cart that I used custom images on and it does the same thing. I never noticed it before and I guess it just looks weird because the one I noticed it on has big category images. this has nothing to do with your script! haha thank you for making it though, it works well and its a big help!

Link to comment
Share on other sites

Guest readitag

You're welcome.

But, It should be clear. It didn't write this mod, I just put Albert's, Wild Bills's and Franck~'s work into a coherent set of instructions.

They did the hard work and the thanks goes to them!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.



×
×
  • Create New...