Jump to content

NOOB with no idea, unexpected T_IF , No idea what ive done wrong


Avinitlarge

Recommended Posts

Hi

First of all, I know VERY little about PHP, The effort below is a wile guess that has gone wrong. I get this error Parse error: syntax error,

 

unexpected T_IF in /home/repairyo/public_html/shop/includes/content/viewOrders.inc.php on line 57

 

I have no idea what ive done wrong, may be I am stupid for attempting it.

 

Cheers

Paul

 

This is the original code

$view_orders->assign('VAL_STATE',$lang['glob']['orderState_'.$orders[$i]['status']]);

 

This is the modified code

 

			$view_orders->assign('VAL_STATE',$state = $results[$i]['status'] 
                         if ($state == '1') {
	 "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>";
	} else if ($state == '2') {
	 "<font color='#009900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>";
	} else if ($state == '4') {
	 "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>";
	} else if ($state == '5') {
	 "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>";
	} else if ($state == '6') {
	 "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>";
	} else if ($state == '7') {
	 "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>";
	} else {
	 $lang['glob']['orderState_'.$orders[$i]['status']]); }

:shrug:

Link to comment
Share on other sites

Thanks, That got rid of the error. I still cant get it to work properly though. I don't know what I am doing wrong.

 

If the order is has been cancelled, I should see cancelled in red in the order form which I thought would be the ($state =='6') but instead all I am seeing is the number 6 in black. I can't work out what ive done wrong, its frying my head.

 

