PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.1.0
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.1.0
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Models / CommissionStructure.php
CommissionStructure.php
74 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Models;
4
5 use SureCart\Support\Currency;
6
7 /**
8 * CommissionStructure modal.
9 */
10 class CommissionStructure extends Model {
11 /**
12 * Rest API endpoint
13 *
14 * @var string
15 */
16 protected $endpoint = 'commission_structures';
17
18 /**
19 * Object name
20 *
21 * @var string
22 */
23 protected $object_name = 'commission_structure';
24
25 /**
26 * Get commission amount attribute.
27 *
28 * @return string
29 */
30 public function getCommissionAmountAttribute() {
31 if ( empty( $this->amount_commission ) && empty( $this->percent_commission ) ) {
32 return '-';
33 }
34
35 return $this->amount_commission ?
36 Currency::format( $this->amount_commission, \SureCart::account()->currency ?? 'usd' )
37 : $this->percent_commission . '%';
38 }
39
40 /**
41 * Get subscription commission attribute.
42 *
43 * @return string|null
44 */
45 public function getSubscriptionCommissionAttribute() {
46 if ( $this->recurring_commissions_enabled ) {
47 if ( empty( $this->recurring_commission_days ) ) {
48 return '';
49 }
50 // translators: %d is the number of days.
51 return sprintf( _n( '%d Day', '%d Days', $this->recurring_commission_days, 'surecart' ), $this->recurring_commission_days );
52 }
53
54 return null;
55 }
56
57 /**
58 * Get lifetime commission attribute.
59 *
60 * @return string|null
61 */
62 public function getLifetimeCommissionAttribute() {
63 if ( $this->repeat_customer_commissions_enabled ) {
64 if ( empty( $this->repeat_customer_commission_days ) ) {
65 return '';
66 }
67 // translators: %d is the number of days.
68 return sprintf( _n( '%d Day', '%d Days', $this->repeat_customer_commission_days, 'surecart' ), $this->repeat_customer_commission_days );
69 }
70
71 return null;
72 }
73 }
74