Home > other >  Enable guest checkout on site?
Enable guest checkout on site?

Time:02-10

Is there a way to set a default user(guest) login for a site so everyone that comes on the website is set as that default(guest) user?

I need a way to enable guest checkout, so new users to this shop site wont have to create an account every time they want to buy something.

Currently its set so that you can't edit the ship/billing address, and if you try to checkout as a guest, it redirects to the login page instead.

This is using php to connect to a mysql database on localhost.

<?php
session_start();
//error_reporting(0);
include('includes/config.php');
if(strlen($_SESSION['login'])==0)
    {   
header('location:.php');
}
else{
    // code for billing address updation
    if(isset($_POST['update']))
    {
        $baddress=$_POST['billingaddress'];
        $bstate=$_POST['bilingstate'];
        $bcity=$_POST['billingcity'];
        $bpincode=$_POST['billingpincode'];
        $query=mysqli_query($con,"update users set billingAddress='$baddress',billingState='$bstate',billingCity='$bcity',billingPincode='$bpincode' where id='".$_SESSION['id']."'");
        if($query)
        {
echo "<script>alert('Billing Address has been updated');</script>";
        }
    }

I think it is querying the database for a userid, and since the default user(guest) doesn't have an ID until they actually sign up, it sets the '$_SESSION['login'])==0.

CodePudding user response:

  •  Tags:  
  • Related