Click here to Skip to main content
15,902,447 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

this code below is from details-html.php file from print-google-cloud-print-gcp-woocommerce plugin in wordpress that print out automatically recipt after placeing an order. it's print out all the details except addon items.

this part of code belong to item and his selected addon

<?php foreach ($order->get_items() as $item) {
		/* @var $item \WC_Order_item */
		$meta = $item['item_meta'];
		$meta = array_filter($meta, function ($key) {
			return !in_array($key, Order::getHiddenKeys());
		}, ARRAY_FILTER_USE_KEY);
		?>
		
		<tbody>
		<tr>
		    <td style="text-align:left;padding:10px" rowspan="<?= count($meta) + 1; ?>"><?= wc_price($item->get_data()['total'], array('currency' => $order->get_currency())); ?></td>
		    <td style="text-align:right;padding:10px" colspan="2"><?= $item['name']; ?> × <?= $item['qty']; ?></td>


		</tr>
		
		<?php $meta = array_map(function ($meta, $key) {
			$result = '<tr>';
			$result .= '<td>' . $key . '</td>';
			$result .= '<td>' . $meta . '</td>';
			$result .= '</tr>';
			return $result;
		}, $meta, array_keys($meta));
		echo implode(PHP_EOL, $meta);
		?>
		</tbody>
	<?php } ?>
		<?php foreach ($order->get_fees() as $fee) { ?>
				<tbody>
				<tr>
						<td colspan="2"><?= $fee->get_name() ?></td>
						<td><?= wc_price($fee->get_total(), array('currency' => $order->get_currency())); ?></td>
				</tr>
				</tbody>
		<?php } ?>


i am getting error "_addon_items Array"

Please Help me to Solve this.

What I have tried:

i try to change the ['item_meta'] to ['item_id'] according to some guide but didn't work!
Posted
Comments
Richard Deeming 22-Apr-21 3:44am    
Provide the full error message, and specify which line it occurs on.
Tomer Cohen 2021 24-Apr-21 17:04pm    
<?php include 'style.php'; ?>





















get_items() as $item) {
/* @var $item \WC_Order_item */
$meta = $item['item_meta'];
$meta = array_filter($meta, function ($key) {
return !in_array($key, Order::getHiddenKeys());
}, ARRAY_FILTER_USE_KEY);
?>
';
$result .= '';
$result .= '';
$result .= '';
return $result;
}, $meta, array_keys($meta));
echo implode(PHP_EOL, $meta); >>> i think it's happening in this line
?>

get_fees() as $fee) { ?>

get_subtotal_to_display(); ?> get_shipping_total(), array('currency' => $order->get_currency())); ?> get_total_tax(), array('currency' => $order->get_currency())); ?> get_payment_method_title(); ?> get_total(), array('currency' => $order->get_currency())); ?> × get_data()['total'], array('currency' => $order->get_currency())); ?> ' . $key . '' . $meta . ' get_name() ?> get_total(), array('currency' => $order->get_currency())); ?>








get_shipping_method()) { ?>

needs_shipping_address() && ($shipping = $order->get_formatted_shipping_address())) : ?>

get_customer_note())): ?>

get_formatted_billing_address()) ? $address : __('N/A', 'woocommerce'); ?>
get_billing_phone()) : ?>
get_billing_phone()); ?>

get_billing_email()) : ?>
get_billing_email()); ?>



get_customer_note(); ?>







Richard Deeming 26-Apr-21 3:14am    
Reposting the code from your question, whilst ignoring the request to post the actual error message you are trying to solve, does not help.

Your question cannot be answered based on the details provided.
Tomer Cohen 2021 26-Apr-21 4:51am    
I am trying to Paste the all code but it's ignoring the html
there is anyway to paste all code?
Richard Deeming 26-Apr-21 4:53am    
You are really determined NOT to get any help, aren't you? 🤦‍♂️

DO NOT dump all of your code on us and expect someone to fix it for you.

Instead, explain what the problem is. Provide the full details of the error message.

Or continue trying to dump your code without explanation, and make it onto the "ignored, probably trolling" list.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900