Announcement

Collapse
No announcement yet.

Sell a product upto a specified date/time

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

    Sell a product upto a specified date/time

    Has anyone managed to achieve the ability to sell a product upto a specific point in time?

    For instance, we want to sell a product up to 11pm on October 23rd 2010. After that, the product is still visible but the Add To Cart button is not displayed or is replaced with a message.

    Any thoughts? Would Javascript do it? Or would we have to start using PHP pages instead?
    Elysium:Online - Official Accredited SellerDeck Partner
    SellerDeck Design, Build, Hosting & Promotion
    Based in rural Northants

    #2
    Javascript can test the time / date which you could then run an else/if and write a new class around the add to cart layout which is set to display:none in the actinic.css


    Bikster
    SellerDeck Designs and Responsive Themes

    Comment


      #3
      using the display:none method of "hiding" the add-to-cart button does just that, - it hides it, but its still there - even if the button is hidden, I can use fire-fox functionality to generate an on-click of the button and still add the item to the cart - admittedly, not everone has that knowledge, but it can be done.

      You really should be manipulating the DOM (Document Object Model) - thats the physical structure of the html page. so by far the better method is to TOTALLY delete the button from within the code - but there's a problem here, in javascript, there is no RemoveElement DOM method

      there is a way around the lack of "RemoveElement", you need to grab a reference of the element, find it’s parent, then remove the element reference by treating it as a child and calling the removeChild method.

      eg.
      var el = document.getElementById('add-to-cart-button');
      el.parentNode.removeChild(el);
      using this method, the actual button will be totally removed from within the HTML.

      the javascript bit of code needs to be executed only when the html page has totally finished loading, for that you need to use the window.onload functionality see
      http://www.openhosting.co.uk/articles/webdev/5918/
      for instance, or put it in the <body> tag


      the difference between javascript and php is simply that javascript is client-side, ie the client can see the javascript code whereas the PHP code is executed on the server BEFORE the page is displayed and so the "how or whta you've done" code is never seen by the end user.

      once you have the ability to delete the button, all you need to do is to detect whe the required date is (gmt? bst?) and only execute the code if the time greater than . ..
      see http://www.proglogic.com/code/javasc...e/timeleft.php

      kev

      Comment


        #4
        Originally posted by Goz View Post
        Any thoughts? Would Javascript do it? Or would we have to start using PHP pages instead?
        Javascript "should" be sufficient, however as Kevin has said there are ways around this e.g. with the <form> tag still there the form could theoretically be submitted by hitting the Enter key whilst focus is on the quantity field.....

        I'd either have a function called on the "onclick" event of the button which simply pops up a "sorry - you cannot buy because....." message box when the date has past (and does nothing except submit the form before that date), or I'd use a function which, as John and Kevin have said, simply removes the button from the user and replaces it with a message.
        Fergus Weir - teclan ltd
        Ecommerce Digital Marketing

        SellerDeck Responsive Web Design

        SellerDeck Hosting
        SellerDeck Digital Marketing

        Comment


          #5
          Not an expert on javascript in any way, but I would have thought you could use document.write to either put the 'buy' button or the 'too late' message on the page based on the time. You could also trap the submit to check the form hasn't submitted too late as well. It just depends how complicated you want it to be.

          Mike
          -----------------------------------------

          First Tackle - Fly Fishing and Game Angling

          -----------------------------------------

          Comment


            #6
            JavaScript may be problematic if your customers have the data / time set wrongly on their computers or are in another time-zone.

            Two solutions. Make that page a .php one and use PHP to comment out or omit the <form ...>, Cart Button and </form> tags. That way no-one will be able to buy.

            If you prefer a .HTML page, you could always write a tiny bit of PHP that returns a line of JavaScript that sets the date.

            E.g.

            <script type="text/javascript" src="setdate.php"></script>

            And setdate.php returns something like

            var servertime = new Date("<?php CODE TO GENERATE CURRENT DATE STRING HERE ?>");

            You may need to do some more coding to allow for people who load the page before the cutoff and then leave it open for ages. Perhaps an onsumbit for that product only.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              thanks guys - lots to go into the melting pot. I'd better start having a play!
              Elysium:Online - Official Accredited SellerDeck Partner
              SellerDeck Design, Build, Hosting & Promotion
              Based in rural Northants

              Comment

              Working...
              X