Jump to content

Incorrect Syntax?


roldahayes

Recommended Posts

Hi,

 

Can anyone point me in the right direction where I may be going wrong with the correct syntax in this code please?

 

private function considerVouchers( $voucherCode ){//The voucher code value is checked to ensure it is not empty // (as per point 1)if( $voucherCode != '' ) // we need the date, to see if the voucher has expired$cts = date('Y-m-d H:i:s');$voucher_sql = "SELECT *, if('{$cts}' > expiry, 1, 0)AS expired FROM discount_codesWHERE vouchercode='{$voucherCode}' LIMIT 1";$this->registry->getObject('db')->executeQuery( $voucher_sql );if( $this->registry->getObject('db')->numRows() == 0 ){$this->voucher_notice = 'Sorry, the voucher code you enteredis invalid';}else{$voucher = $this->registry->getObject('db')->getRows();if( $voucher['active'] == 1 ){if( $voucher['expired'] == 1 ){$this->voucher_notice = 'Sorry, this voucher has expired';return false;}else{// check to see there are some vouchers, and customer// has enough in their basket (points 3 and 4)if( $voucher['num_vouchers'] != 0 ){if( $this->cost >= $voucher['min_basket_cost'] ){$this->discountCode = $voucherCode;$this->discountCodeId = $voucher['ID'];// If the discount operation is a percentage, then// the discount value is applied to the basket cost// to calculate that percentage. This amount is then// deducted from the order cost, giving a "discount// value"% discount from the order.if( $voucher['discount_operation'] == '%' ){$this->cost = $this->cost - (($this->cost)/100)*$voucher['discount_amount'];$this->voucher_notice = 'A ' . $voucher['discount_amount'] . '% discount has been applied to your order';return true;// If the discount operation is a subtraction, then // the discount amount from the discount code is // deducted from the order cost, and the order cost // is updated to reflect this.}elseif( $voucher['discount_operation'] == '-' ){$this->cost = $this->cost - $voucher['discount_amount'];$this->voucher_notice = 'A discount of £'. $voucher['discount_amount'] . ' has been applied to your order';return true;// Finally, if the discount operation is set to s // then, we set the shipping cost to the discount // value. This could allow us to set free shipping,// or just reduce shipping costs.}elseif( $voucher['discount_operation'] == 's' ){$this->shipping_cost = $voucher['discount_amount'];$this->voucher_notice = 'Your orders shipping costhas been reduced to £' . $voucher['discount_amount'];return true;}}else{$this->voucher_notice = 'Sorry, your order total is not enough for your order to qualify for this discount code';return false;}}else{$this->voucher_notice = 'Sorry, this was a limitededition voucher code, there are no more instancesof that code left';return false;}}}else{$this->voucher_notice = 'Sorry, the vocuher code youentered is no longer active';return false;}}}}

Link to comment
Share on other sites

 

I cannot get an error message to appear - Just a blank screen,

Turn error reporting on in the php.ini or check your severs error log.

 

 

Dreamweaver code highlight is suggesting the syntax error is on line 1 but that is all I can see.

Don't rely on Dreamweaver telling you what the error is.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.