Ive altered the code from the above

			$view_orders->assign('VAL_STATE',$state = $orders[$i]['status']);
                        if ($state == '1') {
	echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
} else if ($state == '2') {
	echo "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($state == '4') {
	echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($state == '5') {
	echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($State == '6') {
	echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($state == '7') {
	echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else {
	 $lang['glob']['orderState_'.$orders[$i]['status']]; }

 

$lv = !$langBully ?  "lang" : "bully";
${$lv}['glob'] = array(
'orderState_1' => "Pending (New Order)",
'orderState_2' => "Processing (See order notes)",
'orderState_3' => "Order Complete & Dispatched",
'orderState_4' => "Declined (See order notes)",
'orderState_5' => "Failed Fraud Review",
'orderState_6' => "Cancelled",]

Link to comment
Share on other sites

Yep, every one of them

 

Here is the full page is it helps any better. Im on the verge of giving up

 

if(!defined('CC_INI_SET')){ die("Access Denied"); }

// include lang file

$lang = getLang('includes'.CC_DS.'content'.CC_DS.'viewOrders.inc.php');
$lang = getLang('orders.inc.php');

// query database

$view_orders=new XTemplate ('content'.CC_DS.'viewOrders.tpl');

$view_orders->assign('LANG_YOUR_VIEW_ORDERS',$lang['viewOrders']['your_orders']);

$orders = $db->select('SELECT `status`, `cart_order_id`, `time`, `courier_tracking` FROM '.$glob['dbprefix'].'CubeCart_order_sum WHERE `customer_id` = '.$db->mySQLsafe($cc_session->ccUserData['customer_id']).' ORDER BY `time` DESC');

if ($orders) {

	$view_orders->assign('LANG_ORDER_LIST',$lang['viewOrders']['orders_listed_below']);

	$view_orders->assign('LANG_ORDER_NO',$lang['viewOrders']['order_no']);
	$view_orders->assign('LANG_STATUS',$lang['viewOrders']['status']);
	$view_orders->assign('LANG_DATE_TIME',$lang['viewOrders']['date_time']);
	$view_orders->assign('LANG_ACTION',$lang['viewOrders']['action']);
	$view_orders->assign('LANG_VIEW_ORDER',$lang['viewOrders']['view']);
	$view_orders->assign('LANG_COURIER_TRACKING', $lang['viewOrders']['courier_tracking']);

	for($i = 0, $maxi = count($orders); $i < $maxi; ++$i)
	{

		$state = $orders[$i]['status'];
		$orders[$i]['state'] =  $lang['glob']['orderState_'.$state];

		$view_orders->assign('TD_CART_CLASS',cellColor($i, 'tdcartEven', 'tdcartOdd'));
		$view_orders->assign('DATA',$orders[$i]);

		$view_orders->assign('VAL_STATE',$state = $orders[$i]['status']);
           if ($state == '1') {
	 "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
} else if ($state == '2') {
	 "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($state == '4') {
	 "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($state == '5') {
	 "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($state == '6') {
	 "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else if ($state == '7') {
	 "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
	} else 
	                          $lang['glob']['orderState_'.$orders[$i]['status']]; 	
	                          
	                          
		$view_orders->assign('VAL_DATE_TIME',formatTime($orders[$i]['time']));	

		if (!empty($orders[$i]['courier_tracking'])) {
			$view_orders->assign('TRACKING_URL', $orders[$i]['courier_tracking']);
			$view_orders->parse('view_orders.session_true.orders_true.repeat_orders.courier_tracking');
		}

		if (in_array($orders[$i]['status'], array(1,4))) {
			$view_orders->assign('LANG_COMPLETE_PAYMENT',$lang['viewOrders']['complete_payment']);
			$view_orders->parse('view_orders.session_true.orders_true.repeat_orders.make_payment');

		}

		$view_orders->parse('view_orders.session_true.orders_true.repeat_orders');

	}

	for ($i=1; $i<=6; ++$i) {
		$view_orders->assign('LANG_ORDER_STATUS',$lang['glob']['orderState_'.$i]);
		$view_orders->assign('LANG_ORDER_STATUS_DESC',$lang['glob']['orderState_'.$i.'_desc']);
		$view_orders->parse('view_orders.session_true.orders_true.repeat_status');

	}
	$view_orders->parse('view_orders.session_true.orders_true');
} else {
	$view_orders->assign('LANG_NO_ORDERS',$lang['viewOrders']['no_orders']);
	$view_orders->parse('view_orders.session_true.orders_false');
}


$view_orders->assign('LANG_LOGIN_REQUIRED',$lang['viewOrders']['login_required']);

if($cc_session->ccUserData['customer_id']>0) $view_orders->parse('view_orders.session_true');

else $view_orders->parse('view_orders.session_false');

$view_orders->parse('view_orders');

$page_content = $view_orders->text('view_orders');
?>

Link to comment
Share on other sites

I believe your problem is the value in the array, even though you have the array values orderState_1 to 6,

 

the array values you call actually start at 0 not 1 so the cancelled value would be state 5 not 6, this will be the same for all your orderState values

 

a quick and dirty way to fix this is

 

${$lv}['glob'] = array(
'orderState_0' => "No Order",
'orderState_1' => "Pending (New Order)",
'orderState_2' => "Processing (See order notes)",
'orderState_3' => "Order Complete & Dispatched",
'orderState_4' => "Declined (See order notes)",
'orderState_5' => "Failed Fraud Review",
'orderState_6' => "Cancelled");

Link to comment
Share on other sites

ok you are now missing some echo tags from what you posted originally, echo is what prints to the screen, also you have a value orderState 7 but no 7 in the array so change this part

         if ($state == '1') {
       "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
   } else if ($state == '2') {
       "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '4') {
       "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '5') {
       "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '6') {
       "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '7') {
       "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else
                                $lang['glob']['orderState_'.$orders[$i]['status']];    

 

to

 

         if ($state == '1') {
        echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
   } else if ($state == '2') {
        echo "<font color='#009900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '3') {
       "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '4') {
        echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '5') {
        echo "<font color='#cc0000'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else if ($state == '6') {
        echo "<font color='#ff9900'>".$lang['glob']['orderState_'.$orders[$i]['status']]."</font>";
    } else {
       echo $lang['glob']['orderState_'.$orders[$i]['status']];    
    }

 

you were also missing some curly brackets on the last else statement

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.