I am writing custom woocomerce plugin I have list of Items on a page each has its own add button when I press that in session array I store the that and want to show that that in cart page in one row table like woocommerce plugin does my code is bellow I don't know how to redirect to other page after click in add button. //items list page: when some one click on add button I want to redirect to cart page.
<?php
function register_session(){
if(!session_id()) session_start();
}
add_action('init','register_session');
?>
<table border="1">
<tr>
<th>Item_ID</th>
<th>Item Description</th>
<th>Packing Size</th>
<th>Cart</th>
</tr>
<?php
$result1 = $wpdb->get_results ( "SELECT * FROM wp_orderlist where
category_id = $cat ");
foreach ( $result1 as $print1 ) {
echo '<tr>';
echo '<td>'. $print1->item_id.'</td>';
echo '<td>'. $print1->Item_Description.'</td>';
echo '<td>'. $print1->Packing.'</td>';
echo '<td> <form method="post"> <input type="submit" name="add"
href="$print1->item_id" value="ADD"></form> </td>';
echo '</tr>';
}
echo '</tr> ';
?>
</table>
</div>
<?php }
if (isset($_POST['add']))
{
$cart = array (
'oid' => $print1->item_id,
'des' => $print1->Item_Description,
'pack' => $print1->Packing
);
$_SESSION['cart'][] = $cart;
print_r($_SESSION['cart']);
}
?>
//I place this code on cart page to show data in array just for testing
//I am getting empty array.
<?php
$cart = ! empty( $_SESSION['cart'] ) ? $_SESSION['cart'] : false;
$_SESSION['cart'][] = $cart;
print_r($_SESSION['cart']);
exit;
?>
// I want automatic redirection to cart and want to show session
// data in one row table.