Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] New user Account / Quote Number



******    message to minivend-users from Bill Randle <billr@exgate.tek.com>     ******

Here's an alternate solution using a UserTag and the File::CounterFile module
used by MiniVend[4] to implement its counters. Put this in a file named
'fcounter' in your global or catalog specific usertag directory.

UserTag fcounter Order file
UserTag fcounter Routine <<EOF
sub {
    my $file = shift || 'etc/counter';
    $file = $Vend::Cfg->{VendRoot} . "/$file"
        unless index($file, '/') == 0;
    my $ctr = new File::CounterFile $file;
    return $ctr->inc();
}
EOF

This would be used like this:
  [if scratch quote_num]
  <INPUT TYPE=hidden NAME=quote_number VALUE="[scratch quote_num]">
  [else]
  [seti quote_num][fcounter path_to_quote_number_file][/seti]
  [/else]
  [/if]	

to increment the number each time [fcounter] is called. The File::CounterFile
module takes care of all the necessary file locking to prevent simultaneous
access, etc. If the filename is omitted, it uses a file named "counter" in
the etc directory of your catalog.

If the file doesn't exist, it will create it with an initial value of 0.
If you want your sequnce numbers to start at a different value, you could
pass another arg to [fcounter] with the initial value, which is then
passed on to the 'new' function:
	my $ctr = new File::CounterFile $file $initial;

See $(MVROOT)/lib/File/CounterFile.pm for more details.

	-Bill

Cameron Prince wrote:
> 
> ******    message to minivend-users from Cameron Prince <PRINCECB@novachem.com>     ******
> 
> Ven,
> 
> I completed the quotation number support for my catalog and maybe you can
> use it to help you with the id number you need.
> 
> Here's the global sub from minivend.cfg: (DITCHED USING ARRAYS)
> 
> GlobalSub <<EOF
> sub QuoteNumber {
> my $quote_log = '/path/to/quote.number';
> 
> open(QUOTENUM,"<$quote_log");
> my $prev_quote_num = <QUOTENUM>;
> close(QUOTENUM);
> 
> my $new_quote_num = $prev_quote_num + 1;
> 
> open(QUOTENUM,">$quote_log");
> print QUOTENUM ($new_quote_num);
> close(QUOTENUM);
> 
> $Vend::Session->{scratch}->{quote_num} = $new_quote_num;
> return "";
> }
> EOF
> 
> And the code on the basket page:
> 
> [if scratch quote_num]
> <INPUT TYPE=hidden NAME=quote_number VALUE="[scratch quote_num]">
> [else]
> [perl arg=sub interpolate=1]QuoteNumber('')[/perl]
> [/else]
> [/if]
> 
> So the way this works is if the visitor adds a service to the basket and
> hasn't been to the basket before, a new quote number is generated.
> (Incremented once)
> 
> He can continue to add things to the basket within the same session and the
> number doesn't increment.
> 
> He can save, email or process the quote and the quote number is then added
> to a field in userdb.
> 
> Good luck,
> 
> Cameron
[snip]
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: