Hi All
Im a bit of a php virgin but am embarking on a task to mod my Bakery cart process so I can offer Promotional Code / Voucher discounts on orders.
For those not familiar with the bakery cart process, when a user adds stuff to the cart then submits the order, it brings up view_form.php which allows the customer to input their name / address etc, then continuing goes to view_summary.php where the user confirms the order and contact details are correct which before submitting agains to the billing merchant (Paypal etc).
In my view_form.php Ive added a text box where the customer can add in a voucher code if they have one. When the customer submits the order, this box populates a new field I've created in
wb_mod_bakery_custo mer called "cust_voucher". This is the table where each order is recorded and basically ties the promotion code to the order being placed. This all works fine and I can see the populated "cust_voucher" in the database.
I've also created a new table in the database called
wb_promocode to store the promotional code details. Within this table there are two fields
"code1" stores the text for the promo code (e.g. "APRIL5")
"code1val" stores a number used to calculate the amount of discount to apply (e.g 0.95 to give a 5% discount)
I've populated these two fields in the database, so they can be queried.
The next part of the standard cart process is to open view_summary.php. In here I've entered the following code to query the database to determine if there's a valid promo code, but this is where I'm stuck as the variables don't seem to be correctly set, because if I try to echo the variables, the page fails to display.
$vouchercode = $database->query("SELECT cust_voucher FROM ".TABLE_PREFIX."mod_bakery_customer WHERE order_id = '{$_SESSION['bakery']['order_id']}'");
echo $vouchercode;
$vcode1 = $database->query("SELECT code1 FROM ".TABLE_PREFIX.promocode);
echo $vcode1;
Obviously once I get the variables working I'll be doing something else with them to calculate the discount and won't just be echoing them out to screen! I've tried debug but it doesn't help, so can anyone explain why the above code won't work and where I'm going wrong as my query seems to be identical in format to others used in the same form?
thanks
Chris