PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.0
Booktics – Appointment Booking Calendar for Service Businesses v1.0.0
1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 All 27 releases
booktics / base / models / order-model.php

order-model.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.0, at base/models/order-model.php

64 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Models;
4
5 use Booktics\Abstracts\Model;
6
7 /**
8 * Class Order_Model
9 *
10 * Handles database operations for orders in the Booktics system.
11 *
12 * @package Booktics\Models
13 */
14 class Order_Model extends Model {
15 protected $table = 'booktics_orders';
16 protected $fillable = [
17 'id',
18 'order_no',
19 'customer_id',
20 'customer_note',
21 'status',
22 'payment_status',
23 'price_breakdown',
24 'tax_total',
25 'coupon_code',
26 'coupon_discount',
27 'subtotal',
28 'total',
29 'payment_method',
30 'payment_intent_id',
31 'payment_transaction_id',
32 'created_at',
33 'updated_at'
34 ];
35
36 /**
37 * Create a new order record
38 *
39 * @param array $data Order data to be created
40 *
41 * @return mixed The created order record
42 */
43 public function create( array $data ) {
44 if ( empty( $data['order_no'] ) ) {
45 $data['order_no'] = $this->generate_order_no();
46 }
47
48 $data['price_breakdown'] = wp_json_encode( $data['price_breakdown'] );
49
50 return parent::create( $data );
51 }
52
53
54 /**
55 * Generate a unique order number
56 *
57 * @return string
58 */
59 protected function generate_order_no() {
60 $randomNum = time();
61
62 return 'BKNG-' . $randomNum;
63 }
64 }