Announcement

Collapse
No announcement yet.

Checking minimum quantities (again)

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

    Checking minimum quantities (again)

    As part of our online wine shop,we need to ensure that customers purchase a minimum of 12 bottles during any purchase (after that they can buy single or multiples of any bottle.) In order to do this we've made use of Norman Rouxell's neat and excellent Javascript code to read the number of items in the cookie stored on the client machine and then check that the order meets the minimum requirement. However whilst this works for individual items, it poses a problem when a customer purchases a predefined case of 12 bottles, which then registers as one item. We have attempted to create components relating to each case, but the cookie maintains a value of 1 item for a case and so this method also does not work. (see thread http://community.actinic.com/showthr...5&goto=newpost items 11 thru 14.)

    We have therefore tried to examine the Perl code executed when the customer checks out of the store. In OrderScript.pl, there is a sub-routine called 'ValidateStart' which seems to be called every time a customer checks out. This sub-routine validates each cart item using 'ValidateOrderDetails', a sub-routine contained within the ShoppingCart.pl file.

    'ValidateOrderDetails' appears to create a hash containing information surrounding the product in question, (%Values). A reference to this hash is then returned to the calling sub-routine 'ValidateStart'. (For some reason, the scalar storing this reference is called $pFailure - mistaken naming convention??) It seems logical to carry out a check at this stage to determine the product references of the items purchased. If a product reference could be identified from examining the contents of the hash in question, it would then be simple to write a few lines of code to determine whether the content of the cart is good to go.

    In order to trace the flow of execution (by printing to the page), we have inserted the following line of code within the loop that validates the order details: -

    print "Content-type: text/html\n\n";

    We have confirmed that $pFailure contains a reference to a hash by using: -
    print $pFailure;

    In order to obtain values from the hash we have tried using
    print $pFailure->[0]; (This seems to just stop everything)

    We are also unable to get a list of the hash by using
    print %{$pFailure};

    We are not perl programmers but we can't see a reason why this hash should be empty at this point. Can anybody point us in the right direction for obtaining the values contained within the hash?

    (we have submitted a request to support on the basic problem but this is where we have got to at the moment) All help, suggestions (even if it's to tell us we're idiots) would be appreciated.

    Dave
    Last edited by davecuttriss; 01-Oct-2004, 01:18 PM. Reason: Spelling

    #2
    Hi there

    I'm afraid I am unable to provide detailed Perl support as you obviously know more about Perl than I do. Hopefully someone else on here can provide some details.

    Comment


      #3
      Originally posted by cdicken
      Hi there

      I'm afraid I am unable to provide detailed Perl support as you obviously know more about Perl than I do. Hopefully someone else on here can provide some details.
      Thanks Chris: anyone else out there who'd like a try?

      Cheers

      Dave

      Comment

      Working...
      X