[Nulled] » Nulled Warez Scripts » CMS Internet shop Scripts » SimplaCMS script » the bucket entry module to the database
November 14 2022

the bucket entry module to the database

1. SQL

create table s_carts (code varchar(255) not null, user_id int(11), cart text, primary key (user_id, code)) default charset=utf8

2. api/Cart.php

2.1. At the end before the final "}" insert

$query = $this->db->placehold("DELETE FROM __carts WHERE user_id=?", $_SESSION['user_id']);
$this->db->query($query);
} 

if($_SESSION['shopping_cart']){
$query = $this->db->placehold("INSERT IGNORE INTO __carts SET code=?, user_id=?, cart=?", $_COOKIE['shopping_cart_code'], 0, serialize((array)$_SESSION['shopping_cart']));
$this->db->query($query);
if($_SESSION['user_id']){
$query = $this->db->placehold("INSERT IGNORE INTO __carts SET code=?, user_id=?, cart=?", '', $_SESSION['user_id'], serialize((array)$_SESSION['shopping_cart']));
$this->db->query($query);
} 
}
}


public function base_to_cart($param, $add='max')
{
if(empty($param)) return;

// $this->db->query("SELECT cart FROM __carts WHERE code=? OR user_id=? LIMIT 1", $param, $param);
$this->db->query("SELECT cart FROM __carts WHERE code=? OR (user_id>0 AND user_id=?) LIMIT 1", $param, $param);

if($c=$this->db->result('cart'))
$bcs = unserialize($c);

if ($bcs){
if($add=='max'){
if(is_array($bcs))foreach ($bcs as $variant_id => $amount) {
if(isset($_SESSION['shopping_cart'][$variant_id]))
$_SESSION['shopping_cart'][$variant_id]=max($_SESSION['shopping_cart'][$variant_id], (int)$amount);
else
$_SESSION['shopping_cart'][$variant_id]=$amount;
}
}else
$_SESSION['shopping_cart']=$bcs;
}
$this->check_cart();
}


public function check_cart()
{
$sc=(array)$_SESSION['shopping_cart'];
$variant_ids=array_keys($sc);

if(empty($variant_ids))
return;

$_SESSION['shopping_cart']=array(); 

$variants=$this->variants->get_variants(array('id' => $variant_ids));
if(is_array($variants))foreach ($variants as $variant) {
$vids[]=$variant->id;
}

if(is_array($variants))foreach ($variants as $variant) {
$id=$variant->id;
if(!($sc[$id]>0))continue;

if($variant->infinity)
$_SESSION['shopping_cart'][$id]=$sc[$id]; 
elseif($sc[$id]<=$variant->stock)
$_SESSION['shopping_cart'][$id]=$sc[$id]; 
elseif($variant->stock>0)
$_SESSION['shopping_cart'][$id]=$variant->stock; 
}

}


2.2. in 2 places
after

// If the product exists, we will add it to the cart
if(!empty($variant) && ($variant->stock>0))
{
// We will not give more than in stock
$amount = min($amount, $variant->stock);

$_SESSION['shopping_cart'][$variant_id] = intval($amount);


paste

$this->cart_to_base();


2.3.
after

unset($_SESSION['shopping_cart'][$variant_id]);


paste

if(!isset($_COOKIE['shopping_cart_code'])){
$sid=session_id();
$_COOKIE['shopping_cart_code']=$sid;
setcookie("shopping_cart", $sid, time()+365*24*3600, '/');
$this->cart->base_to_cart($_COOKIE['shopping_cart_code']);
}











Information

Visitors who are in the group Guests they can't download files.
Log in to the site under your login and password or if you are a new user go through the process registrations on the website.

Comments:

This publication has no comments yet. You can be the first!

Information the publication:

  • Author of the publication: blackcms
  • Date of publication: 14 November 2022 12:52
  • Publication category(s): SimplaCMS script»,Modules SimplaCMS
  • Number of views of the publication: 919
  • Number of comments to the publication: 0

Related News

14 November 2022
SimplaCMS script»,Modules SimplaCMS
Automatic discount for

Automatic discount for all registered users

Read more
20 February 2022
Programming»,Databases
SQL programming language

SQL Programming language Wikipedia A declarative programming language used to create, modify, and manage data in a

Read more
13 March 2022
Information security»,Protection and hacking
PhoneSploit: Getting

PhoneSploit: Getting into an Android phone Let's start with the fact that all this software is on Linux, and it

Read more
11 November 2022
Web Templates»,HTML Templates website
Draining the Template

A template for watching anime, you can also redo it for movies, a website with a multi-functional interface in

Read more
14 November 2022
OpenCart script»,OpenCart modules
Discounts Pack 1.5.1.5 -

Discounts Pack is a discount package that combines several discount modules: volume, loyalty, category, discounts

Read more

Information

Users of 🆅🅸🆂🅸🆃🅾🆁 are not allowed to comment this publication.

Site Search

Site Menu


☑ Websites Scripts

Calendar

«    November 2024    »
MonTueWedThuFriSatSun
 123
45678910
11121314151617
18192021222324
252627282930 

Advertisement

Survey on the website

Evaluate the work of the site
 

Statistics

  • +4 Total articles 6747
  • +14 Comments 4083
  • +28 Users : 5818