This content has been marked as final. Show 10 replies
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
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.
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.
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
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 :)
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
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.
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
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.
Ok that sounds good
I will try it & let you know
have a great day