Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Add order defaults on new order

givanz86d82e545b85
diff --git a/app/controller/checkout/checkout.php b/app/controller/checkout/checkout.php
index af35539..47714fe 100755
--- a/app/controller/checkout/checkout.php
+++ b/app/controller/checkout/checkout.php
@@ -200,6 +200,7 @@ class Checkout extends Base {
}
}
+ unset($rules['confirm_password']);
$validator = new Validator($rules);
$checkoutInfo = $validator->filter($this->request->post);
diff --git a/app/validate/signup.php b/app/validate/signup.php
index cf224d3..50ea5c4 100755
--- a/app/validate/signup.php
+++ b/app/validate/signup.php
@@ -34,7 +34,6 @@ return [
'maxLength' => 100,
],
'password' => [
- 'notEmpty' => '',
//'passwordComplexity' => 'low',
'minLength' => 6,
'maxLength' => 32,
diff --git a/system/cart/order.php b/system/cart/order.php
index 2a502e5..db79cef 100755
--- a/system/cart/order.php
+++ b/system/cart/order.php
@@ -22,6 +22,7 @@
namespace Vvveb\System\Cart;
+use function Vvveb\siteSettings;
use Vvveb\Sql\OrderSQL;
class Order {
@@ -46,6 +47,22 @@ class Order {
}
public function add($data) {
+ //set defaults
+ $defaults = ['invoice_prefix', 'order_status_id', 'remote_ip', 'forwarded_for_ip'];
+
+ $site = siteSettings();
+ $site['remote_ip'] = $_SERVER['REMOTE_ADDR'] ?? false;
+ $site['forwarded_for_ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? false;
+
+ foreach ($defaults as $default) {
+ if (
+ (! isset($data) || ! empty($data)) &&
+ (isset($site[$default]) && ! empty($site[$default]))
+ ) {
+ $data[$default] = $site[$default];
+ }
+ }
+
//check if email is already registerd
return $this->model->add(['order' => $data]);
}