Таким образом, у меня есть эта ошибка «Неподдерживаемые типы операндов», возникающая из конкатенации в коде PHP. Ниже приведена конкретная строка, где происходит ошибка:
'full_name' => ($recipient['firstname'].' '.$recipient['lastname'])
Фрагмент из контейнера массива, показанного ниже:
$summary = array(
'full_name' => ($recipient['firstname'].' '.$recipient['lastname'])
);
В моем коде нет ничего плохого, но он все равно выдает эту ошибку. Он работал раньше, а затем, когда я попытался протестировать его снова, ничего не меняя, появилась ошибка.
Я в настоящее время использую, Codeigniter для платформы.
[ОБНОВЛЕНО] Ниже приведен код функции до места возникновения ошибки:
публичная функция index_post () {
// устанавливаем максимальное время выполнения и ограничение времени, чтобы предотвратить тайм-аут из-за сторонних интеграций
ini_set (‘max_execution_time’, 300);
set_time_limit (300);
// get JSON value post request
$inputJSON = file_get_contents( 'php://input' );
$input_post = json_decode( $inputJSON, TRUE ); //convert JSON into array
// verify points if it still enough
$is_points_enough = $this->verify_member_current_pondo_points($input_post['total_points_to_use']);
// check if member has enough status. if not, return the error code
if ( !$is_points_enough['status'] ) {
$this->response( array(
'status' => TRUE,
'response' => $is_points_enough,
), REST_Controller::HTTP_OK );
}
// construct data to pass to order verification
$order_data['items'] = $input_post['purchase_items']; // items to be redeemed
$order_data['item_redeem_info'] = $input_post['item_redeem_info']; // information of the redeemer
$order_data['member_info'] = array( // member account id and email from verifying token
'account' => $this->user->account_id,
'email' => $this->user->email
);
// check if stocks are enough to continue the process
$order = $this->order_transaction->checkout_order( $order_data );
// if order process failed, it will return an error with its specific error message
if (!$order['status']) {
$this->response( array(
'status' => TRUE,
'response' => $order,
), REST_Controller::HTTP_OK );
}
else {
$items = $order; // these are the list of items already checked
$recipient = $order_data['item_redeem_info']; // information of the redeemer
$recipient_address = $order_data['item_redeem_info']['address']; // address of the redeemer
$delivery_data['recipients'] = array();
$recipient_data = array(
'recipient' => array( // recipient's information
'firstname' => $recipient['firstname'],
'lastname' => $recipient['lastname'],
'middlename' => "",
'contact' => $recipient['contact'],
'email' => $recipient['email'],
'notification' => 1, // value 1 means notification on
'address' => array(
'country' => "PH",
'destination' => $recipient_address['destination'],
'province' => $recipient_address['province'],
'city' => $recipient_address['city'],
'barangay' => $recipient_address['barangay'],
'street' => $recipient_address['street'],
'landmarks' => $recipient_address['landmarks']
)
)
);
array_push($delivery_data['recipients'], $recipient_data);
// if order has physical items included
if (count($items['physical_item'][0]) > 0) {
$address = array( //address of recipient
'province' => $recipient_address['province'],
'city' => $recipient_address['city'],
'barangay' => $recipient_address['barangay'],
'street' => $recipient_address['street']
);
// if type is delivery, insert address data
if ( ($recipient['type'] == "delivery") ) {
$address = $this->order_transaction->add_address( $address );
} else {
$address = $this->order_transaction->get_branch_address_id( $recipient['branch'] );
}
$_items = $items['physical_item']; //physical items list from the order result
$_recipients = $delivery_data['recipients'][0]['recipient'];
$packages['packages'] = array();
$items_for_summary = array();
$total_item_quantity = 0;
$item_details = array();
// set delivery details - package; also set the item summary to be delivered
for ( $x = 0; $x < count( $_items ); $x++ ) {
$result = $this->order_transaction->get_product_data_by_id( $_items[ $x ]['purchase_id'] ); //get product data to populate important details
array_push( $item_details, $result );
$_package = array(
'package' => array(
'pouch' => 'UL',
'description' => $result->name,
'weight' => 0,
'width' => 0,
'height' => 0,
'length' => 0,
'value' => 0,
'coupon' => 0,
'sfc' => 0,
'reference' => "",
'notes' => "")
);
//this container is for the delivery information
array_push( $packages['packages'], $_package );
//needed for product shipment information
$total_item_quantity = $total_item_quantity + $_items[ $x ]['quantity'];
}
$delivery_data['recipients'][0]['recipient']['packages'] = $packages['packages'];
//verify pondo account points if it is enough
$is_points_enough = $this->verify_member_current_pondo_points( $input_post['total_points_to_use'] );
// if points is not enough
if ( !$is_points_enough['status'] ) {
$data['status'] = $is_points_enough;
$data['error'] = array(
'code' => $this->error_code['E_NOT_ENOUGH_POINTS'],
'message' => "Not enough points.");
$this->response( array(
'status' => TRUE,
'response' => $data,
), REST_Controller::HTTP_OK );
}
// if points if enough
else {
// points to redeem in pondo
$redeem_data['points'] = $input_post['total_points_to_use'];
// description of redeem info for pondo
$redeem_data['description'] = "Mineski Infinity item/airtime redeem";
// redeem pondo points
$is_redeem = $this->redeem_current_pondo_points( $redeem_data );
// if it failed to redeem points
if ( !$is_redeem ) {
$data['status'] = FALSE;
$data['error'] = array(
'code' => $this->error_code['E_CANNOT_REDEEM'],
'message' => "Cannot redeem points.");
$this->response( array(
'status' => TRUE,
'response' => $data,
), REST_Controller::HTTP_BAD_REQUEST );
}
// if it successfully to redeem points
else {
$delivery_data['schedule'] = $this->_get_delivery_date(); //delivery date
//send delivery information to xend
$booking_info = $this->order_transaction->ship_items( $delivery_data );
$booking_info = json_decode( $booking_info );
$tracking_code = $booking_info->tracking;
// $this->order_transaction->empty_cart( $this->user->id ); //empty cart
echo gettype($recipient['firstname']);
echo gettype($recipient['lastname']);
//set data for product shipment information
$summary = array(
'full_name' => ($recipient['firstname'].' '.$recipient['lastname']),
// 'contact' => $recipient['contact'],
// 'email' => $recipient['email'],
// 'address_id' => $address->id,
// 'branch_id' => ($recipient-['type'] == "pickup") ? $recipient['branch'] : '',
// 'shipment_type' => $recipient['type'],
// 'total_item_quantity' => $total_item_quantity,
// 'member_id' => $this->user->id,
// 'date_ordered' => date( "Y-m-d h:i:s" ),
// 'tracking_code' => $tracking_code[0],
// 'date_received' => 0,
// 'delivery_status' => 'pending',
// 'date_expected_arrival' => 0,
// 'remarks' => (($recipient['remarks'] == NULL) || ($recipient['remarks'] == "")) ? "" : $recipient['remarks']
);
print_r($summary);
Задача ещё не решена.
Других решений пока нет …