خطای افزونهMy commerce
Exceptionsyntax error, unexpected end of file - Line 136
فایل/home/rkcxsznd/modello.ir/content/plugins/mycommerce/class/MCE_Cart.php
  1. <?php
    
  2. /**
    
  3.  * @Description : This section advances the shopping cart process
    
  4.  * @Author : Salar izadi
    
  5.  */
    
  6. final class MCE_Cart {
    
  7.     public string $table = "mce_cart";
    
  8.     /**
    
  9.      * @return void
    
  10.      * @throws Exception
    
  11.      */
    
  12.     public function init () {
    
  13.         $this->ipToMember();
    
  14.     }
    
  15.     /**
    
  16.      * @param array $where
    
  17.      * @return false|mixed
    
  18.      * @throws ReflectionException
    
  19.      * @throws Exception
    
  20.      */
    
  21.     public function get (array $where = []) {
    
  22.         global $ufo, $db;
    
  23.         $safe_where = [];
    
  24.         foreach ($db->columns($this->table, [], false) as $column) {
    
  25.             if (isset($where[$column]))
    
  26.                 $safe_where[$column] = $where[$column];
    
  27.         }
    
  28.         if (isset($safe_where["attributes"])) {
    
  29.             $attributes = $safe_where["attributes"];
    
  30.             unset($safe_where["attributes"]);
    
  31.         }
    
  32.         $member = $ufo->get_member()["uid"] ?? false;
    
  33.         $safe_where = $ufo->default([
    
  34.             ($member ? "mid" : "ip") => $member["uid"] ?? $ufo->viewer_ip()
    
  35.         ], $safe_where);
    
  36.         if (!empty($attributes)) {
    
  37.             if ($ufo->is_json($attributes)) {
    
  38.                 $safe_where['attributes'] = $attributes;
    
  39.             }
    
  40.         }
    
  41.         $rows = $db->get($this->table, $safe_where);
    
  42.         if (!isset($where["id"]) && !empty($attributes) && is_array($attributes)) {
    
  43.             $row = false;
    
  44.             foreach ($rows as &$item) {
    
  45.                 if ($ufo->is_json($item["attributes"], $item["attributes"])) {
    
  46.                     foreach ($attributes as $key => $property) {
    
  47.                         if (isset($item["attributes"][$key])) {
    
  48.                             if ($ufo->equal($item["attributes"][$key], $property)) {
    
  49.                                 $row = $item;
    
  50.                                 break 2;
    
  51.                             }
    
  52.                         }
    
  53.                     }
    
  54.                 }
    
  55.             }
    
  56.             $rows = $row;
    
  57.         }
    
  58.         return $rows[0] ?? $rows;
    
  59.     }
    
  60.     /**
    
  61.      * @param int|string $list
    
  62.      * @return array
    
  63.      * @throws Exception
    
  64.      */
    
  65.     public function list ($list = 0): array {
    
  66.         global $ufo, $db;
    
  67.         // Prevent printing of (exerts) or (works)
    
  68.         ob_start(); ob_clean();
    
  69.         $where = [
    
  70.             "list" => $list
    
  71.         ];
    
  72.         if ($ufo->check_login_member())
    
  73.             $where["mid"] = $ufo->get_member()["uid"];
    
  74.         else
    
  75.             $where["ip"] = $ufo->viewer_ip();
    
  76.         $products = new MCE_Products();
    
  77.         $rows     = $db->get("mce_cart", $where);
    
  78.         $carts    = [];
    
  79.         $count    = 0;
    
  80.         foreach ($rows as $k => &$item) {
    
  81.             $product = $products->get((int) $item["product"]);
    
  82.             $remove  = false;
    
  83.             $ufo->is_json($item["attributes"], $item["attributes"]);
    
  84.             $color = $item["attributes"]["color"] ?? 0;
    
  85.             if ($product) {
    
  86.                 if ($product["inventory"] > 0 || ($product["type"] == 1 && $product["inventory"] == -1)) {
    
  87.                     /** Get color */
    
  88.                     if ($color != 0) {
    
  89.                         foreach ($product["colors"] as $kc => $vc) {
    
  90.                             if ($color == $vc["id"]) {
    
  91.                                 if ($vc["inv"] < $item["count"])
    
  92.                                     $remove = true;
    
  93.                                 else {
    
  94.                                     $product["color"] = array_merge(
    
  95.                                         $vc, $products->get_color($vc["id"])
    
  96.                                     );
    
  97.                                     $product["inventory"] = $vc["inv"];
    
  98.                                 }
    
  99.                                 break;
    
  100.                             }
    
  101.                         }
    
  102.                     }
    
  103.                     /** Attributes **/
    
  104.                     $product["product_attrs"] = $product["attributes"];
    
  105.                     $product["attributes"] = $item["attributes"];
    
  106.                     $product["readable_attrs"] = [];
    
  107.                     foreach ($product["attributes"] as $key => &$attr) {
    
  108.