Announcement

Collapse
No announcement yet.

Hide Add to Cart When No Components in Stock

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hide Add to Cart When No Components in Stock

    With a product that has component permutations linked to hidden products I have selected to 'Hide Out Of Stock Options' - this works fine, but......when all of them are out of stock the drop down still shows and is empty.

    I want to create a condition that tests for this and then to use it to block the drop down list as well as the Add to Cart button.

    I can't find a condition that will work to test for this - can anyone help?

    #2
    Thinking out loud: could you use php to addup the stock levels on each hidden product and then act upon that total if it equalled 0?

    or maybe count the number of products in the list and compare that to how many of them are out of stock messaged, if the same, then do the hide. As each associated product can be taken out of stock, i presume that it's stock level is available to get.

    Can you add the actual stock level onto the end of the name of the choice?

    Comment


      #3
      The condition to block the option operates on the list so is not valid outside it. I tried using php to add up and/or compare but I have to then reference the php result variable outside the compenent list in the product layout, and of course when I close the php block the variable definition is lost.

      I was thinking of enclosing all the layout in php and then echoing it out into the product layout but was concerned that apart from being very difficult to manage would also load Actinic too much.

      This is Norman's forte...

      Comment


        #4
        Can't you declare a variable for stock total at the start of a product layout, zero it before you start and then within the list add the value to it. At the start of the product layout it gets zero'd, then has its value assigned and then gets wiped on the next product.

        Gabe did something along the same lines for me where we had a site wide php variable and on each product had to assign something to it, so it was emptied at the start of the layout, then filled out during the layout, so was always fresh relevant data inside on a per product basis.

        Agree with you on Norm, right up his street this one. His matrix that takes items out of stock must be pretty close to all you need on this, as that also changes each grid option (the colour of it) according to stock level along with removing the add to cart option.

        PS - mention it on t'other forum, pretty sure Gabe or Norm would at least get you in the right ball park. The alternative is playing pin the tail on the donkey with me, with us both wearing blindfolds at 3am and the electric has been switched off .

        Comment


          #5
          The key is knowing how to define a site wide php variable - if I could do that then I could do the rest.

          The way I tried, If I close out the php block then the variable is lost.

          * Luckily my keyboard's flourescent.

          Comment


            #6
            I think I've found it....

            global $myvariable;

            Obvious.

            Comment


              #7
              That sounds the puppy. Remember to zero it though before you refill it each time.

              Comment


                #8
                Yeah - set at the top of the layout and reset it at the bottom.

                I've got it working so that with one product layout I can have all possibilities working, with/without components, stock monitored/not monitored which will remove the add to cart and replace with a no stock image BUT...

                Now I need to remove the empty drop down list from 'view' if all components are out of stock - problem is I only know when they're out of stock after processing the list.

                Looks like I may have to make a copy of the list with everything essentially removed purely to test and create the value to be used in the 'real' list.

                Becoming quite a lot of PHP and needing a lot of code changes in quite a few places - not too sure if it's where I want to be at - don't want to break Actinic again.

                Comment


                  #9
                  Can you add the list code into a php variable, then do your stock check and echo the list code it if a certain condition is met?

                  Comment


                    #10
                    Taking time out on this and compromised to just leave the empty drop down but with an OOS message.

                    Another option is to use php to write/read to the database and store the variable there.

                    Another day.

                    Comment


                      #11
                      I never found a way to do it either so I knocked up a querry in Access that I run which tells me if any products have no Sizes in stock so I can manually do it in Actinic.

                      Looking at one of Gabes examples in the V8 forum about bypassing the cgi bin he 'looks up' values in the database using Perl - maybe that could be adapted?
                      Unusual Silver Jewellery
                      Giftmill - Unusual Gifts
                      Crystal Healing Jewellery
                      Steampunk Jewellery

                      Comment


                        #12
                        I'd suggest this could probably be done using some ajax on the client side. Use javascript to loop through the options and send a request to the server to check for Out of Stock for each product (php / perl script required on the server side to query the .cat files - or the ActiveStock file, if you're using that). Then, if they are all out of stock, use display:none on the parent list element as well as the Add to Cart element.
                        ActiveStock
                        On-line, real-time stock control plug-in for Actinic V7, V8 and V9
                        **New - Captcha plug-in for your Contact Us form**

                        ActiveStock website
                        Free 30 Day Trial
                        ActiveStock Blog (including a new tutorial on a 'Sort By' function for long section pages)

                        Comment

                        Working...
                        X