Creating a favourites page by using a session variable - php

I am trying to create a Favourites Pages where the user selects items from the "menu" and then the item is placed in the Favourites Page. I am making use of a session variable
$_SESSION['favourites']
I am starting the session by using the
session_start('session.php');
In the session_start it includes
<?php
session_start();
?>
The favourite feature works when I combine the two files together, but it does not work when I display the favourites on a different page.
This is the menu page
$conn = mysqli_connect("localhost", "root", "", "restaurant");
$sql= "SELECT * FROM menu ORDER BY id ASC";
$result=mysqli_query($conn, $sql);
$resultcheck=mysqli_num_rows($result);
if(isset($_POST["add_to_favourite"]))
{
if(isset($_POST["favourites"]))
{
$food_item_id = array_column($_SESSION["favourites"], "item_id");
if(!in_array($_GET["id"], $food_item_id))
{
$count = count($_SESSION["favourites"]);
$item_array = array(
'item_id' => $_GET["id"],
'item_name' => $_POST["hidden_name"],
'item_price' => $_POST["hidden_price"],
'item_desc' => $_POST["hidden_desc"]
);
$_SESSION["favourites"][$count] = $item_array;
}else{
echo '<script>alert(You have already added this item to Favourites")</script>';
}
}
else{
$food_array = array(
'item_id' => $_GET["id"],
'item_name' => $_POST["hidden_name"],
'item_price' => $_POST["hidden_price"],
'item_desc' => $_POST["hidden_desc"]
);
$_SESSION["favourites"][0] = $food_array;
}
}
?>
<!-- Start of HTML -->
<section id="intro">
<div class="hero-global container">
<h1 class="global-header">Detailed Menu</h1>
</div>
</section>
<div class="container">
<ul class="food-cards">
<?php
if($resultcheck>0)
{
while($row=mysqli_fetch_assoc($result))
{
?>
<li class="card-info">
<form method="post" action="favourites.php?action=add&id=<?php echo $row["id"]; ?>">
<div class="food-card">
<div class="food-pic">
<img src="./assets/english-breakfast.png" alt="">
</div>
<div class="food-cont">
<h2 class="food-title">
<?php
echo $row['name']
?>
</h2>
<p class="food-desc">
<?php echo $row["description"]; ?>
</p>
<div class="price-fav-btn">
<div class="price">
<?php
echo "€".$row['price']
?>
</div>
<div class="atf-btn">
<input class="fav-btn" type="submit" name="add_to_favourite" value="Add to Favourites"/>
</div>
<input type="hidden" name="hidden_name" value="<?php echo $row["name"]; ?>" />
<input type="hidden" name="hidden_price" value="<?php echo $row["price"]; ?>" />
<input type="hidden" name="hidden_desc" value="<?php echo $row["description"]; ?>" />
</div>
</div>
</div>
</form>
</li>
<?php
}
}
?>
</ul> <!-- end of ul list -->
</div>
This is the favourites page, where the items are displayed.
<?php
if(isset($_GET["action"]))
{
if($_GET["action"] == "delete")
{
foreach($_SESSION["favourites"] as $keys => $values)
{
if($values["item_id"] == $_GET["id"])
{
unset($_SESSION["favourites"][$keys]);
echo '<script>alert("Item Removed")</script>';
echo '<script>window.location="menudetails.php"</script>';
}
}
}
}
?>
<div><h1>Favourites</h1></div>
<table>
<tr style="text-align: left">
<th width="30%">Name</th>
<th width="60%">Description</th>
<th width="5%">Price</th>
<th width="5%">Remove</th>
</tr>
<?php
if(!empty($_SESSION["favourites"]))
{
foreach($_SESSION["favourites"] as $key => $value)
{
?>
<tr>
<td width: 20%><?php echo $value["item_name"] ?></td>
<td style="text-align: left"><?php echo $value["item_desc"]?></td>
<td><?php echo '€'.$value["item_price"]?></td>
<td><span class="fav-btn">Remove</span></td>
</tr>
<tr>
</table>
<?php
}
}
?>
EDIT:
I am starting the session on both pages.
Also, the part that is not working is when it comes to seeing whats in the favourites page. There is not output, only the link (in search bar) with the respective id.
Output

Related

codeigniter update multiple record using checkbox with mongo

