Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Payment and shipping status to orders. Address and orders list to user page.

givanzfb7c057a89ec
diff --git a/admin/component/order.php b/admin/component/order.php
new file mode 100644
index 0000000..9a705db
--- /dev/null
+++ b/admin/component/order.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+include DIR_ROOT . 'app' . DS . 'component' . DS . 'order.php';
diff --git a/admin/component/orders.php b/admin/component/orders.php
index a40e0d2..b574353 100755
--- a/admin/component/orders.php
+++ b/admin/component/orders.php
@@ -22,6 +22,7 @@
namespace Vvveb\Component;
+use Vvveb\System\Cart\Currency;
use Vvveb\System\Component\ComponentBase;
use Vvveb\System\Event;
use Vvveb\System\Images;
@@ -48,17 +49,23 @@ class Orders extends ComponentBase {
$results = $orders->getAll($this->options);
- foreach ($results['order'] as $id => &$order) {
- if (isset($order['images'])) {
- $order['images'] = json_decode($order['images'], 1);
+ if ($results['order']) {
+ $currency = Currency::getInstance();
- foreach ($order['images'] as &$image) {
- $image = Images::image('order', $image);
+ foreach ($results['order'] as $id => &$order) {
+ if (isset($order['images'])) {
+ $order['images'] = json_decode($order['images'], 1);
+
+ foreach ($order['images'] as &$image) {
+ $image = Images::image('order', $image);
+ }
+ }
+
+ if (isset($order['image'])) {
+ $order['images'][] = Images::image('order', $order['image']);
}
- }
- if (isset($order['image'])) {
- $order['images'][] = Images::image('order', $order['image']);
+ $order['total_formatted'] = $currency->format($order['total']);
}
}
diff --git a/admin/component/user/address.php b/admin/component/user/address.php
new file mode 100644
index 0000000..cc0555f
--- /dev/null
+++ b/admin/component/user/address.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+include DIR_ROOT . 'app' . DS . 'component' . DS . 'user' . DS . 'address.php';
diff --git a/admin/component/user/wishlist.php b/admin/component/user/wishlist.php
new file mode 100644
index 0000000..133f00c
--- /dev/null
+++ b/admin/component/user/wishlist.php
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Component\User;
+
+use Vvveb\Sql\User_WishlistSQL;
+use Vvveb\System\Component\ComponentBase;
+use Vvveb\System\Event;
+use function Vvveb\url;
+
+class Wishlist extends ComponentBase {
+ public static $defaultOptions = [
+ 'start' => 0,
+ 'limit' => 10,
+ ];
+
+ //don't cache
+ function cacheKey() {
+ return false;
+ }
+
+ function results() {
+ $results = [];
+
+ if ($this->options['user_id']) {
+ $wishlist = new User_WishlistSQL();
+ $results = $wishlist->getAll($this->options);
+
+ if ($results && isset($results['wishlist'])) {
+ foreach ($results['wishlist'] as $id => &$wishlist) {
+ $wishlist['url'] = url('user/wishlist/edit', $wishlist);
+ $wishlist['delete-url'] = url('user/wishlist/delete', $wishlist);
+ }
+ }
+ }
+
+ list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
+
+ return $results;
+ }
+
+ //called on each request
+ function request($results, $index = 0) {
+ }
+}
diff --git a/admin/controller/order/order.php b/admin/controller/order/order.php
index 77ba9cb..db804a9 100755
--- a/admin/controller/order/order.php
+++ b/admin/controller/order/order.php
@@ -23,6 +23,7 @@
namespace Vvveb\Controller\Order;
use function Vvveb\__;
+use function Vvveb\email;
use Vvveb\Controller\Base;
use Vvveb\Controller\Content\AutocompleteTrait;
use function Vvveb\orderStatusBadgeClass;
@@ -112,7 +113,7 @@ class Order extends Base {
$order += prefixArrayKeys('shipping_', $order['shipping_data']) ?? [];
$order += prefixArrayKeys('payment_', $order['payment_data']) ?? [];
- $data = $orders->getData($order);
+ $data = $orders->getData($order);
$view->set($data);
$view->set($results);
@@ -158,7 +159,7 @@ class Order extends Base {
$site = siteSettings($this->global['site_id']);
$options = $this->global + $site;
unset($options['admin_id']);
-
+
$order = new OrderCart($order_id, $options);
$order->add($product_id, false, $quantity, []);
$order->updateCart();
@@ -168,10 +169,31 @@ class Order extends Base {
$this->index();
}
+ private function sendNotification($order_id, $email, $message) {
+ try {
+ $error = __('Error sending order confirmation mail!');
+
+ if (! email([$email], sprintf(__('Order update #%s'), $order_id), 'order/update', ['message' => $message])) {
+ $this->session->set('errors', $error);
+ $this->view->errors[] = $error;
+ }
+ } catch (\Exception $e) {
+ if (DEBUG) {
+ $error .= "\n" . $e->getMessage();
+ }
+ $this->session->set('errors', $error);
+ $this->view->errors[] = $error;
+ }
+ }
+
function saveLog() {
$order_id = $this->request->get['order_id'] ?? false;
$log = $this->request->post['log'] ?? [];
+ $notify = $log['notify'] ?? false;
+ $public = $log['public'] ?? false;
$view = $this->view;
+
+ $this->index();
if ($order_id && $log) {
// update order status with the last log status
@@ -184,15 +206,26 @@ class Order extends Base {
if (isset($result['order_log']) && $result['order_log']) {
$view->success = [__('Order status saved!')];
+
+ $this->view->log[] = $log;
+
+ if ($notify) {
+ $message = '';
+ if ($public) {
+ $message = $log['note'];
+ }
+
+ $email = $this->view->order['email'];
+ $this->sendNotification($order_id, $email, $message);
+ }
+
} else {
- $view->errors = [$orderLog->error];
+ $view->errors[] = $orderLog->error;
}
} else {
- $view->errors = [$order->error];
+ $view->errors[] = $order->error;
}
}
-
- return $this->index();
}
function save() {
diff --git a/admin/controller/settings/payment-status.php b/admin/controller/settings/payment-status.php
new file mode 100644
index 0000000..63580d4
--- /dev/null
+++ b/admin/controller/settings/payment-status.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller\Settings;
+
+use Vvveb\Controller\Crud;
+
+class PaymentStatus extends Crud {
+ protected $type = 'payment_status';
+
+ protected $controller = 'payment-status';
+
+ protected $module = 'settings';
+}
diff --git a/admin/controller/settings/payment-statuses.php b/admin/controller/settings/payment-statuses.php
new file mode 100644
index 0000000..130631b
--- /dev/null
+++ b/admin/controller/settings/payment-statuses.php
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller\Settings;
+
+use Vvveb\Controller\Listing;
+
+class PaymentStatuses extends Listing {
+ protected $type = 'payment_status';
+
+ protected $controller = 'payment-status';
+
+ protected $listController = 'payment-statuses';
+
+ protected $list = 'payment_status';
+
+ protected $module = 'settings';
+}
diff --git a/admin/controller/settings/shipping-status.php b/admin/controller/settings/shipping-status.php
new file mode 100644
index 0000000..8fdf76d
--- /dev/null
+++ b/admin/controller/settings/shipping-status.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller\Settings;
+
+use Vvveb\Controller\Crud;
+
+class ShippingStatus extends Crud {
+ protected $type = 'shipping_status';
+
+ protected $controller = 'shipping-status';
+
+ protected $module = 'settings';
+}
diff --git a/admin/controller/settings/shipping-statuses.php b/admin/controller/settings/shipping-statuses.php
new file mode 100644
index 0000000..51225f2
--- /dev/null
+++ b/admin/controller/settings/shipping-statuses.php
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller\Settings;
+
+use Vvveb\Controller\Listing;
+
+class ShippingStatuses extends Listing {
+ protected $type = 'shipping_status';
+
+ protected $controller = 'shipping-status';
+
+ protected $listController = 'shipping-statuses';
+
+ protected $list = 'shipping_status';
+
+ protected $module = 'settings';
+}
diff --git a/admin/sql/mysqli/attribute.sql b/admin/sql/mysqli/attribute.sql
index e1b3730..14a35f2 100755
--- a/admin/sql/mysqli/attribute.sql
+++ b/admin/sql/mysqli/attribute.sql
@@ -4,7 +4,7 @@
PROCEDURE getAll(
IN language_id INT,
- IN product_id INT,
+ IN product_id ARRAY,
IN attribute_group_id INT,
IN start INT,
IN limit INT,
@@ -13,7 +13,7 @@
)
BEGIN
-- attribute
- SELECT attribute_content.name, attribute_group_content.name as `group`, attribute.*
+ SELECT attribute_content.name, attribute_group_content.name as `group`, attribute.*, pa.product_id
@IF isset(:product_id)
THEN
,pa.value
@@ -34,7 +34,7 @@
@IF isset(:product_id)
THEN
- AND pa.product_id = :product_id
+ AND pa.product_id IN (:product_id)
END @IF
@IF isset(:attribute_group_id)
diff --git a/admin/sql/mysqli/comment.sql b/admin/sql/mysqli/comment.sql
index e3f3b71..e4f62a5 100755
--- a/admin/sql/mysqli/comment.sql
+++ b/admin/sql/mysqli/comment.sql
@@ -23,10 +23,10 @@
)
BEGIN
- SELECT user.*, comment.*, comment_id as array_key
+ SELECT user.username, user.first_name, user.last_name, user.display_name, user.avatar, user.bio, user.subscribe, comment.*, comment_id as array_key
@IF isset(:post_title) AND :post_title
THEN
- ,post_content.name
+ ,post_content.name, post_content.slug
END @IF
FROM comment AS comment
@@ -95,6 +95,7 @@
SELECT *
FROM comment AS _
+ LEFT JOIN user ON user.user_id = _.user_id
WHERE 1 = 1
@IF isset(:comment_id)
diff --git a/admin/sql/mysqli/digital_asset.sql b/admin/sql/mysqli/digital_asset.sql
index 6b0b0d0..ea84ad8 100755
--- a/admin/sql/mysqli/digital_asset.sql
+++ b/admin/sql/mysqli/digital_asset.sql
@@ -4,6 +4,8 @@
PROCEDURE getAll(
IN language_id INT,
+ IN user_id INT,
+ IN order_status_id INT,
IN start INT,
IN limit INT,
OUT fetch_all,
@@ -15,7 +17,15 @@
FROM digital_asset AS digital_asset
INNER JOIN digital_asset_content ON digital_asset_content.digital_asset_id = digital_asset.digital_asset_id
AND digital_asset_content.language_id = :language_id
-
+
+ -- user_id
+ @IF isset(:user_id)
+ THEN
+ INNER JOIN product_to_digital_asset ptda ON ptda.digital_asset_id = digital_asset.digital_asset_id
+ INNER JOIN order_product op ON op.product_id = ptda.product_id
+ INNER JOIN `order` o ON o.order_id = op.order_id AND o.user_id = :user_id AND o.order_status_id = :order_status_id
+ END @IF
+
WHERE 1 = 1
-- limit
@@ -36,6 +46,7 @@
PROCEDURE get(
IN digital_asset_id INT,
+ IN user_id INT,
IN language_id INT,
OUT fetch_row,
)
@@ -53,6 +64,7 @@
PROCEDURE add(
IN digital_asset ARRAY,
+ OUT insert_id,
OUT insert_id
)
BEGIN
diff --git a/admin/sql/mysqli/order.sql b/admin/sql/mysqli/order.sql
index c4b334c..148e9b2 100755
--- a/admin/sql/mysqli/order.sql
+++ b/admin/sql/mysqli/order.sql
@@ -10,6 +10,13 @@
IN order_status CHAR,
IN order_status_id INT,
+
+ IN payment_status CHAR,
+ IN payment_status_id INT,
+
+ IN shipping_status CHAR,
+ IN shipping_status_id INT,
+
IN email CHAR,
IN phone_number CHAR,
IN search CHAR,
@@ -28,6 +35,8 @@
SELECT `order`.*,os.name as order_status FROM `order` AS `order`
LEFT JOIN order_status AS os ON (`order`.order_status_id = os.order_status_id AND os.language_id = :language_id)
+ LEFT JOIN shipping_status AS oss ON (`order`.shipping_status_id = oss.shipping_status_id AND oss.language_id = :language_id)
+ LEFT JOIN payment_status AS ops ON (`order`.order_status_id = ops.payment_status_id AND os.language_id = :language_id)
WHERE 1 = 1
@@ -41,11 +50,31 @@
@IF isset(:order_status)
THEN
AND os.name = :order_status
- END @IF
-
+ END @IF
+
@IF isset(:order_status_id)
THEN
AND `order`.order_status_id = :order_status_id
+ END @IF
+
+ @IF isset(:shipping_status)
+ THEN
+ AND oss.name = :shipping_status
+ END @IF
+
+ @IF isset(:shipping_status_id)
+ THEN
+ AND `order`.shipping_status_id = :shipping_status_id
+ END @IF
+
+ @IF isset(:payment_status)
+ THEN
+ AND ops.name = :payment_status
+ END @IF
+
+ @IF isset(:payment_status_id)
+ THEN
+ AND `order`.payment_status_id = :payment_status_id
END @IF
@IF isset(:email) AND !empty(:email)
@@ -56,7 +85,7 @@
@IF isset(:phone_number) AND !empty(:phone_number)
THEN
AND `order`.phone_number = :phone_number
- END @IF
+ END @IF
-- search
@IF isset(:search) AND !empty(:search)
@@ -83,6 +112,7 @@
IN order_id INT,
IN customer_order_id CHAR,
IN user_id INT,
+ IN email CHAR,
IN language_id INT,
OUT fetch_row,
OUT fetch_all,
@@ -98,6 +128,8 @@
-- order
SELECT `order`.*,
os.name as order_status,
+ ops.name as payment_status,
+ oss.name as shipping_status,
bc.name as billing_country,
sc.name as shipping_country,
br.name as billing_region,
@@ -106,6 +138,8 @@
FROM `order`
LEFT JOIN order_status AS os ON (`order`.order_status_id = os.order_status_id AND os.language_id = :language_id)
+ LEFT JOIN payment_status AS ops ON (`order`.payment_status_id = ops.payment_status_id AND os.language_id = :language_id)
+ LEFT JOIN shipping_status AS oss ON (`order`.shipping_status_id = oss.shipping_status_id AND os.language_id = :language_id)
-- country
LEFT JOIN country AS bc ON (`order`.billing_country_id = bc.country_id)
LEFT JOIN country AS sc ON (`order`.shipping_country_id = sc.country_id)
@@ -128,6 +162,11 @@
@IF isset(:customer_order_id)
THEN
AND `order`.customer_order_id = :customer_order_id
+ END @IF
+
+ @IF isset(:email)
+ THEN
+ AND `order`.email = :email
END @IF
LIMIT 1;
@@ -151,31 +190,31 @@
AND product_content.language_id = :language_id
END @IF
-
- WHERE products.order_id = :order_id;
+ -- use @result.order.order_id instead of :order_id to work when :customer_order_id is used
+ WHERE products.order_id = @result.order.order_id;
-- log
SELECT *,os.name as order_status
FROM order_log as log
LEFT JOIN order_status AS os ON (log.order_status_id = os.order_status_id AND os.language_id = :language_id)
- WHERE log.order_id = :order_id;
+ WHERE log.order_id = @result.order.order_id;
-- meta
SELECT * FROM order_meta as meta
- WHERE meta.order_id = :order_id;
-
+ WHERE meta.order_id = @result.order.order_id;
+
-- total
SELECT * FROM order_total as total
- WHERE total.order_id = :order_id;
+ WHERE total.order_id = @result.order.order_id;
-- shipment
SELECT * FROM order_shipment as shipment
- WHERE shipment.order_id = :order_id;
+ WHERE shipment.order_id = @result.order.order_id;
-- voucher
SELECT * FROM order_voucher as voucher
- WHERE voucher.order_id = :order_id;
-
+ WHERE voucher.order_id = @result.order.order_id;
+
END
@@ -199,7 +238,23 @@
order_status_id as array_key, -- order_id as key
name as array_value -- only set name as value and return
- FROM order_status as order_status_id WHERE language_id = :language_id;
+ FROM order_status as order_status_id WHERE language_id = :language_id;
+
+ -- payment status
+ SELECT
+
+ payment_status_id as array_key, -- order_id as key
+ name as array_value -- only set name as value and return
+
+ FROM payment_status as payment_status_id WHERE language_id = :language_id;
+
+ -- shipping status
+ SELECT
+
+ shipping_status_id as array_key, -- order_id as key
+ name as array_value -- only set name as value and return
+
+ FROM shipping_status as shipping_status_id WHERE language_id = :language_id;
-- billing_country
SELECT
diff --git a/admin/sql/mysqli/order_status.sql b/admin/sql/mysqli/order_status.sql
index ffa3dc9..1f1d93d 100755
--- a/admin/sql/mysqli/order_status.sql
+++ b/admin/sql/mysqli/order_status.sql
@@ -1,6 +1,6 @@
--- Currencies
+-- Order status
- -- get all order status
+ -- get all order statuses
PROCEDURE getAll(
IN language_id INT,
@@ -10,7 +10,6 @@
OUT fetch_one,
)
BEGIN
- -- order_status
SELECT *
FROM order_status AS order_status WHERE 1 = 1
@@ -91,4 +90,4 @@
BEGIN
-- order_status
DELETE FROM order_status WHERE order_status_id IN (:order_status_id);
- END
\ No newline at end of file
+ END
diff --git a/admin/sql/mysqli/payment_status.sql b/admin/sql/mysqli/payment_status.sql
new file mode 100644
index 0000000..98449b5
--- /dev/null
+++ b/admin/sql/mysqli/payment_status.sql
@@ -0,0 +1,94 @@
+-- Payment statuses
+
+ -- get all payment statuses
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+
+ SELECT *
+ FROM payment_status AS payment_status WHERE 1 = 1
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(payment_status.payment_status_id, payment_status) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get payment_status
+
+ PROCEDURE get(
+ IN payment_status_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- payment_status
+ SELECT *
+ FROM payment_status as _ WHERE payment_status_id = :payment_status_id;
+ END
+
+ -- add payment_status
+
+ PROCEDURE add(
+ IN payment_status ARRAY,
+ IN language_id INT,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :payment_status_data = @FILTER(:payment_status, payment_status)
+
+
+ INSERT INTO payment_status
+
+ ( @KEYS(:payment_status_data), language_id )
+
+ VALUES ( :payment_status_data, :language_id );
+
+ END
+
+ -- edit payment_status
+ CREATE PROCEDURE edit(
+ IN payment_status ARRAY,
+ IN payment_status_id INT,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ @FILTER(:payment_status, payment_status)
+
+ UPDATE payment_status
+
+ SET @LIST(:payment_status)
+
+ WHERE payment_status_id = :payment_status_id
+
+
+ END
+
+ -- delete payment_status
+
+ PROCEDURE delete(
+ IN payment_status_id ARRAY,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- payment_status
+ DELETE FROM payment_status WHERE payment_status_id IN (:payment_status_id);
+ END
diff --git a/admin/sql/mysqli/product_question.sql b/admin/sql/mysqli/product_question.sql
index a2d2af4..7181f81 100755
--- a/admin/sql/mysqli/product_question.sql
+++ b/admin/sql/mysqli/product_question.sql
@@ -18,7 +18,7 @@
)
BEGIN
- SELECT user.*,product_question.*,user.user_id as user_id
+ SELECT user.username, user.first_name, user.last_name, user.display_name, user.avatar, user.bio, user.subscribe, product_question.*,user.user_id as user_id
FROM product_question AS product_question
LEFT JOIN user on user.user_id = product_question.user_id
@@ -30,31 +30,31 @@
AND product_question.product_id = :product_id
END @IF
- -- product slug
+ -- product slug
@IF isset(:slug)
- THEN
+ THEN
AND product_question.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
END @IF
-- user
@IF isset(:user_id)
- THEN
+ THEN
AND product_question.user_id = :user_id
END @IF
- -- user
+ -- user
@IF isset(:status)
- THEN
+ THEN
AND product_question.status = :status
- END @IF
+ END @IF
- @SQL_LIMIT(:start, :limit);
+ @SQL_LIMIT(:start, :limit);
- SELECT count(*) FROM (
+ SELECT count(*) FROM (
@SQL_COUNT(product_question.product_question_id, product_question) -- this takes previous query removes limit and replaces select columns with parameter product_id
- ) as count;
+ ) as count;
END
@@ -69,7 +69,7 @@
-- question
SELECT *
FROM product_question as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN user on user.user_id = _.user_id
+ LEFT JOIN user on user.user_id = _.user_id
WHERE product_question_id = :product_question_id LIMIT 1;
END
diff --git a/admin/sql/mysqli/product_review.sql b/admin/sql/mysqli/product_review.sql
index 6fcde84..1896497 100755
--- a/admin/sql/mysqli/product_review.sql
+++ b/admin/sql/mysqli/product_review.sql
@@ -20,7 +20,7 @@
)
BEGIN
- SELECT user.*,product_review.*,user.user_id as user_id,
+ SELECT user.username, user.first_name, user.last_name, user.display_name, user.avatar, user.bio, user.subscribe, product_review.*,user.user_id as user_id,
-- (SELECT CONCAT('[', GROUP_CONCAT('{"id":"', prm.product_review_media_id, '","image":"' , prm.image, '"}'), ']')
(SELECT JSON_ARRAYAGG( JSON_OBJECT('id', prm.product_review_media_id, 'image', prm.image) )
FROM product_review_media as prm
@@ -29,25 +29,25 @@
FROM product_review
LEFT JOIN user ON user.user_id = product_review.user_id
- WHERE 1 = 1
+ WHERE 1 = 1
-- product
@IF isset(:product_id)
- THEN
+ THEN
AND product_review.product_id = :product_id
- END @IF
+ END @IF
-- product slug
@IF isset(:slug)
- THEN
- AND product_review.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
- END @IF
+ THEN
+ AND product_review.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
+ END @IF
-- user
@IF isset(:user_id)
- THEN
+ THEN
AND product_review.user_id = :user_id
- END @IF
+ END @IF
-- status
@IF isset(:status)
@@ -76,7 +76,7 @@
-- review
SELECT *
FROM product_review as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN user on user.user_id = _.user_id
+ LEFT JOIN user on user.user_id = _.user_id
WHERE product_review_id = :product_review_id LIMIT 1;
END
diff --git a/admin/sql/mysqli/shipping_status.sql b/admin/sql/mysqli/shipping_status.sql
new file mode 100644
index 0000000..d9ed4c9
--- /dev/null
+++ b/admin/sql/mysqli/shipping_status.sql
@@ -0,0 +1,94 @@
+-- Shipping statuses
+
+ -- get all shipping statuses
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+
+ SELECT *
+ FROM shipping_status AS shipping_status WHERE 1 = 1
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(shipping_status.shipping_status_id, shipping_status) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get shipping_status
+
+ PROCEDURE get(
+ IN shipping_status_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- shipping_status
+ SELECT *
+ FROM shipping_status as _ WHERE shipping_status_id = :shipping_status_id;
+ END
+
+ -- add shipping_status
+
+ PROCEDURE add(
+ IN shipping_status ARRAY,
+ IN language_id INT,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :shipping_status_data = @FILTER(:shipping_status, shipping_status)
+
+
+ INSERT INTO shipping_status
+
+ ( @KEYS(:shipping_status_data), language_id )
+
+ VALUES ( :shipping_status_data, :language_id );
+
+ END
+
+ -- edit shipping_status
+ CREATE PROCEDURE edit(
+ IN shipping_status ARRAY,
+ IN shipping_status_id INT,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ @FILTER(:shipping_status, shipping_status)
+
+ UPDATE shipping_status
+
+ SET @LIST(:shipping_status)
+
+ WHERE shipping_status_id = :shipping_status_id
+
+
+ END
+
+ -- delete shipping_status
+
+ PROCEDURE delete(
+ IN shipping_status_id ARRAY,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- shipping_status
+ DELETE FROM shipping_status WHERE shipping_status_id IN (:shipping_status_id);
+ END
diff --git a/admin/sql/mysqli/user_address.sql b/admin/sql/mysqli/user_address.sql
index fb26c1f..783d572 100755
--- a/admin/sql/mysqli/user_address.sql
+++ b/admin/sql/mysqli/user_address.sql
@@ -1,4 +1,4 @@
--- Addresss
+-- Address
-- get all user addresses
@@ -43,6 +43,7 @@
CREATE PROCEDURE get(
IN user_address_id INT,
+ IN user_id INT,
OUT fetch_row,
)
BEGIN
@@ -51,11 +52,17 @@
FROM user_address AS _
WHERE 1 = 1
- @IF isset(:user_address_id)
- THEN
- AND _.user_address_id = :user_address_id
+ @IF isset(:user_address_id)
+ THEN
+ AND _.user_address_id = :user_address_id
END @IF
+ -- user
+ @IF isset(:user_id)
+ THEN
+ AND _.user_id = :user_id
+ END @IF
+
LIMIT 1;
diff --git a/admin/sql/mysqli/user_wishlist.sql b/admin/sql/mysqli/user_wishlist.sql
index 689547b..d05d4a8 100644
--- a/admin/sql/mysqli/user_wishlist.sql
+++ b/admin/sql/mysqli/user_wishlist.sql
@@ -17,9 +17,10 @@
)
BEGIN
- SELECT *
+ SELECT p.*, user_wishlist.*, pc.name, pc.slug
FROM user_wishlist
+ INNER JOIN product p ON p.product_id = user_wishlist.product_id
INNER JOIN product_content pc ON pc.product_id = user_wishlist.product_id AND pc.language_id = :language_id
WHERE user_wishlist.user_id = :user_id
@@ -56,19 +57,27 @@
-- Add new product to wishlist
CREATE PROCEDURE add(
- IN user_wishlist ARRAY,
+ -- IN user_wishlist ARRAY,
+ IN product_id INT,
+ IN user_id INT,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_wishlist, user_wishlist)
+ -- @FILTER(:user_wishlist, user_wishlist)
+
+ -- INSERT INTO user_wishlist
+
+ -- ( @KEYS(:user_wishlist) )
+
+ -- VALUES ( :user_wishlist )
- INSERT INTO user_wishlist
+ INSERT IGNORE INTO user_wishlist
- ( @KEYS(:user_wishlist) )
+ ( `user_id`, `product_id` )
- VALUES ( :user_wishlist )
+ VALUES ( :user_id, :product_id )
END
diff --git a/admin/sql/pgsql/admin.sql b/admin/sql/pgsql/admin.sql
index 22661fd..76b3337 100755
--- a/admin/sql/pgsql/admin.sql
+++ b/admin/sql/pgsql/admin.sql
@@ -76,35 +76,35 @@
WHERE 1 = 1
- @IF isset(:username)
- THEN
- AND _.username = :username
- END @IF
+ @IF isset(:username)
+ THEN
+ AND _.username = :username
+ END @IF
- @IF isset(:email)
- THEN
- AND _.email = :email
- END @IF
+ @IF isset(:email)
+ THEN
+ AND _.email = :email
+ END @IF
- @IF isset(:admin_id)
+ @IF isset(:admin_id)
THEN
AND _.admin_id = :admin_id
- END @IF
+ END @IF
- @IF isset(:status)
+ @IF isset(:status)
THEN
AND _.status = :status
- END @IF
-
+ END @IF
+
@IF isset(:token)
THEN
AND _.token = :token
- END @IF
-
- @IF isset(:role_id)
+ END @IF
+
+ @IF isset(:role_id)
THEN
AND _.role_id = :role_id
- END @IF
+ END @IF
LIMIT 1;
diff --git a/admin/sql/pgsql/attribute.sql b/admin/sql/pgsql/attribute.sql
index 6481c1f..ca1a455 100755
--- a/admin/sql/pgsql/attribute.sql
+++ b/admin/sql/pgsql/attribute.sql
@@ -4,7 +4,7 @@
PROCEDURE getAll(
IN language_id INT,
- IN product_id INT,
+ IN product_id ARRAY,
IN attribute_group_id INT,
IN start INT,
IN limit INT,
@@ -34,7 +34,7 @@
@IF isset(:product_id)
THEN
- AND pa.product_id = :product_id
+ AND pa.product_id IN (:product_id)
END @IF
@IF isset(:attribute_group_id)
diff --git a/admin/sql/pgsql/comment.sql b/admin/sql/pgsql/comment.sql
index f1c5f35..46fa2ec 100755
--- a/admin/sql/pgsql/comment.sql
+++ b/admin/sql/pgsql/comment.sql
@@ -23,11 +23,11 @@
)
BEGIN
- SELECT "user".*, comment.*, comment_id as array_key
+ SELECT user.username, user.first_name, user.last_name, user.display_name, user.avatar, user.bio, user.subscribe, comment.*, comment_id as array_key
@IF isset(:post_title) AND :post_title
THEN
- ,post_content.name
- END @IF
+ ,post_content.name, post_content.slug
+ END @IF
FROM comment AS comment
LEFT JOIN "user" ON (comment.user_id = comment.user_id)
@@ -95,6 +95,7 @@
SELECT *
FROM comment AS _
+ LEFT JOIN user ON user.user_id = _.user_id
WHERE 1 = 1
@IF isset(:comment_id)
diff --git a/admin/sql/pgsql/digital_asset.sql b/admin/sql/pgsql/digital_asset.sql
index f7bd7ac..4bb4db5 100755
--- a/admin/sql/pgsql/digital_asset.sql
+++ b/admin/sql/pgsql/digital_asset.sql
@@ -4,6 +4,8 @@
PROCEDURE getAll(
IN language_id INT,
+ IN user_id INT,
+ IN order_status_id INT,
IN start INT,
IN limit INT,
OUT fetch_all,
@@ -15,7 +17,15 @@
FROM digital_asset AS digital_asset
INNER JOIN digital_asset_content ON digital_asset_content.digital_asset_id = digital_asset.digital_asset_id
AND digital_asset_content.language_id = :language_id
-
+
+ -- user_id
+ @IF isset(:user_id)
+ THEN
+ INNER JOIN product_to_digital_asset ptda ON ptda.digital_asset_id = digital_asset.digital_asset_id
+ INNER JOIN order_product op ON op.product_id = ptda.product_id
+ INNER JOIN "order" o ON o.order_id = op.order_id AND o.user_id = :user_id AND o.order_status_id = :order_status_id
+ END @IF
+
WHERE 1 = 1
-- limit
@@ -36,6 +46,7 @@
PROCEDURE get(
IN digital_asset_id INT,
+ IN user_id INT,
IN language_id INT,
OUT fetch_row,
)
diff --git a/admin/sql/pgsql/order.sql b/admin/sql/pgsql/order.sql
index 3177d8d..40abddd 100755
--- a/admin/sql/pgsql/order.sql
+++ b/admin/sql/pgsql/order.sql
@@ -10,6 +10,13 @@
IN order_status CHAR,
IN order_status_id INT,
+
+ IN payment_status CHAR,
+ IN payment_status_id INT,
+
+ IN shipping_status CHAR,
+ IN shipping_status_id INT,
+
IN email CHAR,
IN phone_number CHAR,
IN search CHAR,
@@ -28,42 +35,44 @@
SELECT "order".*,os.name as order_status FROM "order" AS "order"
LEFT JOIN order_status AS os ON ("order".order_status_id = os.order_status_id AND os.language_id = :language_id)
+ LEFT JOIN shipping_status AS oss ON ("order".shipping_status_id = oss.shipping_status_id AND oss.language_id = :language_id)
+ LEFT JOIN payment_status AS ops ON ("order".order_status_id = ops.payment_status_id AND os.language_id = :language_id)
WHERE 1 = 1
+
+ AND "order".site_id = :site_id
- AND "order".site_id = :site_id
-
- @IF isset(:user_id)
- THEN
- AND "order".user_id = :user_id
- END @IF
-
- @IF isset(:order_status)
- THEN
- AND os.name = :order_status
- END @IF
+ @IF isset(:user_id)
+ THEN
+ AND "order".user_id = :user_id
+ END @IF
+
+ @IF isset(:order_status)
+ THEN
+ AND os.name = :order_status
+ END @IF
- @IF isset(:order_status_id)
- THEN
- AND "order".order_status_id = :order_status_id
- END @IF
+ @IF isset(:order_status_id)
+ THEN
+ AND "order".order_status_id = :order_status_id
+ END @IF
- @IF isset(:email) AND !empty(:email)
- THEN
- AND "order".email = :email
+ @IF isset(:email) AND !empty(:email)
+ THEN
+ AND "order".email = :email
END @IF
@IF isset(:phone_number) AND !empty(:phone_number)
THEN
AND "order".phone_number = :phone_number
- END @IF
-
- -- search
- @IF isset(:search) AND !empty(:search)
- THEN
- AND
- "order".first_name LIKE '%' || :search || '%' OR
- "order".last_name LIKE '%' || :search || '%'
+ END @IF
+
+ -- search
+ @IF isset(:search) AND !empty(:search)
+ THEN
+ AND
+ "order".first_name LIKE '%' || :search || '%' OR
+ "order".last_name LIKE '%' || :search || '%'
END @IF
ORDER BY order_id DESC
@@ -80,9 +89,10 @@
CREATE PROCEDURE get(
- IN order_id INT,
+ IN order_id INT,
IN customer_order_id CHAR,
IN user_id INT,
+ IN email CHAR,
IN language_id INT,
OUT fetch_row,
OUT fetch_all,
@@ -98,6 +108,8 @@
-- order
SELECT "order".*,
os.name as order_status,
+ ops.name as payment_status,
+ oss.name as shipping_status,
bc.name as billing_country,
sc.name as shipping_country,
br.name as billing_region,
@@ -106,6 +118,8 @@
FROM "order"
LEFT JOIN order_status AS os ON ("order".order_status_id = os.order_status_id AND os.language_id = :language_id)
+ LEFT JOIN payment_status AS ops ON ("order".payment_status_id = ops.payment_status_id AND os.language_id = :language_id)
+ LEFT JOIN shipping_status AS oss ON ("order".shipping_status_id = oss.shipping_status_id AND os.language_id = :language_id)
-- country
LEFT JOIN country AS bc ON ("order".billing_country_id = bc.country_id)
LEFT JOIN country AS sc ON ("order".shipping_country_id = sc.country_id)
@@ -128,6 +142,11 @@
@IF isset(:customer_order_id)
THEN
AND "order".customer_order_id = :customer_order_id
+ END @IF
+
+ @IF isset(:email)
+ THEN
+ AND "order".email = :email
END @IF
LIMIT 1;
@@ -150,31 +169,31 @@
AND product_content.language_id = :language_id
END @IF
-
- WHERE products.order_id = :order_id;
+ -- use @result.order.order_id instead of :order_id to work when :customer_order_id is used
+ WHERE products.order_id = @result.order.order_id;
-- log
SELECT *,os.name as order_status
FROM order_log as log
LEFT JOIN order_status AS os ON (log.order_status_id = os.order_status_id AND os.language_id = :language_id)
- WHERE log.order_id = :order_id;
-
+ WHERE log.order_id = @result.order.order_id;
+
-- meta
SELECT * FROM order_meta as meta
- WHERE meta.order_id = :order_id;
-
+ WHERE meta.order_id = @result.order.order_id;
+
-- total
SELECT * FROM order_total as total
- WHERE total.order_id = :order_id;
+ WHERE total.order_id = @result.order.order_id;
-- shipment
SELECT * FROM order_shipment as shipment
- WHERE shipment.order_id = :order_id;
+ WHERE shipment.order_id = @result.order.order_id;
-- voucher
SELECT * FROM order_voucher as voucher
- WHERE voucher.order_id = :order_id;
-
+ WHERE voucher.order_id = @result.order.order_id;
+
END
@@ -198,8 +217,24 @@
order_status_id as array_key, -- order_id as key
name as array_value -- only set name as value and return
- FROM order_status as order_status_id WHERE language_id = :language_id;
-
+ FROM order_status as order_status_id WHERE language_id = :language_id;
+
+ -- payment status
+ SELECT
+
+ payment_status_id as array_key, -- order_id as key
+ name as array_value -- only set name as value and return
+
+ FROM payment_status as payment_status_id WHERE language_id = :language_id;
+
+ -- shipping status
+ SELECT
+
+ shipping_status_id as array_key, -- order_id as key
+ name as array_value -- only set name as value and return
+
+ FROM shipping_status as shipping_status_id WHERE language_id = :language_id;
+
-- billing_country
SELECT
country_id as array_key, -- order_id as key
diff --git a/admin/sql/pgsql/order_status.sql b/admin/sql/pgsql/order_status.sql
index 5aedd4b..97eefd7 100755
--- a/admin/sql/pgsql/order_status.sql
+++ b/admin/sql/pgsql/order_status.sql
@@ -1,4 +1,4 @@
--- Currencies
+-- Order status
-- get all order status
@@ -10,7 +10,6 @@
OUT fetch_one,
)
BEGIN
- -- order_status
SELECT *
FROM order_status AS order_status WHERE 1 = 1
diff --git a/admin/sql/pgsql/payment_status.sql b/admin/sql/pgsql/payment_status.sql
new file mode 100644
index 0000000..20e5259
--- /dev/null
+++ b/admin/sql/pgsql/payment_status.sql
@@ -0,0 +1,93 @@
+-- Payment statuses
+
+ -- get all payment statuses
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ SELECT *
+ FROM payment_status AS payment_status WHERE 1 = 1
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(payment_status.payment_status_id, payment_status) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get payment_status
+
+ PROCEDURE get(
+ IN payment_status_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- payment_status
+ SELECT *
+ FROM payment_status as _ WHERE payment_status_id = :payment_status_id;
+ END
+
+ -- add payment_status
+
+ PROCEDURE add(
+ IN payment_status ARRAY,
+ IN language_id INT,
+ OUT fetch_one
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :payment_status_data = @FILTER(:payment_status, payment_status)
+
+
+ INSERT INTO payment_status
+
+ ( @KEYS(:payment_status_data), language_id )
+
+ VALUES ( :payment_status_data, :language_id ) RETURNING payment_status_id;
+
+ END
+
+ -- edit payment_status
+ CREATE PROCEDURE edit(
+ IN payment_status ARRAY,
+ IN payment_status_id INT,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ @FILTER(:payment_status, payment_status)
+
+ UPDATE payment_status
+
+ SET @LIST(:payment_status)
+
+ WHERE payment_status_id = :payment_status_id
+
+
+ END
+
+ -- delete payment_status
+
+ PROCEDURE delete(
+ IN payment_status_id ARRAY,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- payment_status
+ DELETE FROM payment_status WHERE payment_status_id IN (:payment_status_id);
+ END
diff --git a/admin/sql/pgsql/post_meta.sql b/admin/sql/pgsql/post_meta.sql
index b4386cd..ddc3655 100644
--- a/admin/sql/pgsql/post_meta.sql
+++ b/admin/sql/pgsql/post_meta.sql
@@ -11,8 +11,8 @@
)
BEGIN
- SELECT value
- FROM post_content_meta AS _
+ SELECT value
+ FROM post_content_meta AS _
WHERE _."key" = :key
@IF !empty(:post_id)
diff --git a/admin/sql/pgsql/product_question.sql b/admin/sql/pgsql/product_question.sql
index eb7876a..b298d83 100755
--- a/admin/sql/pgsql/product_question.sql
+++ b/admin/sql/pgsql/product_question.sql
@@ -18,9 +18,9 @@
)
BEGIN
- SELECT "user".*, product_question.*, "user".user_id as user_id
+ SELECT "user".username, "user".first_name, "user".last_name, "user".display_name, "user".avatar, "user".bio, "user".subscribe, product_question.*, "user".user_id as user_id
FROM product_question AS product_question
- LEFT JOIN "user" on "user".user_id = product_question.user_id
+ LEFT JOIN "user" on "user".user_id = product_question.user_id
WHERE 1 = 1
@@ -32,29 +32,29 @@
-- product slug
@IF isset(:slug)
- THEN
+ THEN
AND product_question.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
- END @IF
+ END @IF
-- user
@IF isset(:user_id)
- THEN
+ THEN
AND product_question.user_id = :user_id
- END @IF
+ END @IF
- -- user
+ -- user
@IF isset(:status)
- THEN
+ THEN
AND product_question.status = :status
- END @IF
+ END @IF
- @SQL_LIMIT(:start, :limit);
+ @SQL_LIMIT(:start, :limit);
- SELECT count(*) FROM (
+ SELECT count(*) FROM (
@SQL_COUNT(product_question.product_question_id, product_question) -- this takes previous query removes limit and replaces select columns with parameter product_id
- ) as count;
+ ) as count;
END
@@ -69,7 +69,7 @@
-- question
SELECT *
FROM product_question as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN "user" on "user".user_id = _.user_id
+ LEFT JOIN "user" on "user".user_id = _.user_id
WHERE product_question_id = :product_question_id LIMIT 1;
END
diff --git a/admin/sql/pgsql/product_review.sql b/admin/sql/pgsql/product_review.sql
index c4f9743..ce09ab8 100755
--- a/admin/sql/pgsql/product_review.sql
+++ b/admin/sql/pgsql/product_review.sql
@@ -20,33 +20,33 @@
)
BEGIN
- SELECT "user".*, product_review.*, "user".user_id as user_id,
+ SELECT "user".username, "user".first_name, "user".last_name, "user".display_name, "user".avatar, "user".bio, "user".subscribe, product_review.*, "user".user_id as user_id,
(SELECT json_agg(json_build_object('id',prm.product_review_media_id,'image',prm.image))
FROM product_review_media as prm
- WHERE prm.product_review_id = product_review.product_review_id) as images
+ WHERE prm.product_review_id = product_review.product_review_id GROUP BY prm.product_review_id) as images
FROM product_review
LEFT JOIN "user" ON "user".user_id = product_review.user_id
- WHERE 1 = 1
+ WHERE 1 = 1
-- product
@IF isset(:product_id)
- THEN
+ THEN
AND product_review.product_id = :product_id
- END @IF
+ END @IF
-- product slug
@IF isset(:slug)
- THEN
+ THEN
AND product_review.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
- END @IF
+ END @IF
-- user
@IF isset(:user_id)
- THEN
+ THEN
AND product_review.user_id = :user_id
- END @IF
+ END @IF
-- status
@IF isset(:status)
@@ -75,7 +75,7 @@
-- review
SELECT *
FROM product_review as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN "user" on "user".user_id = _.user_id
+ LEFT JOIN "user" on "user".user_id = _.user_id
WHERE product_review_id = :product_review_id LIMIT 1;
END
diff --git a/admin/sql/pgsql/shipping_status.sql b/admin/sql/pgsql/shipping_status.sql
new file mode 100644
index 0000000..1db6624
--- /dev/null
+++ b/admin/sql/pgsql/shipping_status.sql
@@ -0,0 +1,93 @@
+-- Shipping statuses
+
+ -- get all shipping statuses
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+ SELECT *
+ FROM shipping_status AS shipping_status WHERE 1 = 1
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(shipping_status.shipping_status_id, shipping_status) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get shipping_status
+
+ PROCEDURE get(
+ IN shipping_status_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- shipping_status
+ SELECT *
+ FROM shipping_status as _ WHERE shipping_status_id = :shipping_status_id;
+ END
+
+ -- add shipping_status
+
+ PROCEDURE add(
+ IN shipping_status ARRAY,
+ IN language_id INT,
+ OUT fetch_one
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :shipping_status_data = @FILTER(:shipping_status, shipping_status)
+
+
+ INSERT INTO shipping_status
+
+ ( @KEYS(:shipping_status_data), language_id )
+
+ VALUES ( :shipping_status_data, :language_id ) RETURNING shipping_status_id;
+
+ END
+
+ -- edit shipping_status
+ CREATE PROCEDURE edit(
+ IN shipping_status ARRAY,
+ IN shipping_status_id INT,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ @FILTER(:shipping_status, shipping_status)
+
+ UPDATE shipping_status
+
+ SET @LIST(:shipping_status)
+
+ WHERE shipping_status_id = :shipping_status_id
+
+
+ END
+
+ -- delete shipping_status
+
+ PROCEDURE delete(
+ IN shipping_status_id ARRAY,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- shipping_status
+ DELETE FROM shipping_status WHERE shipping_status_id IN (:shipping_status_id);
+ END
diff --git a/admin/sql/pgsql/user_address.sql b/admin/sql/pgsql/user_address.sql
index 1a83494..566c117 100755
--- a/admin/sql/pgsql/user_address.sql
+++ b/admin/sql/pgsql/user_address.sql
@@ -1,4 +1,4 @@
--- Addresss
+-- Address
-- get all user addresses
@@ -43,6 +43,7 @@
CREATE PROCEDURE get(
IN user_address_id INT,
+ IN user_id INT,
OUT fetch_row,
)
BEGIN
@@ -51,11 +52,17 @@
FROM user_address AS _
WHERE 1 = 1
- @IF isset(:user_address_id)
- THEN
- AND _.user_address_id = :user_address_id
+ @IF isset(:user_address_id)
+ THEN
+ AND _.user_address_id = :user_address_id
END @IF
+ -- user
+ @IF isset(:user_id)
+ THEN
+ AND _.user_id = :user_id
+ END @IF
+
LIMIT 1;
diff --git a/admin/sql/pgsql/user_wishlist.sql b/admin/sql/pgsql/user_wishlist.sql
index 689547b..c4634aa 100644
--- a/admin/sql/pgsql/user_wishlist.sql
+++ b/admin/sql/pgsql/user_wishlist.sql
@@ -17,9 +17,10 @@
)
BEGIN
- SELECT *
+ SELECT p.*, user_wishlist.*, pc.name, pc.slug
FROM user_wishlist
+ INNER JOIN product p ON p.product_id = user_wishlist.product_id
INNER JOIN product_content pc ON pc.product_id = user_wishlist.product_id AND pc.language_id = :language_id
WHERE user_wishlist.user_id = :user_id
@@ -56,19 +57,27 @@
-- Add new product to wishlist
CREATE PROCEDURE add(
- IN user_wishlist ARRAY,
+ -- IN user_wishlist ARRAY,
+ IN product_id INT,
+ IN user_id INT,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_wishlist, user_wishlist)
+ -- @FILTER(:user_wishlist, user_wishlist)
+
+ -- INSERT INTO user_wishlist
+
+ -- ( @KEYS(:user_wishlist) )
+
+ -- VALUES ( :user_wishlist )
- INSERT INTO user_wishlist
+ INSERT IGNORE INTO user_wishlist
- ( @KEYS(:user_wishlist) )
+ ( "user_id", "product_id" )
- VALUES ( :user_wishlist )
+ VALUES ( :user_id, :product_id )
END
diff --git a/admin/sql/sqlite/admin.sql b/admin/sql/sqlite/admin.sql
index 83d23c1..5a62b10 100755
--- a/admin/sql/sqlite/admin.sql
+++ b/admin/sql/sqlite/admin.sql
@@ -76,36 +76,36 @@
WHERE 1 = 1
- @IF isset(:username)
- THEN
- AND _.username = :username
- END @IF
+ @IF isset(:username)
+ THEN
+ AND _.username = :username
+ END @IF
- @IF isset(:email)
- THEN
- AND _.email = :email
- END @IF
+ @IF isset(:email)
+ THEN
+ AND _.email = :email
+ END @IF
- @IF isset(:admin_id)
+ @IF isset(:admin_id)
THEN
AND _.admin_id = :admin_id
- END @IF
+ END @IF
- @IF isset(:status)
+ @IF isset(:status)
THEN
AND _.status = :status
- END @IF
-
+ END @IF
+
@IF isset(:token)
THEN
AND _.token = :token
- END @IF
-
- @IF isset(:role_id)
+ END @IF
+
+ @IF isset(:role_id)
THEN
AND _.role_id = :role_id
- END @IF
-
+ END @IF
+
LIMIT 1;
END
diff --git a/admin/sql/sqlite/attribute.sql b/admin/sql/sqlite/attribute.sql
index f017c73..bee0bda 100755
--- a/admin/sql/sqlite/attribute.sql
+++ b/admin/sql/sqlite/attribute.sql
@@ -4,7 +4,7 @@
PROCEDURE getAll(
IN language_id INT,
- IN product_id INT,
+ IN product_id ARRAY,
IN attribute_group_id INT,
IN start INT,
IN limit INT,
@@ -34,7 +34,7 @@
@IF isset(:product_id)
THEN
- AND pa.product_id = :product_id
+ AND pa.product_id IN (:product_id)
END @IF
@IF isset(:attribute_group_id)
diff --git a/admin/sql/sqlite/comment.sql b/admin/sql/sqlite/comment.sql
index 116eb13..726f046 100755
--- a/admin/sql/sqlite/comment.sql
+++ b/admin/sql/sqlite/comment.sql
@@ -23,10 +23,10 @@
)
BEGIN
- SELECT user.*, comment.*, comment_id as array_key
+ SELECT user.username, user.first_name, user.last_name, user.display_name, user.avatar, user.bio, user.subscribe, comment.*, comment_id as array_key
@IF isset(:post_title) AND :post_title
THEN
- ,post_content.name
+ ,post_content.name, post_content.slug
END @IF
FROM comment AS comment
@@ -95,6 +95,7 @@
SELECT *
FROM comment AS _
+ LEFT JOIN user ON user.user_id = _.user_id
WHERE 1 = 1
@IF isset(:comment_id)
diff --git a/admin/sql/sqlite/digital_asset.sql b/admin/sql/sqlite/digital_asset.sql
index bba42e3..ce790aa 100755
--- a/admin/sql/sqlite/digital_asset.sql
+++ b/admin/sql/sqlite/digital_asset.sql
@@ -4,6 +4,8 @@
PROCEDURE getAll(
IN language_id INT,
+ IN user_id INT,
+ IN order_status_id INT,
IN start INT,
IN limit INT,
OUT fetch_all,
@@ -15,7 +17,15 @@
FROM digital_asset AS digital_asset
INNER JOIN digital_asset_content ON digital_asset_content.digital_asset_id = digital_asset.digital_asset_id
AND digital_asset_content.language_id = :language_id
-
+
+ -- user_id
+ @IF isset(:user_id)
+ THEN
+ INNER JOIN product_to_digital_asset ptda ON ptda.digital_asset_id = digital_asset.digital_asset_id
+ INNER JOIN order_product op ON op.product_id = ptda.product_id
+ INNER JOIN `order` o ON o.order_id = op.order_id AND o.user_id = :user_id AND o.order_status_id = :order_status_id
+ END @IF
+
WHERE 1 = 1
-- limit
@@ -36,6 +46,7 @@
PROCEDURE get(
IN digital_asset_id INT,
+ IN user_id INT,
IN language_id INT,
OUT fetch_row,
)
@@ -53,6 +64,7 @@
PROCEDURE add(
IN digital_asset ARRAY,
+ OUT insert_id,
OUT insert_id
)
BEGIN
diff --git a/admin/sql/sqlite/order.sql b/admin/sql/sqlite/order.sql
index 25e4af7..659857d 100755
--- a/admin/sql/sqlite/order.sql
+++ b/admin/sql/sqlite/order.sql
@@ -10,6 +10,13 @@
IN order_status CHAR,
IN order_status_id INT,
+
+ IN payment_status CHAR,
+ IN payment_status_id INT,
+
+ IN shipping_status CHAR,
+ IN shipping_status_id INT,
+
IN email CHAR,
IN phone_number CHAR,
IN search CHAR,
@@ -28,6 +35,8 @@
SELECT `order`.*,os.name as order_status FROM `order` AS `order`
LEFT JOIN order_status AS os ON (`order`.order_status_id = os.order_status_id AND os.language_id = :language_id)
+ LEFT JOIN shipping_status AS oss ON (`order`.shipping_status_id = oss.shipping_status_id AND oss.language_id = :language_id)
+ LEFT JOIN payment_status AS ops ON (`order`.order_status_id = ops.payment_status_id AND os.language_id = :language_id)
WHERE 1 = 1
@@ -41,11 +50,31 @@
@IF isset(:order_status)
THEN
AND os.name = :order_status
- END @IF
+ END @IF
@IF isset(:order_status_id)
THEN
AND `order`.order_status_id = :order_status_id
+ END @IF
+
+ @IF isset(:shipping_status)
+ THEN
+ AND oss.name = :shipping_status
+ END @IF
+
+ @IF isset(:shipping_status_id)
+ THEN
+ AND `order`.shipping_status_id = :shipping_status_id
+ END @IF
+
+ @IF isset(:payment_status)
+ THEN
+ AND ops.name = :payment_status
+ END @IF
+
+ @IF isset(:payment_status_id)
+ THEN
+ AND `order`.payment_status_id = :payment_status_id
END @IF
@IF isset(:email) AND !empty(:email)
@@ -56,7 +85,7 @@
@IF isset(:phone_number) AND !empty(:phone_number)
THEN
AND `order`.phone_number = :phone_number
- END @IF
+ END @IF
-- search
@IF isset(:search) AND !empty(:search)
@@ -80,9 +109,10 @@
CREATE PROCEDURE get(
- IN order_id INT,
+ IN order_id INT,
IN customer_order_id CHAR,
IN user_id INT,
+ IN email CHAR,
IN language_id INT,
OUT fetch_row,
OUT fetch_all,
@@ -98,6 +128,8 @@
-- order
SELECT `order`.*,
os.name as order_status,
+ ops.name as payment_status,
+ oss.name as shipping_status,
bc.name as billing_country,
sc.name as shipping_country,
br.name as billing_region,
@@ -106,6 +138,8 @@
FROM `order`
LEFT JOIN order_status AS os ON (`order`.order_status_id = os.order_status_id AND os.language_id = :language_id)
+ LEFT JOIN payment_status AS ops ON (`order`.payment_status_id = ops.payment_status_id AND os.language_id = :language_id)
+ LEFT JOIN shipping_status AS oss ON (`order`.shipping_status_id = oss.shipping_status_id AND os.language_id = :language_id)
-- country
LEFT JOIN country AS bc ON (`order`.billing_country_id = bc.country_id)
LEFT JOIN country AS sc ON (`order`.shipping_country_id = sc.country_id)
@@ -128,6 +162,11 @@
@IF isset(:customer_order_id)
THEN
AND `order`.customer_order_id = :customer_order_id
+ END @IF
+
+ @IF isset(:email)
+ THEN
+ AND `order`.email = :email
END @IF
LIMIT 1;
@@ -150,31 +189,31 @@
AND product_content.language_id = :language_id
END @IF
-
- WHERE products.order_id = :order_id;
+ -- use @result.order.order_id instead of :order_id to work when :customer_order_id is used
+ WHERE products.order_id = @result.order.order_id;
-- log
SELECT *,os.name as order_status
FROM order_log as log
LEFT JOIN order_status AS os ON (log.order_status_id = os.order_status_id AND os.language_id = :language_id)
- WHERE log.order_id = :order_id;
-
+ WHERE log.order_id = @result.order.order_id;
+
-- meta
SELECT * FROM order_meta as meta
- WHERE meta.order_id = :order_id;
-
+ WHERE meta.order_id = @result.order.order_id;
+
-- total
SELECT * FROM order_total as total
- WHERE total.order_id = :order_id;
+ WHERE total.order_id = @result.order.order_id;
-- shipment
SELECT * FROM order_shipment as shipment
- WHERE shipment.order_id = :order_id;
+ WHERE shipment.order_id = @result.order.order_id;
-- voucher
SELECT * FROM order_voucher as voucher
- WHERE voucher.order_id = :order_id;
-
+ WHERE voucher.order_id = @result.order.order_id;
+
END
@@ -198,7 +237,23 @@
order_status_id as array_key, -- order_id as key
name as array_value -- only set name as value and return
- FROM order_status as order_status_id WHERE language_id = :language_id;
+ FROM order_status as order_status_id WHERE language_id = :language_id;
+
+ -- payment status
+ SELECT
+
+ payment_status_id as array_key, -- order_id as key
+ name as array_value -- only set name as value and return
+
+ FROM payment_status as payment_status_id WHERE language_id = :language_id;
+
+ -- shipping status
+ SELECT
+
+ shipping_status_id as array_key, -- order_id as key
+ name as array_value -- only set name as value and return
+
+ FROM shipping_status as shipping_status_id WHERE language_id = :language_id;
-- billing_country
SELECT
diff --git a/admin/sql/sqlite/order_status.sql b/admin/sql/sqlite/order_status.sql
index bcf04ab..29d956d 100755
--- a/admin/sql/sqlite/order_status.sql
+++ b/admin/sql/sqlite/order_status.sql
@@ -1,4 +1,4 @@
--- Currencies
+-- Order status
-- get all order status
@@ -10,7 +10,6 @@
OUT fetch_one,
)
BEGIN
- -- order_status
SELECT *
FROM order_status AS order_status WHERE 1 = 1
diff --git a/admin/sql/sqlite/payment_status.sql b/admin/sql/sqlite/payment_status.sql
new file mode 100644
index 0000000..98449b5
--- /dev/null
+++ b/admin/sql/sqlite/payment_status.sql
@@ -0,0 +1,94 @@
+-- Payment statuses
+
+ -- get all payment statuses
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+
+ SELECT *
+ FROM payment_status AS payment_status WHERE 1 = 1
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(payment_status.payment_status_id, payment_status) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get payment_status
+
+ PROCEDURE get(
+ IN payment_status_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- payment_status
+ SELECT *
+ FROM payment_status as _ WHERE payment_status_id = :payment_status_id;
+ END
+
+ -- add payment_status
+
+ PROCEDURE add(
+ IN payment_status ARRAY,
+ IN language_id INT,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :payment_status_data = @FILTER(:payment_status, payment_status)
+
+
+ INSERT INTO payment_status
+
+ ( @KEYS(:payment_status_data), language_id )
+
+ VALUES ( :payment_status_data, :language_id );
+
+ END
+
+ -- edit payment_status
+ CREATE PROCEDURE edit(
+ IN payment_status ARRAY,
+ IN payment_status_id INT,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ @FILTER(:payment_status, payment_status)
+
+ UPDATE payment_status
+
+ SET @LIST(:payment_status)
+
+ WHERE payment_status_id = :payment_status_id
+
+
+ END
+
+ -- delete payment_status
+
+ PROCEDURE delete(
+ IN payment_status_id ARRAY,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- payment_status
+ DELETE FROM payment_status WHERE payment_status_id IN (:payment_status_id);
+ END
diff --git a/admin/sql/sqlite/post_meta.sql b/admin/sql/sqlite/post_meta.sql
index 4f3233f..e0935a3 100644
--- a/admin/sql/sqlite/post_meta.sql
+++ b/admin/sql/sqlite/post_meta.sql
@@ -12,7 +12,7 @@
BEGIN
SELECT value
- FROM post_content_meta AS _
+ FROM post_content_meta AS _
WHERE _.`key` = :key
@IF !empty(:post_id)
diff --git a/admin/sql/sqlite/product.sql b/admin/sql/sqlite/product.sql
index 2849307..cdb4096 100755
--- a/admin/sql/sqlite/product.sql
+++ b/admin/sql/sqlite/product.sql
@@ -1017,13 +1017,13 @@
@IF isset(:isbn) && :isbn !== ""
THEN
AND products.isbn = :isbn
- END @IF
+ END @IF
@IF isset(:status) && :status !== ""
THEN
AND products.status = :status
- END @IF
+ END @IF
@IF isset(:product_id) && count(:product_id) > 0
diff --git a/admin/sql/sqlite/product_question.sql b/admin/sql/sqlite/product_question.sql
index 48d443e..15f6285 100755
--- a/admin/sql/sqlite/product_question.sql
+++ b/admin/sql/sqlite/product_question.sql
@@ -18,7 +18,7 @@
)
BEGIN
- SELECT user.*,product_question.*,user.user_id as user_id
+ SELECT user.username, user.first_name, user.last_name, user.display_name, user.avatar, user.bio, user.subscribe, product_question.*,user.user_id as user_id
FROM product_question AS product_question
LEFT JOIN user on user.user_id = product_question.user_id
@@ -30,31 +30,31 @@
AND product_question.product_id = :product_id
END @IF
- -- product slug
+ -- product slug
@IF isset(:slug)
THEN
AND product_question.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
- END @IF
+ END @IF
-- user
@IF isset(:user_id)
- THEN
+ THEN
AND product_question.user_id = :user_id
- END @IF
+ END @IF
- -- user
+ -- user
@IF isset(:status)
- THEN
+ THEN
AND product_question.status = :status
- END @IF
+ END @IF
- @SQL_LIMIT(:start, :limit);
+ @SQL_LIMIT(:start, :limit);
SELECT count(*) FROM (
- @SQL_COUNT(product_question.product_question_id, product_question) -- this takes previous query removes limit and replaces select columns with parameter product_id
+ @SQL_COUNT(product_question.product_question_id, product_question) -- this takes previous query removes limit and replaces select columns with parameter product_id
- ) as count;
+ ) as count;
END
@@ -69,7 +69,7 @@
-- question
SELECT *
FROM product_question as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN user on user.user_id = _.user_id
+ LEFT JOIN user on user.user_id = _.user_id
WHERE product_question_id = :product_question_id LIMIT 1;
END
diff --git a/admin/sql/sqlite/product_review.sql b/admin/sql/sqlite/product_review.sql
index d8f69ab..ea7d0fb 100755
--- a/admin/sql/sqlite/product_review.sql
+++ b/admin/sql/sqlite/product_review.sql
@@ -20,33 +20,33 @@
)
BEGIN
- SELECT user.*,product_review.*,user.user_id as user_id,
+ SELECT user.username, user.first_name, user.last_name, user.display_name, user.avatar, user.bio, user.subscribe, product_review.*,user.user_id as user_id,
(SELECT json_group_array(json_object('id',prm.product_review_media_id,'image',prm.image))
FROM product_review_media as prm
- WHERE prm.product_review_id = product_review.product_review_id) as images
+ WHERE prm.product_review_id = product_review.product_review_id GROUP BY prm.product_review_id) as images
FROM product_review
LEFT JOIN user ON user.user_id = product_review.user_id
- WHERE 1 = 1
+ WHERE 1 = 1
-- product
@IF isset(:product_id)
- THEN
+ THEN
AND product_review.product_id = :product_id
- END @IF
+ END @IF
-- product slug
@IF isset(:slug)
- THEN
+ THEN
AND product_review.product_id = (SELECT product_id FROM product_content WHERE slug = :slug LIMIT 1)
- END @IF
+ END @IF
-- user
@IF isset(:user_id)
- THEN
+ THEN
AND product_review.user_id = :user_id
- END @IF
+ END @IF
-- status
@IF isset(:status)
@@ -75,7 +75,7 @@
-- review
SELECT *
FROM product_review as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN user on user.user_id = _.user_id
+ LEFT JOIN user on user.user_id = _.user_id
WHERE product_review_id = :product_review_id LIMIT 1;
END
diff --git a/admin/sql/sqlite/shipping_status.sql b/admin/sql/sqlite/shipping_status.sql
new file mode 100644
index 0000000..d9ed4c9
--- /dev/null
+++ b/admin/sql/sqlite/shipping_status.sql
@@ -0,0 +1,94 @@
+-- Shipping statuses
+
+ -- get all shipping statuses
+
+ PROCEDURE getAll(
+ IN language_id INT,
+ IN start INT,
+ IN limit INT,
+ OUT fetch_all,
+ OUT fetch_one,
+ )
+ BEGIN
+
+ SELECT *
+ FROM shipping_status AS shipping_status WHERE 1 = 1
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @SQL_LIMIT(:start, :limit);
+
+ SELECT count(*) FROM (
+
+ @SQL_COUNT(shipping_status.shipping_status_id, shipping_status) -- this takes previous query removes limit and replaces select columns with parameter product_id
+
+ ) as count;
+
+ END
+
+ -- get shipping_status
+
+ PROCEDURE get(
+ IN shipping_status_id INT,
+ OUT fetch_row,
+ )
+ BEGIN
+ -- shipping_status
+ SELECT *
+ FROM shipping_status as _ WHERE shipping_status_id = :shipping_status_id;
+ END
+
+ -- add shipping_status
+
+ PROCEDURE add(
+ IN shipping_status ARRAY,
+ IN language_id INT,
+ OUT insert_id
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ :shipping_status_data = @FILTER(:shipping_status, shipping_status)
+
+
+ INSERT INTO shipping_status
+
+ ( @KEYS(:shipping_status_data), language_id )
+
+ VALUES ( :shipping_status_data, :language_id );
+
+ END
+
+ -- edit shipping_status
+ CREATE PROCEDURE edit(
+ IN shipping_status ARRAY,
+ IN shipping_status_id INT,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- allow only table fields and set defaults for missing values
+ @FILTER(:shipping_status, shipping_status)
+
+ UPDATE shipping_status
+
+ SET @LIST(:shipping_status)
+
+ WHERE shipping_status_id = :shipping_status_id
+
+
+ END
+
+ -- delete shipping_status
+
+ PROCEDURE delete(
+ IN shipping_status_id ARRAY,
+ OUT affected_rows,
+ )
+ BEGIN
+ -- shipping_status
+ DELETE FROM shipping_status WHERE shipping_status_id IN (:shipping_status_id);
+ END
diff --git a/admin/sql/sqlite/user_address.sql b/admin/sql/sqlite/user_address.sql
index fb26c1f..783d572 100755
--- a/admin/sql/sqlite/user_address.sql
+++ b/admin/sql/sqlite/user_address.sql
@@ -1,4 +1,4 @@
--- Addresss
+-- Address
-- get all user addresses
@@ -43,6 +43,7 @@
CREATE PROCEDURE get(
IN user_address_id INT,
+ IN user_id INT,
OUT fetch_row,
)
BEGIN
@@ -51,11 +52,17 @@
FROM user_address AS _
WHERE 1 = 1
- @IF isset(:user_address_id)
- THEN
- AND _.user_address_id = :user_address_id
+ @IF isset(:user_address_id)
+ THEN
+ AND _.user_address_id = :user_address_id
END @IF
+ -- user
+ @IF isset(:user_id)
+ THEN
+ AND _.user_id = :user_id
+ END @IF
+
LIMIT 1;
diff --git a/admin/sql/sqlite/user_wishlist.sql b/admin/sql/sqlite/user_wishlist.sql
index 689547b..d05d4a8 100644
--- a/admin/sql/sqlite/user_wishlist.sql
+++ b/admin/sql/sqlite/user_wishlist.sql
@@ -17,9 +17,10 @@
)
BEGIN
- SELECT *
+ SELECT p.*, user_wishlist.*, pc.name, pc.slug
FROM user_wishlist
+ INNER JOIN product p ON p.product_id = user_wishlist.product_id
INNER JOIN product_content pc ON pc.product_id = user_wishlist.product_id AND pc.language_id = :language_id
WHERE user_wishlist.user_id = :user_id
@@ -56,19 +57,27 @@
-- Add new product to wishlist
CREATE PROCEDURE add(
- IN user_wishlist ARRAY,
+ -- IN user_wishlist ARRAY,
+ IN product_id INT,
+ IN user_id INT,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_wishlist, user_wishlist)
+ -- @FILTER(:user_wishlist, user_wishlist)
+
+ -- INSERT INTO user_wishlist
+
+ -- ( @KEYS(:user_wishlist) )
+
+ -- VALUES ( :user_wishlist )
- INSERT INTO user_wishlist
+ INSERT IGNORE INTO user_wishlist
- ( @KEYS(:user_wishlist) )
+ ( `user_id`, `product_id` )
- VALUES ( :user_wishlist )
+ VALUES ( :user_id, :product_id )
END
diff --git a/admin/template/common.tpl b/admin/template/common.tpl
index 863fdf7..3eca3dd 100755
--- a/admin/template/common.tpl
+++ b/admin/template/common.tpl
@@ -4,23 +4,7 @@
import(admin.tpl)
import(ifmacros.tpl)
import(notifications.tpl)
-
-import(components/posts.tpl)
-import(components/products.tpl)
-import(components/product.tpl)
-import(components/orders.tpl)
-import(components/users.tpl)
-import(components/languages.tpl)
-import(components/admin.tpl)
-import(components/comments.tpl)
-import(components/news.tpl)
-import(components/product/reviews.tpl)
-import(components/stats.tpl)
-import(components/states.tpl)
-import(components/sites.tpl)
-import(components/site.tpl)
-import(components/pagination.tpl)
-import(components/notifications.tpl, [data-v-component-notifications])
+import(components.tpl)
import(menu.tpl)
diff --git a/admin/template/components.tpl b/admin/template/components.tpl
new file mode 100644
index 0000000..55366f4
--- /dev/null
+++ b/admin/template/components.tpl
@@ -0,0 +1,18 @@
+import(components/posts.tpl)
+import(components/products.tpl)
+import(components/product.tpl)
+import(components/orders.tpl)
+import(components/users.tpl)
+import(components/languages.tpl)
+import(components/admin.tpl)
+import(components/comments.tpl)
+import(components/news.tpl)
+import(components/product/reviews.tpl)
+import(components/stats.tpl)
+import(components/states.tpl)
+import(components/sites.tpl)
+import(components/site.tpl)
+import(components/order.tpl)
+import(components/user/address.tpl)
+import(components/pagination.tpl)
+import(components/notifications.tpl, [data-v-component-notifications])
diff --git a/admin/template/components/order.tpl b/admin/template/components/order.tpl
new file mode 100644
index 0000000..a880ede
--- /dev/null
+++ b/admin/template/components/order.tpl
@@ -0,0 +1 @@
+import(/app/template/components/order.tpl)
diff --git a/admin/template/components/user/address.tpl b/admin/template/components/user/address.tpl
new file mode 100644
index 0000000..bb86115
--- /dev/null
+++ b/admin/template/components/user/address.tpl
@@ -0,0 +1 @@
+import(/app/template/components/user/address.tpl)
diff --git a/admin/template/content/edit.tpl b/admin/template/content/edit.tpl
index 4eae18f..f428575 100644
--- a/admin/template/content/edit.tpl
+++ b/admin/template/content/edit.tpl
@@ -39,7 +39,7 @@
@templates-select-option|before = <?php
if ($optgroup != $option['folder']) {
$optgroup = $option['folder'];
- echo '<optgroup label="' . ucfirst($optgroup) . '">';
+ echo '<optgroup label="' . ucfirst($optgroup ?? '') . '">';
}
?>
@@ -156,4 +156,4 @@ if(isset($this->sitesList) && is_array($this->sitesList)) {
}?>
-import(content/post_taxonomy.tpl)
\ No newline at end of file
+import(content/post_taxonomy.tpl)
diff --git a/admin/template/email/order/update.tpl b/admin/template/email/order/update.tpl
new file mode 100644
index 0000000..8f40b99
--- /dev/null
+++ b/admin/template/email/order/update.tpl
@@ -0,0 +1,4 @@
+import(components.tpl)
+import(ifmacros.tpl)
+
+[data-v-message] = $this->message
diff --git a/admin/template/order/order.tpl b/admin/template/order/order.tpl
index c168aa1..b129cc1 100755
--- a/admin/template/order/order.tpl
+++ b/admin/template/order/order.tpl
@@ -48,9 +48,10 @@ if(is_array($logs)) foreach ($logs as $index => $log) {
?>
//catch all data attributes
- @log [data-v-order-log-*]|innerText = $log['@@__data-v-order-log-(*)__@@']
- @log a[data-v-order-log-*]|href = $log['@@__data-v-order-log-(*)__@@']
- @log input[data-v-order-log-*]|value = $log['@@__data-v-order-log-(*)__@@']
+ @log [data-v-order-log-note]|innerText = <?php echo nl2br(htmlentities($log['@@__data-v-order-log-(*)__@@']));?>
+ @log [data-v-order-log-*]|innerText = $log['@@__data-v-order-log-(*)__@@']
+ @log a[data-v-order-log-*]|href = $log['@@__data-v-order-log-(*)__@@']
+ @log input[data-v-order-log-*]|value = $log['@@__data-v-order-log-(*)__@@']
@log .badge[data-v-order-log-order_status]|addClass = <?php echo Vvveb\orderStatusBadgeClass($log['order_status_id']);?>
@log|after = <?php }?>
diff --git a/admin/template/settings/payment-status.tpl b/admin/template/settings/payment-status.tpl
new file mode 100644
index 0000000..ca2c7a3
--- /dev/null
+++ b/admin/template/settings/payment-status.tpl
@@ -0,0 +1 @@
+import(crud.tpl, {"type":"payment_status"})
diff --git a/admin/template/settings/payment-statuses.tpl b/admin/template/settings/payment-statuses.tpl
new file mode 100644
index 0000000..edc835d
--- /dev/null
+++ b/admin/template/settings/payment-statuses.tpl
@@ -0,0 +1,3 @@
+import(listing.tpl, {"type":"payment_status", "list": "payment_status"})
+
+import(filters.tpl)
diff --git a/admin/template/settings/shipping-status.tpl b/admin/template/settings/shipping-status.tpl
new file mode 100644
index 0000000..2957f41
--- /dev/null
+++ b/admin/template/settings/shipping-status.tpl
@@ -0,0 +1 @@
+import(crud.tpl, {"type":"shipping_status"})
diff --git a/admin/template/settings/shipping-statuses.tpl b/admin/template/settings/shipping-statuses.tpl
new file mode 100644
index 0000000..24c7e23
--- /dev/null
+++ b/admin/template/settings/shipping-statuses.tpl
@@ -0,0 +1,3 @@
+import(listing.tpl, {"type":"shipping_status", "list": "shipping_status"})
+
+import(filters.tpl)
diff --git a/config/admin-menu.php b/config/admin-menu.php
index 5386628..15d210c 100755
--- a/config/admin-menu.php
+++ b/config/admin-menu.php
@@ -318,40 +318,40 @@ return
//'badge' => '7',
//'badge-class' => 'badge bg-secondary float-end',
],
- 'subscriptions' => [
- 'name' => __('Subscriptions'),
- 'url' => $admin_path . '?module=order/subscriptions',
- 'module' => 'order/subscriptions',
- 'action' => 'index',
- 'icon' => 'la la-retweet',
- ],
- 'returns' => [
- 'name' => __('Returns'),
- 'url' => $admin_path . '?module=order/returns',
- 'module' => 'order/returns',
- 'action' => 'index',
- 'icon' => 'la la-undo',
- //'badge' => '3',
- //'badge-class' => 'badge bg-danger float-end',
- ],
- 'marketing-heading' => [
- 'name' => __('Marketing'),
- 'heading' => true,
- ],
- 'coupons' => [
- 'name' => __('Discount coupons'),
- 'icon' => 'la la-percentage',
- 'url' => $admin_path . '?module=order/coupons',
- 'module' => 'order/coupons',
- 'action' => 'index',
- ],
- 'vouchers' => [
- 'name' => __('Gift vouchers'),
+ 'subscriptions' => [
+ 'name' => __('Subscriptions'),
+ 'url' => $admin_path . '?module=order/subscriptions',
+ 'module' => 'order/subscriptions',
+ 'action' => 'index',
+ 'icon' => 'la la-retweet',
+ ],
+ 'returns' => [
+ 'name' => __('Returns'),
+ 'url' => $admin_path . '?module=order/returns',
+ 'module' => 'order/returns',
+ 'action' => 'index',
+ 'icon' => 'la la-undo',
+ //'badge' => '3',
+ //'badge-class' => 'badge bg-danger float-end',
+ ],
+ 'marketing-heading' => [
+ 'name' => __('Marketing'),
+ 'heading' => true,
+ ],
+ 'coupons' => [
+ 'name' => __('Discount coupons'),
+ 'icon' => 'la la-percentage',
+ 'url' => $admin_path . '?module=order/coupons',
+ 'module' => 'order/coupons',
+ 'action' => 'index',
+ ],
+ 'vouchers' => [
+ 'name' => __('Gift vouchers'),
'icon' => 'la la-gift',
- 'url' => $admin_path . '?module=order/vouchers',
- 'module' => 'order/vouchers',
- 'action' => 'index',
- ],
+ 'url' => $admin_path . '?module=order/vouchers',
+ 'module' => 'order/vouchers',
+ 'action' => 'index',
+ ],
],
],
/*
@@ -528,7 +528,6 @@ return
],
],
],
-/*
'field' => [
'name' => __('Fields'),
'url' => $admin_path . '?module=field/field-groups',
@@ -552,7 +551,6 @@ return
],
],
],
-*/
'settings' => [
'name' => __('Settings'),
'url' => $admin_path . '?module=settings/sites',
@@ -671,7 +669,7 @@ return
'action' => 'index',
'icon' => 'la la-box',
],
-/*
+
'fields' => [
'name' => __('Fields'),
'url' => $admin_path . '?module=field/field-group',
@@ -679,7 +677,6 @@ return
'action' => 'index',
'icon' => 'la la-stream',
],
-*/
],
],
'ecommerce' => [
@@ -691,19 +688,19 @@ return
'class' => 'align-top',
'items' => [
/*
- 'checkout' => [
- 'name' => __('Checkout & payments'),
- 'icon' => 'la la-credit-card',
- 'url' => $admin_path . '?module=settings/checkout',
- 'module' => 'settings/checkout',
- 'action' => 'index',
- ],
- 'email' => [
- 'name' => __('Email notifications'),
- 'icon' => 'la la-envelope',
- 'url' => $admin_path . '?module=settings/notifications',
- 'module' => 'settings/notifications',
- 'action' => 'index',
+ 'checkout' => [
+ 'name' => __('Checkout & payments'),
+ 'icon' => 'la la-credit-card',
+ 'url' => $admin_path . '?module=settings/checkout',
+ 'module' => 'settings/checkout',
+ 'action' => 'index',
+ ],
+ 'email' => [
+ 'name' => __('Email notifications'),
+ 'icon' => 'la la-envelope',
+ 'url' => $admin_path . '?module=settings/notifications',
+ 'module' => 'settings/notifications',
+ 'action' => 'index',
],*/
'subscriptions' => [
'name' => __('Subscriptions plans'),
@@ -781,13 +778,6 @@ return
'module' => 'settings/order-statuses',
'action' => 'index',
'items' => [
- 'order-status' => [
- 'name' => __('Order'),
- 'url' => $admin_path . '?module=settings/order-statuses',
- 'module' => 'settings/order-statuses',
- 'action' => 'index',
- 'icon' => 'la la-file-invoice',
- ],
'stock-status' => [
'name' => __('Stock'),
'url' => $admin_path . '?module=settings/stock-statuses',
@@ -802,6 +792,31 @@ return
'action' => 'index',
'icon' => 'la la-retweet',
],
+ 'order-heading' => [
+ 'name' => __('Order'),
+ 'heading' => true,
+ ],
+ 'order-status' => [
+ 'name' => __('Order'),
+ 'url' => $admin_path . '?module=settings/order-statuses',
+ 'module' => 'settings/order-statuses',
+ 'action' => 'index',
+ 'icon' => 'la la-file-invoice',
+ ],
+ 'payment-status' => [
+ 'name' => __('Payment'),
+ 'url' => $admin_path . '?module=settings/payment-statuses',
+ 'module' => 'settings/payment-statuses',
+ 'action' => 'index',
+ 'icon' => 'la la-coins',
+ ],
+ 'shipping-status' => [
+ 'name' => __('Shipping'),
+ 'url' => $admin_path . '?module=settings/shipping-statuses',
+ 'module' => 'settings/shipping-statuses',
+ 'action' => 'index',
+ 'icon' => 'la la-shipping-fast',
+ ],
'status-heading' => [
'name' => __('Returns'),
'heading' => true,
@@ -948,15 +963,13 @@ return
'action' => 'index',
'icon' => 'la la-server',
],
- /*
- 'cron' => [
- 'name' => __('Cron job'),
- 'url' => $admin_path . '?module=tools/cron',
- 'module' => 'tools/cron',
- 'action' => 'index',
- 'icon' => 'la la-history la-90',
- ],
-*/
+ 'cron' => [
+ 'name' => __('Cron job'),
+ 'url' => $admin_path . '?module=tools/cron',
+ 'module' => 'tools/cron',
+ 'action' => 'index',
+ 'icon' => 'la la-history la-90',
+ ],
'import-export' => [
'name' => __('Import/Export'),
'url' => $admin_path . '?module=tools/import',
diff --git a/install/sql/insert/order/order_status.sql b/install/sql/insert/order/order_status.sql
index 19a08ac..1936502 100755
--- a/install/sql/insert/order/order_status.sql
+++ b/install/sql/insert/order/order_status.sql
@@ -1,21 +1,8 @@
INSERT INTO `order_status` VALUES
-(1,1,'processing'),
-(2,1,'shipped'),
-(3,1,'canceled'),
+(1,1,'pending'),
+(2,1,'processing'),
+(3,1,'processed'),
(4,1,'complete'),
-(5,1,'denied'),
-(6,1,'canceled_reversal'),
-(7,1,'failed'),
-(8,1,'refunded'),
-(9,1,'reversed'),
-(10,1,'chargeback'),
-(11,1,'pending'),
-(12,1,'voided'),
-(13,1,'processed'),
-(14,1,'expired'),
-(15,1,'holded'),
-(16,1,'closed'),
-(17,1,'delivered'),
-(18,1,'pending_payment'),
-(19,1,'payment_review'),
-(20,1,'fraud');
\ No newline at end of file
+(5,1,'canceled'),
+(6,1,'archived'),
+(7,1,'requires_action');
diff --git a/install/sql/insert/order/payment_status.sql b/install/sql/insert/order/payment_status.sql
new file mode 100644
index 0000000..2efe41b
--- /dev/null
+++ b/install/sql/insert/order/payment_status.sql
@@ -0,0 +1,9 @@
+INSERT INTO `payment_status` VALUES
+(1,1,'not_paid'),
+(2,1,'awaiting'),
+(3,1,'captured'),
+(4,1,'canceled'),
+(5,1,'refunded'),
+(6,1,'partially_refunded'),
+(7,1,'chargeback'),
+(8,1,'requires_action');
diff --git a/install/sql/insert/order/return_resolution.sql b/install/sql/insert/order/return_resolution.sql
index f4981dd..75160a0 100755
--- a/install/sql/insert/order/return_resolution.sql
+++ b/install/sql/insert/order/return_resolution.sql
@@ -1,5 +1,6 @@
INSERT INTO `return_resolution` VALUES
-(1,1,'refunded'),
-(2,1,'partial_refund'),
-(3,1,'credit_issued'),
-(4,1,'replacement_sent');
+(1,1,'pending'),
+(2,1,'refunded'),
+(3,1,'partial_refund'),
+(4,1,'credit_issued'),
+(5,1,'replacement_sent');
diff --git a/install/sql/insert/order/shipping_status.sql b/install/sql/insert/order/shipping_status.sql
new file mode 100644
index 0000000..1e71b56
--- /dev/null
+++ b/install/sql/insert/order/shipping_status.sql
@@ -0,0 +1,9 @@
+INSERT INTO `shipping_status` VALUES
+(1,1,'not_fulfilled'),
+(2,1,'fulfilled'),
+(3,1,'shipped'),
+(4,1,'returned'),
+(5,1,'partially_returned'),
+(6,1,'returned'),
+(7,1,'canceled'),
+(8,1,'requires_action');
diff --git a/install/sql/mysqli/schema/order/order.sql b/install/sql/mysqli/schema/order/order.sql
index c505c54..1015aef 100755
--- a/install/sql/mysqli/schema/order/order.sql
+++ b/install/sql/mysqli/schema/order/order.sql
@@ -27,6 +27,7 @@ CREATE TABLE `order` (
-- `billing_fields` text,
`payment_method` varchar(128) NOT NULL DEFAULT '',
`payment_data` text,
+ `payment_status_id` INT UNSIGNED NOT NULL DEFAULT '0',
-- shipping
`shipping_first_name` varchar(32) NOT NULL DEFAULT '',
`shipping_last_name` varchar(32) NOT NULL DEFAULT '',
@@ -42,6 +43,7 @@ CREATE TABLE `order` (
-- `shipping_fields` text,
`shipping_method` varchar(128) NOT NULL DEFAULT '',
`shipping_data` text,
+ `shipping_status_id` INT UNSIGNED NOT NULL DEFAULT '0',
`total` decimal(15,4) NOT NULL DEFAULT '0.0000',
`order_status_id` INT UNSIGNED NOT NULL DEFAULT '0',
`language_id` INT UNSIGNED NOT NULL,
diff --git a/install/sql/mysqli/schema/order/order_log.sql b/install/sql/mysqli/schema/order/order_log.sql
index ff59d82..d6f3c3b 100755
--- a/install/sql/mysqli/schema/order/order_log.sql
+++ b/install/sql/mysqli/schema/order/order_log.sql
@@ -5,6 +5,7 @@ CREATE TABLE `order_log` (
`order_id` INT UNSIGNED NOT NULL,
`order_status_id` INT UNSIGNED NOT NULL,
`notify` tinyint NOT NULL DEFAULT '0',
+ `public` tinyint NOT NULL DEFAULT '0',
`note` text NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`order_log_id`)
diff --git a/install/sql/mysqli/schema/order/payment_status.sql b/install/sql/mysqli/schema/order/payment_status.sql
new file mode 100644
index 0000000..abeae7a
--- /dev/null
+++ b/install/sql/mysqli/schema/order/payment_status.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `payment_status`;
+
+CREATE TABLE `payment_status` (
+ `payment_status_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `language_id` INT UNSIGNED NOT NULL,
+ `name` varchar(32) NOT NULL,
+ PRIMARY KEY (`payment_status_id`,`language_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/order/return.sql b/install/sql/mysqli/schema/order/return.sql
index 5690bfe..880ebaa 100755
--- a/install/sql/mysqli/schema/order/return.sql
+++ b/install/sql/mysqli/schema/order/return.sql
@@ -3,6 +3,7 @@ DROP TABLE IF EXISTS `return`;
CREATE TABLE `return` (
`return_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`order_id` INT UNSIGNED NOT NULL,
+ `customer_order_id` varchar(64) NOT NULL DEFAULT '0',
`product_id` INT UNSIGNED NOT NULL,
`user_id` INT UNSIGNED NOT NULL,
`first_name` varchar(32) NOT NULL,
@@ -13,12 +14,12 @@ CREATE TABLE `return` (
`model` varchar(64) NOT NULL,
`quantity` int(4) NOT NULL,
`opened` tinyint NOT NULL,
- `return_reason_id` INT UNSIGNED NOT NULL,
- `return_resolution_id` INT UNSIGNED NOT NULL,
- `return_status_id` INT UNSIGNED NOT NULL,
+ `return_reason_id` INT UNSIGNED NOT NULL DEFAULT 0,
+ `return_resolution_id` INT UNSIGNED NOT NULL DEFAULT 0,
+ `return_status_id` INT UNSIGNED NOT NULL DEFAULT 0,
`note` text NOT NULL,
`date_ordered` date NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`return_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
\ No newline at end of file
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/mysqli/schema/order/shipping_status.sql b/install/sql/mysqli/schema/order/shipping_status.sql
new file mode 100644
index 0000000..29aa16f
--- /dev/null
+++ b/install/sql/mysqli/schema/order/shipping_status.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `shipping_status`;
+
+CREATE TABLE `shipping_status` (
+ `shipping_status_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `language_id` INT UNSIGNED NOT NULL,
+ `name` varchar(32) NOT NULL,
+ PRIMARY KEY (`shipping_status_id`,`language_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
diff --git a/install/sql/pgsql/schema/order/order.sql b/install/sql/pgsql/schema/order/order.sql
index 3e5836f..405c2f3 100755
--- a/install/sql/pgsql/schema/order/order.sql
+++ b/install/sql/pgsql/schema/order/order.sql
@@ -4,6 +4,12 @@ DROP SEQUENCE IF EXISTS order_seq;
CREATE SEQUENCE order_seq;
-- SELECT setval('order_seq', 0, true); -- last inserted id by sample data
+CREATE TYPE shipping_status AS ENUM
+ ('not_fulfilled', 'partially_fulfilled', 'fulfilled', 'partially_shipped', 'shipped', 'partially_returned', 'returned', 'canceled', 'requires_action');
+
+CREATE TYPE shipping_status AS ENUM
+ ('not_paid', 'awaiting', 'captured', 'partially_refunded', 'refunded', 'canceled', 'requires_action');
+
CREATE TABLE "order" (
"order_id" int check ("order_id" > 0) NOT NULL DEFAULT NEXTVAL ('order_seq'),
@@ -33,6 +39,7 @@ CREATE TABLE "order" (
-- "billing_fields" text NOT NULL,
"payment_method" varchar(128) NOT NULL DEFAULT '',
"payment_data" text NOT NULL DEFAULT '',
+ "payment_status_id" int check ("order_status_id" > 0) NOT NULL DEFAULT 1,
"shipping_first_name" varchar(32) NOT NULL DEFAULT '',
"shipping_last_name" varchar(32) NOT NULL DEFAULT '',
"shipping_company" varchar(60) NOT NULL DEFAULT '',
@@ -47,6 +54,7 @@ CREATE TABLE "order" (
-- "shipping_fields" text NOT NULL,
"shipping_method" varchar(128) NOT NULL DEFAULT '',
"shipping_data" text NOT NULL DEFAULT '',
+ "shipping_status_id" int check ("order_status_id" > 0) NOT NULL DEFAULT 1,
"total" decimal(15,4) NOT NULL DEFAULT 0.0000,
"order_status_id" int check ("order_status_id" > 0) NOT NULL DEFAULT 1,
"language_id" int check ("language_id" > 0) NOT NULL,
diff --git a/install/sql/pgsql/schema/order/order_log.sql b/install/sql/pgsql/schema/order/order_log.sql
index 26309a8..385916f 100755
--- a/install/sql/pgsql/schema/order/order_log.sql
+++ b/install/sql/pgsql/schema/order/order_log.sql
@@ -10,6 +10,7 @@ CREATE TABLE order_log (
"order_id" int check ("order_id" > 0) NOT NULL,
"order_status_id" int check ("order_status_id" > 0) NOT NULL,
"notify" smallint NOT NULL DEFAULT 0,
+ "public" smallint NOT NULL DEFAULT 0,
"note" text NOT NULL,
"created_at" timestamp(0) NOT NULL DEFAULT now(),
PRIMARY KEY ("order_log_id")
diff --git a/install/sql/pgsql/schema/order/payment_status.sql b/install/sql/pgsql/schema/order/payment_status.sql
new file mode 100644
index 0000000..379590a
--- /dev/null
+++ b/install/sql/pgsql/schema/order/payment_status.sql
@@ -0,0 +1,13 @@
+DROP TABLE IF EXISTS payment_status;
+
+DROP SEQUENCE IF EXISTS payment_status_seq;
+CREATE SEQUENCE payment_status_seq;
+SELECT setval('payment_status_seq', 20, true); -- last inserted id by sample data
+
+
+CREATE TABLE payment_status (
+ "payment_status_id" int check ("payment_status_id" > 0) NOT NULL DEFAULT NEXTVAL ('payment_status_seq'),
+ "language_id" int check ("language_id" > 0) NOT NULL,
+ "name" varchar(32) NOT NULL,
+ PRIMARY KEY ("payment_status_id","language_id")
+);
diff --git a/install/sql/pgsql/schema/order/return.sql b/install/sql/pgsql/schema/order/return.sql
index 3223ecf..50bb1c3 100755
--- a/install/sql/pgsql/schema/order/return.sql
+++ b/install/sql/pgsql/schema/order/return.sql
@@ -8,7 +8,7 @@ CREATE SEQUENCE return_seq;
CREATE TABLE return (
"return_id" int check ("return_id" > 0) NOT NULL DEFAULT NEXTVAL ('return_seq'),
"order_id" int check ("order_id" > 0) NOT NULL,
- "product_id" int check ("product_id" > 0) NOT NULL,
+ "customer_order_id" varchar(64) NOT NULL DEFAULT 0,
"user_id" int check ("user_id" > 0) NOT NULL,
"first_name" varchar(32) NOT NULL,
"last_name" varchar(32) NOT NULL,
@@ -19,8 +19,8 @@ CREATE TABLE return (
"quantity" int NOT NULL,
"opened" smallint NOT NULL,
"return_reason_id" int check ("return_reason_id" > 0) NOT NULL,
- "return_resolution_id" int check ("return_resolution_id" > 0) NOT NULL,
- "return_status_id" int check ("return_status_id" > 0) NOT NULL,
+ "return_resolution_id" int check ("return_resolution_id" > 0) NOT NULL DEFAULT 1,
+ "return_status_id" int check ("return_status_id" > 0) NOT NULL DEFAULT 1,
"note" text NOT NULL,
"date_ordered" date NOT NULL,
"created_at" timestamp(0) NOT NULL DEFAULT now(),
diff --git a/install/sql/pgsql/schema/order/shipping_status.sql b/install/sql/pgsql/schema/order/shipping_status.sql
new file mode 100644
index 0000000..54161da
--- /dev/null
+++ b/install/sql/pgsql/schema/order/shipping_status.sql
@@ -0,0 +1,13 @@
+DROP TABLE IF EXISTS shipping_status;
+
+DROP SEQUENCE IF EXISTS shipping_status_seq;
+CREATE SEQUENCE shipping_status_seq;
+SELECT setval('shipping_status_seq', 20, true); -- last inserted id by sample data
+
+
+CREATE TABLE shipping_status (
+ "shipping_status_id" int check ("shipping_status_id" > 0) NOT NULL DEFAULT NEXTVAL ('shipping_status_seq'),
+ "language_id" int check ("language_id" > 0) NOT NULL,
+ "name" varchar(32) NOT NULL,
+ PRIMARY KEY ("shipping_status_id","language_id")
+);
diff --git a/install/sql/sqlite/schema/order/order.sql b/install/sql/sqlite/schema/order/order.sql
index 051fa22..85df8a2 100755
--- a/install/sql/sqlite/schema/order/order.sql
+++ b/install/sql/sqlite/schema/order/order.sql
@@ -29,6 +29,7 @@ CREATE TABLE `order` (
`billing_fields` text NOT NULL DEFAULT '',
`payment_method` text NOT NULL DEFAULT '',
`payment_data` text,
+`payment_status_id` INT NOT NULL DEFAULT '0',
`shipping_first_name` TEXT NOT NULL DEFAULT '',
`shipping_last_name` TEXT NOT NULL DEFAULT '',
`shipping_company` TEXT NOT NULL DEFAULT '',
@@ -44,6 +45,7 @@ CREATE TABLE `order` (
`shipping_fields` text NOT NULL NULL DEFAULT '',
`shipping_method` TEXT NOT NULL DEFAULT '',
`shipping_data` TEXT NOT NULL NULL DEFAULT '',
+`shipping_status_id` INT NOT NULL DEFAULT '0',
`total` decimal(15,4) NOT NULL DEFAULT '0.0000',
`order_status_id` INT NOT NULL DEFAULT '0',
`language_id` INT NOT NULL,
diff --git a/install/sql/sqlite/schema/order/order_log.sql b/install/sql/sqlite/schema/order/order_log.sql
index 5e8a063..3349caf 100755
--- a/install/sql/sqlite/schema/order/order_log.sql
+++ b/install/sql/sqlite/schema/order/order_log.sql
@@ -5,6 +5,7 @@ CREATE TABLE `order_log` (
`order_id` INT NOT NULL,
`order_status_id` INT NOT NULL,
`notify` TINYINT NOT NULL DEFAULT '0',
+`public` TINYINT NOT NULL DEFAULT '0',
`note` text NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
-- PRIMARY KEY (`order_log_id`)
diff --git a/install/sql/sqlite/schema/order/payment_status.sql b/install/sql/sqlite/schema/order/payment_status.sql
new file mode 100644
index 0000000..90bc337
--- /dev/null
+++ b/install/sql/sqlite/schema/order/payment_status.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `payment_status`;
+
+CREATE TABLE `payment_status` (
+`payment_status_id` INTEGER PRIMARY KEY AUTOINCREMENT,
+`language_id` INT NOT NULL,
+`name` TEXT NOT NULL
+-- PRIMARY KEY (`payment_status_id`,`language_id`)
+);
diff --git a/install/sql/sqlite/schema/order/return.sql b/install/sql/sqlite/schema/order/return.sql
index fc40187..419488a 100755
--- a/install/sql/sqlite/schema/order/return.sql
+++ b/install/sql/sqlite/schema/order/return.sql
@@ -3,6 +3,7 @@ DROP TABLE IF EXISTS `return`;
CREATE TABLE `return` (
`return_id` INTEGER PRIMARY KEY AUTOINCREMENT,
`order_id` INT NOT NULL,
+`customer_order_id` TEXT NOT NULL DEFAULT 0,
`product_id` INT NOT NULL,
`user_id` INT NOT NULL,
`first_name` TEXT NOT NULL,
@@ -14,8 +15,8 @@ CREATE TABLE `return` (
`quantity` INTEGER NOT NULL,
`opened` TINYINT NOT NULL,
`return_reason_id` INT NOT NULL,
-`return_resolution_id` INT NOT NULL,
-`return_status_id` INT NOT NULL,
+`return_resolution_id` INT NOT NULL DEFAULT 0,
+`return_status_id` INT NOT NULL DEFAULT 0,
`note` text NOT NULL,
`date_ordered` date NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
diff --git a/install/sql/sqlite/schema/order/shipping_status.sql b/install/sql/sqlite/schema/order/shipping_status.sql
new file mode 100644
index 0000000..62bcc6b
--- /dev/null
+++ b/install/sql/sqlite/schema/order/shipping_status.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `shipping_status`;
+
+CREATE TABLE `shipping_status` (
+`shipping_status_id` INTEGER PRIMARY KEY AUTOINCREMENT,
+`language_id` INT NOT NULL,
+`name` TEXT NOT NULL
+-- PRIMARY KEY (`shipping_status_id`,`language_id`)
+);
diff --git a/system/cart/coupon-trait.php b/system/cart/coupon-trait.php
index 1a293d3..af49159 100644
--- a/system/cart/coupon-trait.php
+++ b/system/cart/coupon-trait.php
@@ -22,14 +22,14 @@
namespace Vvveb\System\Cart;
-use Vvveb\Sql\couponSQL;
+use Vvveb\Sql\CouponSQL;
trait CouponTrait {
protected $coupons = [];
public function addCoupon($code) {
if ($code) {
- $coupon = new couponSQL();
+ $coupon = new CouponSQL();
$options = $this->options + ['code' => $code, 'status' => 1];
$result = $coupon->get($options);
diff --git a/system/cart/order-cart.php b/system/cart/order-cart.php
new file mode 100644
index 0000000..c0b2c85
--- /dev/null
+++ b/system/cart/order-cart.php
@@ -0,0 +1,341 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\System\Cart;
+
+use function \Vvveb\model;
+use function \Vvveb\url;
+use Vvveb\Sql\OrderSQL;
+use Vvveb\Sql\Product_option_valueSQL;
+use Vvveb\Sql\ProductSQL;
+use Vvveb\System\Images;
+use Vvveb\System\Session;
+
+class OrderCart extends Cart {
+ protected $cart = [];
+
+ protected $session;
+
+ protected $currency;
+
+ protected $tax;
+
+ protected $order_id;
+
+ protected $productModel = 'product';
+
+ protected $options;
+
+ protected $order = [];
+
+ protected $products = [];
+
+ protected $taxes = [];
+
+ protected $totals = [];
+
+ protected $total = 0;
+
+ protected $total_tax = 0;
+
+ protected $total_items = 0;
+
+ use TaxTrait, ProductOptionTrait, CouponTrait;
+
+ function __construct($order_id, $options = []) {
+ $this->session = Session :: getInstance();
+ $this->currency = Currency :: getInstance($options);
+ $this->tax = Tax :: getInstance();
+
+ $this->tax->setRegionRules($options['country_id'], $options['region_id']);
+
+ $this->order_id = $order_id;
+ $this->options = $options;
+ $this->read();
+
+ if (! isset($this->total_items)) {
+ $this->total_items = 0;
+ }
+
+ if (! isset($this->total)) {
+ $this->total = 0;
+ }
+
+ if (! isset($this->products)) {
+ $this->products = [];
+ }
+ }
+
+ public function updateCart() {
+ $this->total = 0;
+ $this->total_items = 0;
+
+ $results = ['products' => [], 'count' => 0];
+
+ if (! empty($this->products)) {
+ $productIds = [];
+ $productOptions = [];
+ $productSubscriptions = [];
+
+ foreach ($this->products as $product) {
+ $productId = $product['product_id'];
+ $productIds[$productId] = $productId;
+
+ //get all product options to make one query to get all option values
+ if (isset($product['option'])) {
+ foreach ($product['option'] as $value) {
+ if (is_numeric($value)) {
+ $productOptions[$value] = $value;
+ } else {
+ $product_option_value_id = $value['product_option_value_id'];
+ $productOptions[$product_option_value_id] = $product_option_value_id;
+ }
+ }
+ }
+
+ if (isset($product['subscription_plan_id'])) {
+ $productSubscriptions[$productId] = $product['subscription_plan_id'];
+ }
+ }
+
+ //get product data from db for products in cart
+ $options = [
+ 'product_id' => $productIds,
+ ] + $this->options;
+
+ $productSql = model($this->productModel); //new ProductSQL();
+ $results = $productSql->getAll(
+ $options
+ );
+
+ // if products have options get all product options in one query
+ $optionResults = [];
+
+ if ($productOptions) {
+ $productOptionValueSql = new Product_option_valueSQL();
+ $optionResults = $productOptionValueSql->getAll(
+ ['product_option_value_id' => array_values($productOptions)] + $this->options
+ )['product_option_value'] ?? [];
+ }
+ }
+
+ $products = $results['products'] ?? [];
+
+ if ($products) {
+ foreach ($this->products as $key => &$prod) {
+ if (! isset($products[$product['product_id']])) {
+ unset($this->products[$key]);
+
+ continue;
+ }
+
+ $productId = $prod['product_id'];
+ $product = $products[$productId];
+
+ $prod['price'] = $product['price'];
+
+ //add option value data and adjust price if necessary
+ if (isset($prod['option'])) {
+ foreach ($prod['option'] as $option_id => $option) {
+ if (is_numeric($option)) {
+ $product_option_value_id = $option;
+ } else {
+ $product_option_value_id = $option['product_option_value_id'];
+ }
+
+ $value = $optionResults[$product_option_value_id];
+
+ if ($value['price']) {
+ if ($value['price_operator'] == '-') {
+ $value['price'] = -$value['price'];
+ }
+
+ $prod['price'] += $value['price'];
+ $value['price_formatted'] = $this->currency->format($value['price']);
+ }
+
+ $prod['option_value'][$product_option_value_id] = $value;
+ }
+ }
+
+ $prod['url'] = htmlentities(url('product/product/index', $product));
+ $prod['remove-url'] = htmlentities(url('cart/cart/remove', $product));
+
+ $prod['total'] = (int)$prod['price'] * $prod['quantity'];
+ $prod['total_formatted'] = $this->currency->format($prod['total']);
+
+ $taxValue = $this->tax->addTaxes($prod['price'], $product['tax_type_id'], true);
+ $prod['price_tax'] = ($taxValue + $prod['price']);
+ $prod['tax'] = $prod['price_tax'] * $prod['quantity'];
+ $prod['total_tax'] = $prod['tax'];
+
+ $prod['price_tax_formatted'] = $this->currency->format($prod['price_tax']);
+ $prod['price_formatted'] = $this->currency->format($product['price']);
+ $prod['total_formatted'] = $this->currency->format($prod['total']);
+ $prod['total_tax_formatted'] = $this->currency->format($prod['total_tax']);
+
+ if (isset($products[$productId]['subscription_plan_id'])) {
+ //$prod['subscription_plan_id'] = $products[$productId]['subscription_plan_id'];
+ }
+
+ $this->total += $prod['total'];
+ $this->total_tax += $prod['total_tax'];
+ $this->total_items += $prod['quantity'];
+
+ $prod = array_merge($prod, $product);
+
+ if (isset($product['image'])) {
+ $prod['image'] = Images::image($product['image'], 'product', 'thumb');
+ }
+
+ // options add to price
+ }
+ }
+
+ $this->addTotal('sub_total', 'Sub-total', $this->total);
+ //write is done by addTotal
+ //$this->write();
+ return $results;
+ }
+
+ function add($productId, $orderProductId = false, $quantity = 1, $option = [], $subscriptionPlanId = false) {
+ if (! $productId) {
+ return false;
+ }
+
+ $key = $productId;
+
+ if ($option) {
+ $optionKey = [];
+
+ foreach ($option as $opt) {
+ $optionKey[$opt['product_option_id']] = $opt['product_option_value_id'];
+ }
+ $key .= '_' . json_encode($optionKey);
+ }
+
+ if ($subscriptionPlanId) {
+ $key .= "_$subscriptionPlanId";
+ }
+
+ $key = str_replace('"', '', $key);
+
+ if (isset($this->products[$key])) {
+ $this->products[$key]['quantity'] += $quantity;
+ } else {
+ $this->products[$key] = [
+ 'product_id' => $productId,
+ 'order_product_id' => $orderProductId,
+ 'quantity' => $quantity,
+ 'option' => $option,
+ 'subscription_plan_id' => $subscriptionPlanId,
+ ];
+ }
+
+ //return $this->updateCart();
+ }
+
+ function addTotal($key, $title, $value, $text = '', $order_total_id = false) {
+ $data = ['key' => $key, 'title' => $title, 'value' => $value, 'value_formatted' => $this->currency->format($value), 'text' => $text, 'order_total_id' => $order_total_id];
+
+ if (isset($this->totals[$key])) {
+ $this->totals[$key]['value'] = $value;
+ $this->totals[$key]['value_formatted'] = $this->currency->format($value);
+ } else {
+ $this->totals[$key] = $data;
+ }
+ //$this->write();
+ }
+
+ protected function read() {
+ $options = ['order_id' => (int)$this->order_id] + $this->options;
+
+ $orders = new OrderSQL();
+ $results = $orders->get($options);
+
+ //$this->totals = $results['total'];
+ if (isset($results['total']) && $results['total']) {
+ foreach ($results['total'] as $total) {
+ $this->addTotal($total['key'], $total['title'], $total['value'], '', $total['order_total_id']);
+ }
+ }
+ //$this->products = $results['products'];
+ if (isset($results['products']) && $results['products']) {
+ foreach ($results['products'] as $product) {
+ $option_value = $product['option_value'] ? json_decode($product['option_value'], true) : [];
+ $this->add($product['product_id'], $product['order_product_id'], $product['quantity'], $option_value);
+ }
+ }
+
+ $this->updateCart();
+
+ /*
+
+ if (is_array($data)) {
+ foreach ($data as $property => $value) {
+ $this->$property = $value;
+ }
+ }*/
+ }
+
+ public function write() {
+ $this->addTaxTotal();
+
+ $order_id = $this->order_id;
+ $orders = new OrderSQL();
+
+ $data = ['total' => $this->getGrandTotal()];
+ $result = $orders->edit(['order' => $data, 'order_id' => $order_id]);
+
+ foreach ($this->products as $key => $product) {
+ $product_options = $product['option'];
+
+ if (isset($product['order_product_id']) && $product['order_product_id']) {
+ $orders->editProduct(['product' => $product, 'product_options' => $product_options, 'order_product_id' => $product['order_product_id'], 'order_id' => $order_id]);
+ } else {
+ unset($product['order_product_id']);
+ $orders->addProduct(['product' => $product, 'product_options' => $product_options, 'order_id' => $order_id]);
+ }
+ }
+
+ foreach ($this->totals as $key => $total) {
+ if (isset($total['order_total_id']) && $total['order_total_id']) {
+ $orders->editTotal(['total' => $total, 'order_total_id' => $total['order_total_id']]);
+ } else {
+ unset($total['order_total_id']);
+ $orders->addTotal(['total' => $total, 'order_id' => $order_id]);
+ }
+ }
+ /*
+ $checkoutInfo['products'] = $cart->getAll();
+ $checkoutInfo['product_options'] = $cart->getProductOptions();
+ $checkoutInfo['totals'] = $cart->getTotals();
+ $checkoutInfo['total'] = $cart->getGrandTotal();
+
+ foreach (['products', 'taxes', 'totals', 'total_items', 'coupons', 'product_options'] as $property) {
+ $data[$property] = $this->$property;
+ }
+
+ $this->session->set($this->sessionKey, $data);
+ */
+ }
+}
diff --git a/system/cart/order.php b/system/cart/order.php
index 21b7413..16c36b7 100755
--- a/system/cart/order.php
+++ b/system/cart/order.php
@@ -78,8 +78,7 @@ class Order {
//add products
foreach ($products as $key => $product) {
$product_options = $product['option_value'] ?? [];
- $product_options['product_id'] = $product['product_id'];
- $this->model->addProduct(['product' => $product, 'product_options' => $product['option_value'], 'order_id' => $order_id]);
+ $this->model->addProduct(['product' => $product, 'product_options' => $product_options, 'order_id' => $order_id]);
}
//update invoice to set {order_id} variable
$data['order_id'] = $order_id;
diff --git a/system/cart/product-option-trait.php b/system/cart/product-option-trait.php
index aff197a..a78da30 100644
--- a/system/cart/product-option-trait.php
+++ b/system/cart/product-option-trait.php
@@ -37,20 +37,11 @@ trait ProductOptionTrait {
public function getProductOptions() {
$product_options = [];
- $products = $this->products + $this->product_options;
+ $products = $this->products;
- foreach ($products as $product) {
- if ($product['product_option_type_id']) {
- $product_option_rates = $this->product_option->getRates($product['price'], $product['product_option_type_id']);
-
- foreach ($product_option_rates as $product_option_rate) {
- if (! isset($product_options[$product_option_rate['product_option_rate_id']])) {
- $product_options[$product_option_rate['product_option_rate_id']] = $product_option_rate;
- $product_options[$product_option_rate['product_option_rate_id']]['value'] = 0;
- }
-
- $product_options[$product_option_rate['product_option_rate_id']]['value'] += ($product_option_rate['amount'] * ($product['quantity'] ?? 1));
- }
+ foreach ($products as $key => $product) {
+ if (isset($product['option_value']) && $product['option_value']) {
+ $product_options[$key] = $product['option_value'];
}
}
diff --git a/system/cart/tax.php b/system/cart/tax.php
index 6a26b05..c069039 100755
--- a/system/cart/tax.php
+++ b/system/cart/tax.php
@@ -22,7 +22,7 @@
namespace Vvveb\System\Cart;
-use Vvveb\Sql\Tax_TypeSQL;
+use Vvveb\Sql\Tax_typeSQL;
use Vvveb\System\Cache;
class Tax {
@@ -46,7 +46,7 @@ class Tax {
public function setRegionRules($country_id, $region_id, $based = 'store') {
$cache = Cache::getInstance();
$rules = $cache->cache(APP,"tax_rates.$country_id.$region_id.$based",function () use ($country_id, $region_id, $based) {
- $taxType = new Tax_TypeSQL();
+ $taxType = new Tax_typeSQL();
$taxRules = $taxType->getRegionRules(['country_id' => $country_id, 'region_id' => $region_id, 'based' => $based]);
return $taxRules['tax_rule'] ?? [];
diff --git a/system/cart/total.php b/system/cart/total.php
index f5b6dd0..549cccc 100755
--- a/system/cart/total.php
+++ b/system/cart/total.php
@@ -23,6 +23,8 @@
namespace Vvveb\System\Cart;
class Total {
+ protected $totals = [];
+
function addTotal($key, $title, $cost, $text = '') {
$data = ['title' => $title, 'cost' => $cost, 'cost_formatted' => '$' . $cost, 'text' => $text];