One more try - I will pay your $20.00! : LUSENET : S-Mart Shopping Cart : One Thread

I will pay $20.00 to whomever can help me fix my problem... (1st come 1st served)

I added the below code and a few other small snippets of code to my Shopping Cart script to have the ability to give someone a Gift Certificate ID Number to put in their order form for a discount. It reads a TXT file database where each Gift Certificate ID is on a different line in the format of the ID being first, then a separator line ( | ) and then the dollar amount of that Gift Certificate and then subtracts the Gift Certificate amount from the sale total. It works PERFECT and it looks like SM11562|1.00

Now I am trying to add something to it so that it will see the amount of the Gift Certificate ID as a percentage as well as a dollar amount like SM11562|10%

In the code below, you will see the newly added code commented out with #'s. It looks ok to me, but if I have the order form call on a percentage amount like SM11562|10%, the script will not execute and gives me a misconfiguration error or it will only subtract the number (ie: subtract 10 instead of 10%). The problem is in the new code. Can someone please take a look at it and see what you think will fix it for me please?

--------------------------------------------------- sub buy_items2 { &check_required; if ($useverify eq '1') { &CC_Verify; }

if ($FORM{'gift_certificate'}) { $gift_cert=1; open (FILE,"$discount_file"); @CONTENTS=; close(FILE); $SIZE=@CONTENTS;

for ($i=0;$i<$SIZE;$i++) { $_=$CONTENTS[$i]; ($cert_id, $cert_discount) = split(/\|/,$_); if ($FORM{'gift_certificate'} eq $cert_id) { # if ($cert_discount =~ /.*\%/) { # ($percentage,$null) = split(/%/,$cert_discount); # $discount = ($totalprice*$percentage)/100; # $discount =~ s/(.*)\.(\d\d).*/$1\.$2/; # # $totalprice=$totalprice-$discount; # } # else { $discount=$cert_discount; $totalprice=$totalprice-$discount; # } } } } else { $gift_cert=0; }

&send_order; ---------------------------------------------------

-- Scott Moore (, May 16, 1998


you could try SM11562||10% i dont know, maybe

-- Malachany (, February 28, 2000.

Moderation questions? read the FAQ