Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Write cart data to db only if it has been changed
givanz9a5f9a776a36
diff --git a/system/cart/cart.php b/system/cart/cart.phpindex 29f1567..a1aae36 100755--- a/system/cart/cart.php+++ b/system/cart/cart.php@@ -68,6 +68,8 @@ class Cart {protected $total_items = 0;protected $controlCache = true;++ protected $hasChanges = false;use TaxTrait, ProductOptionTrait, CouponTrait, TotalTrait, DbTrait;@@ -393,8 +395,8 @@ class Cart {} else {$this->enableCache();}- //write is done by addTotal- //$this->write();++ $this->hasChanges = true;return $results;}@@ -614,4 +616,10 @@ class Cart {setcookie('cart', '1', 0, '/');}}++ public function __destruct() {+ if ($this->hasChanges) {+ $this->write();+ }+ }}diff --git a/system/cart/db-trait.php b/system/cart/db-trait.phpindex 79e246c..8042744 100644--- a/system/cart/db-trait.php+++ b/system/cart/db-trait.php@@ -111,6 +111,8 @@ trait DbTrait {$data['cart_id'] = $this->cart_id;$this->session->set($this->sessionKey, $data);++ $this->hasChanges = false;}public function empty() {