I'm using the checkbox to sending an email that already selected. after the email sent, the status sendinvoice change to Y. everything is fine when I select 1 checkbox. but when I choose multiple checkboxes, the function only update 1 checkbox
How to make it can run update function with multiple checkboxes?
the view code for checkbox and button below
<button type="button" class="btn waves-effect waves-light btn-info" id="btn-sentcitilink"> Sent Email</button>
<?php
foreach($result as $row){
?>
<form method="post" action="<?php echo base_url(); ?>cms/emailcitilink" id="sentemailcitilink">
<?php
}
?>
<table id="myTable" class="table table-bordered table-striped">
<thead>
<tr>
<th>Send Invoice </th>
<th>Booking ID</th>
</tr>
</thead>
<tbody>
<?php
foreach($result as $row){
?>
<tr>
<td>
<?php if($row['sendinvoice'] == 'N'){ ?>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" name="books[]" id="tableDefaultCheck/<?php echo $row['booking_id']?>" value="<?php echo $row['booking_id']?>">
<label class="custom-control-label" for="tableDefaultCheck/<?php echo $row['booking_id'] ?>"></label>
</div>
<?php } ?>
<?php if($row['sendinvoice'] == 'Y'){ ?>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="tableDefaultCheck3" checked disabled>
<label class="custom-control-label" for="tableDefaultCheck3"></label>
</div>
<?php } ?>
</td>
<td>
<div class="hover-link">
<a href="<?php echo base_url(); ?>cms/transaction/view/<?php echo $row['_id'] ?>">
<?php echo $row['booking_id'] ?>
</a>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<script>
$(document).ready(function() {
$("#check-all").click(function() {
if ($(this).is(":checked"))
$(".check-item").prop("checked", true);
else // Jika checkbox all tidak diceklis
$(".check-item").prop("checked", false);
});
$("#btn-sentcitilink").click(function() {
var confirm = window.confirm("Apakah Anda mengirim email data-data ini?");
if (confirm)
$("#sentemailcitilink").submit();
});
});
</script>
The controller code
function emailtocitilink(){
$books = $_POST['books'];
$get_trans = $this->cms_model->get_transaction_by_list_trip($tripsData);
foreach($get_trans as $row){
$arr_data = array(
'booking_id' => $row['TRANSIDMERCHANT'],
);
array_push($arr, $arr_data);
}
$data = $this->data;
$data['result'] = $arr;
$datas = array(
'SendINVOICE' => "Y"
);
$insert = $this->cms_model->update_transaction($datas, $books);
redirect(base_url().'cms/citilinktransaction/');
}
Model
function get_transaction_by_list_trip($TripUUID){
return $this->mongo_db
->where_in('TripUUID', $TripUUID)
->where(array('PAYMENTCHANNEL' => 'TESTINGCHANNEL'))
->order_by(array('transaction_date' => 'desc'))
->get('tr_transaction');
}
function update_transaction($datas, $books){
return $this->mongo_db->where_in('TRANSIDMERCHANT', $books)
->set($datas)
->update('tr_transaction',['multi' => TRUE]);
}
On model, it should be 'multiple' => true
Use update_all to update multiple records:
$this->mongo_db
->set($datas, ["multi" => true])
->where_in('TRANSIDMERCHANT', $books)
->update_all('tr_transaction');

hidden input value do not display in foreach loop in php

Now this display in this way
I'm developing a simple shopping cart, using session variable called ($_SESSION['shopping_cart']. and I use 2 hidden field for price, and item name. I try to display the summary of cart details , but price and item name do not display in the table. But quantity is displayed.I tried a lot to solve this, but it does not display the item name, and price properly.
Please if some one can help me to solve this problem I highly appreciate your guidance, Thanks in advance.
<?php
//database connect
$connect = mysqli_connect('localhost', 'root','', 'carta');
//if session variable is set
if (isset($_POST['add_to_cart'])) {
if (isset($_SESSION['shopping_cart']))
{
$item_id_array = array_column($_SESSION['shopping_cart'], 'item_id');
if (!in_array($_GET['id'], $item_id_array)) {
// counter to track the number of products in cart
$count = count($_SESSION['shopping_cart']);
//add new items to cart
$item_array = array(
"item_id" => $_GET['id'],
"item_name" => $_POST['hidden_name'],
"item_price" => $_POST['hidden_price'],
"item_quantity" => $_POST['quantity']
);
$_SESSION['shopping_cart'][$count] = $item_array;
}else{
echo "<script>alert('Item Already Added...');</script>";
}
}else{
//if shopping cart session variable doesn't exit, create array & store item details
$item_array = array(
"item_id" => $_GET['id'],
"item_name" => $_POST['hidden_name'],
"item_price" => $_POST['hidden_price'],
"item_quantity" => $_POST['quantity']
);
// store item details into session variable
$_SESSION['shopping_cart'][0] = $item_array;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Shopping Cart</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<!-- custom css -->
<link rel="stylesheet" type="text/css" href="cartcustom.css">
</head>
<body>
<div class="container">
<h3 class="text-center">Shopping Cart</h3>
<?php
//get data from database
$query = 'SELECT * FROM products ORDER BY id ASC';
$result = mysqli_query($connect, $query);
if ($result){
if (mysqli_num_rows($result)>0){
while ($row = mysqli_fetch_assoc($result)){
// print_r($row);
?>
//form
<div class="col-sm-2 col-md-3">
<form method="post" action="index.php?action=add&id=<?php echo $row['id']; ?>">
<img src="<?php echo $row['image']; ?>" class="img-responsive">
<h6 class="text-info"><?php echo $row['name']; ?></h6>
<h6 class="text-danger"><?php echo "Rs:" . $row['price'] . ".00" ?></h6>
<input type="text" name="quantity" class="form-control" value="1">
<input type="hidden" name="hidden_name" value="<?php echo $row['name']; ?>"/>
<input type="hidden" name="hidden_price" value="<?php echo $row['price']; ?>"/>
<input type="submit" name="add_to_cart" class="btn btn-success" value="Add to Cart">
</form>
</div>
<?php
}
}
}
?>
</div>
//table of displaying final cart details
<div class="container">
<h4 class="text-center">Order Details</h5>
<div class="table_responsive">
<table class="table table-bordered">
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
<th>Action</th>
</tr>
<?php
if (!empty($_SESSION['shopping_cart'])) {
$total = 0;
foreach ($_SESSION['shopping_cart'] as $keys => $values) {
?>
//display the cart details to customer using a table
<tr>
<td><?php echo $values["item_name"]; ?></td> // this does not display
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <?php echo $values["item_price"]; ?></td> //this does not display
<td> <?php echo number_format($values['item_quantity'] * $values['item_price'], 2 ) ?></td>
</tr>
<?php
}
}
?>
</table>
</div>
</div>
</body>
</html>

Pass id from form to delete function

I have created the following wordpress page template:
<?php
/* Template Name: Report Creator */
get_header();
wp_enqueue_style( 'wp-admin' );
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
?>
<style>
.table td{
padding-left:0;
}
</style>
<!-- ############################### -->
<?php
if(isset($_POST['function-action'])){
$function_action = $_POST['function-action'];
switch($function_action){
case 'form-edit-profile':
break;
case 'form-delete-profile':
wp_delete_post(); //pass ID over here to delete the post
break;
default:
break;
}
}
?>
<table>
<tr>
<th>Titel</th>
<th>Creation Date</th>
<th>Next fetch time</th>
<th># of Recipience</th>
<th>Functions</th>
</tr>
<?php
if ( is_user_logged_in() ):
global $current_user;
$author_query = array('post_status' => array( 'draft' ),
'author' => $current_user->ID,
'meta_query' => array(
array(
'key' => 'wpgamail_options',
'key' => 'ganalytics_settings',
),
),);
$author_posts = new WP_Query($author_query);
while($author_posts->have_posts()) : $author_posts->the_post();
?>
<tr>
<td>
<?php the_title(); ?>
</td>
<td>
<?php $post_date = get_the_date(); echo $post_date; ?>
</td>
<td>
<?php $field = get_field('wpgamail_options', get_the_ID(), true); echo "Next report on " . date('l jS \of F Y h:i:s A', $field['nextfetchtime']); ?>
</td>
<td>
<?php echo count($field['recipients']) . " Recipient"; ?>
</td>
<td>
<form method="post">
<input type="hidden" name="function-action" value="form-edit-profile"/>
<input type="submit" value="Edit Profile" class="button button-primary" />
</form>
</td>
<td>
<form method="post">
<input type="hidden" name="function-action" value="form-delete-profile"/>
<input type="submit" value="Delete Profile" class="button button-primary" onclick="return confirm('Do you really want to delete the report-settings?')" />
</form>
</td>
</tr>
<?php
endwhile;
else :
echo "You are not logged in. Please log in!";
endif;
?>
</table>
<hr/>
</main>
<!-- .site-main -->
</div>
<!-- .content-area -->
<?php get_footer(); ?>
My problem is that I do not know how to pass the id of the currently selected post to the switch-caseconstruct in order to delete / edit the post.
Any suggestions how to do that?
I appreciate your replies!
Try this.
Your HTML
<form method="post">
<input type="hidden" name="function-action" value="form-delete-profile" />
<input type="hidden" name="this_id" value="<?php echo get_the_ID(); ?>" />
<input type="submit" value="Delete Profile" class="button button-primary" onclick="return confirm('Do you really want to delete the report-settings?')" />
</form>
Your PHP
<?php
if(isset($_POST['function-action'])){
$function_action = $_POST['function-action'];
$this_id = (int)$_POST['this_id'];
$post_author = get_post_field( 'post_author', $this_id ); //Get post's author
switch($function_action){
case 'form-edit-profile':
break;
case 'form-delete-profile':
if( $post_author == get_current_user_id() ) { //This condition is to check that currect is the author of this post
wp_delete_post( $this_id ); //pass ID over here to delete the post
} else{
echo "You don't have permission to delete it.!";
}
break;
default:
break;
}
}
?>
Good luck

Codeigniter shopping cart: getting a notice that says - Trying to get property of non-object in my controller

Im quiet new to codeigniter and i am having some trouble setting up my shopping cart. plzz help!!
This is my model:
class shop_model extends CI_Model
{
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_all() {
$results = $this->db->get('product')->result();
return $results;
}
function get($id) {
$results = $this->db->get_where('product', array('id' => $id))->row_array();
$result = $results[0];
//result()
return $result;
}
}
my controller:
class shop extends CI_Controller {
public function __construct()
{
parent::__construct();
//$this->load->library(array('form_validation', 'email','pagination'));
$this->load->database();
$this->load->model('shop_model');
}
public function index()
{
$data['products'] = $this->shop_model->get_all();
//print_r($data['products']);
$this->load->view('template/header');
$this->load->view('watch_stop/vprod_list', $data);
$this->load->view('template/footer');
}
public function prod_cart(){
$data['title'] = 'Shopping Cart | Watch Stop';
$this->load->view('template/header');
$this->load->view('watch_stop/vcart', $data);
$this->load->view('template/footer');
}
function add(){
$prod_list = $this->shop_model->get($this->input->post('id'));
$id = $this->input->post('id');
$insert = array(
'id' => $this->input->post('id'),
'qty' => 1,
'price' => $prod_list->price,
'name' => $prod_list->title
);
$this->cart->insert($insert);
print_r($this->cart->contents());
//redirect('shop/prod_cart');
}
}
my cart (view) page:
<div class="row">
<div class="col-md-9">
<?php if ($cart = $this->cart->contents()): ?>
<div id="cart">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Item Name</th>
<th>Option</th>
<th>Price</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($cart as $item): ?>
<tr>
<td><?php echo heading($item['brand'].' - '.$item['gender'], 5).br().$item['title'];?></td>
<td><?php ?></td>
<td><?php echo $item['subtotal']; ?></td>
<td class="remove"><?php anchor('shop/remove'.$item['rowid'], '<i class="fa fa-times fa-2x"></i>'); ?> </td>
<tr>
<?php endforeach; ?>
<tr class="total">
<td colspan="2"><strong>Total:</strong></td>
<td>LKR <?php echo $this->cart->total(); ?></td>
</tr>
</tbody>
</table>
</div> <!--table-responsive end-->
</div> <!--cart end-->
<?php endif; ?>
</div> <!--col-md-9 end-->
</div> <!--.row end-->
my products list (view) page (this page is populated via another controller and model and works perfectly):
<div class="row na_top ws-brand-head">
<!--column 1 start-->
<div class="col-md-12">
<?php
echo heading($sub_head, 2);
echo '<hr>';
?>
</div> <!--column 1 end-->
</div> <!--row end-->
<div class="row">
<?php echo $this->session->flashdata('msg'); ?>
<?php foreach($products as $prod_list): ?>
<!--Column 2 start-->
<div class="col-md-3 ws-brand">
<div id="products" class="naprod naprod-mar">
<?php
$na_1 = array(
'src' => base_url().$prod_list['image'],
'height' => '150',
'alt' => $prod_list['title']
);
echo form_open('shop/add');
echo heading($prod_list['stock'], 5);
echo '<div class="na-img">'.img($na_1).'</div>';
echo '<div class="nacont">';
echo anchor(site_url('product/'.$prod_funct.'/'.$prod_list['id']),'<p class="na-btn">VIEW</p>');
?>
<!--<input type="text" id="id" name="id" value="<?php //echo $prod_list['id'] ; ?>" style=" display:none;"/>-->
<input type="hidden" name="id" value="<?php echo $prod_list['id'] ; ?>" />
<button type="submit" name="action" class="na-btn"><i class='fa fa-shopping-cart fa-lg'></i></button>
<?php
echo '</div>';
echo br();
echo heading('LKR '.$prod_list['price'], 5);
echo '<div id="'.$prod_list['brand'].'_'.$prod_list['gender'].'_'.$prod_list['id'].'">'.$prod_list['title'].'</div>';
echo form_close();
?>
</div> <!--naprod naprod-mar end-->
</div> <!--column 2 end-->
<?php endforeach; ?>
</div> <!--row end-->
When i try to load the shop/add method im getting the following errors:
1)Trying to get property of non-object in my controller shop: line 40 and 41. That is the line where i have created the $insert array 'price' and 'name'.
You have to verify if there is catched $prod_list after you try to catch it with your shop model.. (I am not quite sure what your method get is returning but false check should be enough)
function add(){
$prod_list = $this->shop_model->get($this->input->post('id'));
if( ! $prod_list ) {
echo "Product doesn't exists";
exit;
}
$id = $this->input->post('id');
$insert = array(
'id' => $this->input->post('id'),
'qty' => 1,
'price' => $prod_list->price,
'name' => $prod_list->title
);
$this->cart->insert($insert);
print_r($this->cart->contents());
//redirect('shop/prod_cart');
}

foreach loop results to INSERT into database

I have three different div's that contain the checkout information.
Shipping info
Billing Info
Order confirmation
The shipping information and billing information is obtained by the customer entering that information in manually, but the order confirmation, that contains what they are ordering, the quantity, and pertinent information to that order resides there. That information is obtained from a foreach loop I have in place that displays the information based on the product's ID.
I am trying to figure out how I am going to INSERT the string that displays from my foreach loop into my database. I have an order report page that I want to display what was ordered.
For the shipping information, I validate it and then send my query in with that information. Like this...
<?php
if(Input::exists()) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'fullname' => array(
'required' => true,
'min' => 2,
'max' => 50
)
if($validation->passed()) {
if(isset($_POST['create'])){
$fullname = trim( $_POST['customer_name'] );
?>
<div class="field">
<label class="paddingleft" for="fullname">Full Name</label>
<div class="center"><input type="text" class="biginputbarinline" name="fullname" value="<?php echo escape(Input::get('firstname')); ?>" required></div>
</div>
The part that I am really confused with is how to INSERT the actual string this foreach loop displays. If the result of my foreach loop was:
2 balls
4 shoes.
I want that information to send in with my query.
This is how I have the Order confirmation section as of now..
<div class="checkoutconfirmationcontainer">
<?php foreach($_SESSION['shopping_cart'] as $id => $product) {
$product_id = $product['product_id'];
?>
<span class="tealmedium"><?php echo $product['quantity'] . " - " . $products[$product_id]['name'] . $message; ?></span><br><br><br>
<div class="floatleft"><div class="smallerimgcontainer">
<?php
$result = mysqli_query($con,"SELECT * FROM products");
if($row = mysqli_fetch_array($result)) {
$products[$row['product_id']] = $row;
if($row['image'] == ""){
echo "<img class='sizedimg' src='/productpics/coming_soon.png' alt='Coming Soon'>";
} else {
echo "<img class='sizedimg' src='/productpics/".$row['img']."' alt='Product Picture'>";
}
echo "<br><br><br><br>";
}
?>
</div></div>
<div class="checkoutitemsummary">
<?php echo "<a href='./viewProduct.php?view_product=$id'>" . $product['name'];?><?php echo $products[$product_id]['name']; ?> </a>
<p><span class="redprice"><?php echo '$' . $products[$product_id]['price'] . "<br />"; }?></span></p>
</div>
How can I get the results of my foreach loop to be inserted into my database with my query?
Shopping Cart
<tr>
<th class="cartth">Name</th>
<th class="cartth">Price</th>
<th class="cartth">Category</th>
<th class="cartth">Quantity</th>
</tr>
<?php
$base_price = 0;
foreach($_SESSION['shopping_cart'] as $id => $product) {
$product_id = $product['product_id'];
$base_price += $products[$product_id]['price'] * $product['quantity'];
$shipping_price += $products[$product_id]['shippingprice'] * $product['quantity'];
?>
<tr>
<td class="carttd"><?php echo "<a href='./viewProduct.php?view_product=$id'>" . $product['name'];?><?php echo $products[$product_id]['name']; ?> </a>
</td>
<td class="carttd"><?php echo '$' . $products[$product_id]['price']; ?></td>
<td class="carttd"><?php echo $products[$product_id]['category']; ?></td>
<td class="carttd">
<?php echo "<input type='text' name='quantity[$product_id]' value='" . $product['quantity'] . "' />"; ?> </td>
</tr>
<?php
}
Javascript/Jquery that produces my div transition:
$('.checkoutmenu>li').on('click',function(e){
$('.checkoutprocess>.'+ e.target.classList[0]).show().siblings().hide();
});
<script>
$('.paymentinfocontainer').hide();
$('.confirmationinfocontainer').hide();
</script>
<script>
$('#button2').click(function () {
$(".checkoutprocess > div").hide();
$('.paymentinfocontainer').show("slow");
});
</script>
<script>
$('#button3 ').click(function () {
$(".checkoutprocess > div").hide();
$('.confirmationinfocontainer').show("slow");
});
</script>
<script>
/*
$('#button1').click(function () {
$(".checkoutprocess > div").hide();
$('.shippinginfocontainer').show("slow");
});
</script>
<script>
$('#button2 ').click(function () {
$(".checkoutprocess > div").hide();
$('.paymentinfocontainer').show("slow");
});
</script>
<script>
$('#button3 ').click(function () {
$(".checkoutprocess > div").hide();
$('.confirmationinfocontainer').show("slow");
});
*/
</script>
Ok, when I clicked on "3. Order Confirmation", I got the following HTML:
<div class="confirmationinfocontainer" style="display: block;">
<span class="summarytitle"><p>Order Confirmation</p></span>
<br>
<div class="floatrightinline">
<div class="confirmshippinginfo">
<p>Shipping to:</p>
<p></p>
<p></p>
<p></p>
<p></p>
</div>
</div>
<div class="checkoutconfirmationcontainer">
<div name="product_id"></div>
<span class="tealmedium">1 - Lakers Hat</span>
<br>
<br>
<br>
<div class="floatleft">
<div class="smallerimgcontainer">
<img alt="Coming Soon" src="/productpics/coming_soon.png" class="sizedimg">
<br>
<br>
<br>
<br>
</div>
</div>
<div class="checkoutitemsummary">
Lakers Hat
<p><span class="redprice">$25<br></span></p>
</div>
<input type="hidden" value="405bb6b2b562b4f00dac620d3f68620f" name="token">
<input type="submit" value="Place Your Order" class="widebutton">
<br>
</div>
</div>
So I see you're already making use of a hidden field. So when a users clicks the "Place Your Order" button, you want the details to be passed along. You can simply add these details back to the form via a hidden field. Like so:
<div class="checkoutconfirmationcontainer">
<?php
foreach($_SESSION['shopping_cart'] as $id => $product) {
$product_id = $product['product_id'];
?>
<input type="hidden" name="product_quantity[<?php echo $id; ?>]" value="<?php echo $product['quantity']; ?>" />
<span class="tealmedium"><?php echo $product['quantity'] . " - " . $products[$product_id]['name'] . $message; ?></span><br><br><br>
<div class="floatleft"><div class="smallerimgcontainer">
<?php
$result = mysqli_query($con,"SELECT * FROM products");
if($row = mysqli_fetch_array($result)) {
$products[$row['product_id']] = $row;
if($row['image'] == ""){
echo "<img class='sizedimg' src='/productpics/coming_soon.png' alt='Coming Soon'>";
} else {
echo "<img class='sizedimg' src='/productpics/".$row['img']."' alt='Product Picture'>";
}
echo "<br><br><br><br>";
}
?>
</div></div>
<div class="checkoutitemsummary">
<?php echo "<a href='./viewProduct.php?view_product=$id'>{$product['name']} {$products[$product_id]['name']}</a>"; ?>
<p><span class="redprice"><?php echo '${$products[$product_id]['price']}<br />"; }?></span></p>
</div>
<input type="hidden" name="token" value="405bb6b2b562b4f00dac620d3f68620f">
<input class="widebutton" type="submit" value="Place Your Order">
<br />
</div>
Looking over this, I see no <form> for this. So I suspect JQuery is handling this somewhere else. So my fix may not really get read if your JQuery or app does not now what to look for, or does not hook onto that hidden field. If this is a framework that you're using or Catalog that you're modifying, check their support. I would say you have a lot more work ahead of you.

Categories