10 Replies Latest reply on Jan 5, 2009 9:55 AM by mrcharis2003@yahoo.c

    How to show "sold" image ..........

    mrcharis2003@yahoo.c Level 1
      Hi there

      Hope everybody is well ..... merry x mas and all that

      I having some problems with my site..... I have a simple site that has a simple shopping cart... with no payment gateway.... cash on delivery or bank transfer only.......

      i have product pages all with a buy now button that adds items to a cart and I have all my cart pages working fine

      I trying to figure out how to add a "sold" image to products that are sold out.....

      In my product table in my database I have a field for howmany_pro to store how many of a product I have in stock
      So that when I add a new product.... using my addproduct.php page I can enter the number ... amount....of a product I have......in stock..... into the add product form ..... as a number to be stored in my howmany_pro field in my product table .....

      So.... so far so good......

      So now ... I want that number.... the howmany_pro number to decrease everytime an item is purchased ... so I can make sure that I have the product asked for in stock..... so I don't get two people ordering the same product.....

      So that when the number of stock goes to Zero "0" I can use the show regieon if database value = "0" behaviour

      I have really no idea how to get this to work......

      Any ideas or help would be great .

      Have a great day

      bibibibi
        • 1. Re: How to show "sold" image ..........
          mrcharis2003@yahoo.c Level 1
          I should have said.....

          So that when the number of stock goes to Zero "0" I can use the show regieon if database value = "0" behaviour to show a sold out image ......... next to the product picture....

          I cant also figure out how to show a different product image....an image that has a sold watermark instead of the original product image..... but showing a sold out image next to the product pic will work fine for now......

          any help would be great

          xoxoxoxoxo
          • 2. Re: How to show "sold" image ..........
            dizmarkie Level 1
            Hi Charis,
            you are on the right track.

            Use a conditional region for your inventory quantity. So when your value for your inventory quantity equals "0" show the sold out image.

            You will notice in the conditional region behaviour there is a check box that says "has else". Check this box and when your conditional region is inserted it will insert your region that should only show based on on your parameters. You will now see a block of text that says "Else text: Replace this." You can replace this text with anything you would like.

            So throw your dynamic image with out sold watermark in here.

            that should work out fine.
            • 3. Re: How to show "sold" image ..........
              dizmarkie Level 1
              My apologies Charis,
              i noticed your other dilemna about decreasing your stock levels when a purchase is made. I will look into but I'm sure if Gunter reads this he'll have a solution.

              Essentially you could use a custom trigger to get the value from the last record and decrease by "1". Much in the same way the sort arrows work i would think.

              this logic seems pretty common. i'll reply when i have a chance.

              cheers
              • 4. Re: How to show "sold" image ..........
                mrcharis2003@yahoo.c Level 1
                hi there

                Thanks for your reply....

                You are correct I can get the show region if database = '0' to work ok

                but cannot reduce the stock number in the database.....

                Anyway will try to get it to work

                Will post my results

                have a great day
                • 5. Re: How to show "sold" image ..........
                  dizmarkie Level 1
                  Hey Charis,
                  Give this a try.

                  in phpmyadmin make sure the field that holds your inventory count is set to "unique".

                  Then this next part I would do after making a backup of one of the trigger class files as it requires editing a certain value.

                  On the insert transaction page add the "auto-increment" behaviour which can be found under developer toolbox/forms/advanced/auto increment column. Then choose the field you would like to auto increment (which will be your inventory field). This will now get the largest value from this field and add 1 to the next record inserted. So this is what we want right? almost... we want to subtract 1 instead. This is where the edit for the value in the class trigger file comes in.. I have not tested this so please make a back up of the file before saving out.

                  Open "tNG_SetOrderField.class.php" which can be found under "includes/tng/triggers" and go to line 83. you will see code that says

                  $sql = 'SELECT MAX(' . KT_escapeFieldName($this->field) . ') + 1 AS kt_sortvalue FROM ' . $this->table;

                  There is a "+1"

                  I would think change this to a "-1" and test it out.

                  hopefully this works :)
                  • 6. Re: How to show "sold" image ..........
                    dizmarkie Level 1
                    Hey Charis, Sorry.
                    Realized this work around will grab the largest value in this field and -1 and this will not work. You need to grab the lowest value in the field and then subtract....

                    not sure if changing " $sql = 'SELECT MAX " to " $sql = 'SELECT MIN "

                    Will do the trick... give that a try along with the previous post suggestion
                    • 7. Re: How to show "sold" image ..........
                      dizmarkie Level 1
                      Ok, so I tested and it works.. the only thing about this work around is that it changes the fundamental way this behaviour works for the entire site.. so if you want to use it the way it was designed in the same site this will pose a problem.

                      there may be away to copy this trigger file and register it as "tNG_SetOrderField2.class.php" and update all the config files for toolbox? But make sure you backup all yoru include folder before messing around. There may be a way to write a custom expression in the trigger to achive this and avoid having to change the files.

                      cheers
                      • 8. Re: How to show "sold" image ..........
                        mrcharis2003@yahoo.c Level 1
                        Thanks for your reply

                        It is a bit over my head at the moment

                        I will try to get it to work and will let you know

                        Thanks soooo much again

                        Have a great day
                        • 9. Re: How to show "sold" image ..........
                          dizmarkie Level 1
                          hey charis,
                          its really not that hard. If you just add the "auto-increment" behaviour from toolbox to your form and assign it to the column you use for your inventory it will increase your records by 1 (for now, until you do the next step).

                          then make the edits to the "tNG_SetOrderField.class.php" file I listed above and don't forget to upload it to the server.

                          It will then reduce the lowest value in your records by 1 and this will eventually bring you to "0" where your conditional region to show the sold out image will kick in.
                          • 10. Re: How to show "sold" image ..........
                            mrcharis2003@yahoo.c Level 1
                            Ok that sounds good

                            I will try it & let you know

                            have a great day