PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.2.3
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.2.3
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 / RuleSchema.php
RuleSchema.php
61 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace SureCart\Models;
3
4 /**
5 * Handle working of Rule String.
6 */
7 class RuleSchema extends Model {
8 /**
9 * Rest API endpoint
10 *
11 * @var string
12 */
13 public $endpoint = 'auto_fees/rule_schema';
14
15 /**
16 * Rest API endpoint
17 *
18 * @var string
19 */
20 public $object_name = 'rule_schema';
21
22 /**
23 * Rule Schema.
24 */
25 protected function getIdAttribute() {
26 return str_replace( 'auto_fee__', '', $this->schema_id );
27 }
28
29 /**
30 * Rule Schema.
31 */
32 protected function getRuleSchemaAttribute() {
33 if ( empty( $this->attributes ) || empty( $this->attributes['attributes'] ) ) {
34 return [];
35 }
36
37 // Add wp_user_role attribute.
38 $this->attributes['attributes'][] = (object) [
39 'key' => 'wp_user_role',
40 'metadata' => true,
41 'type' => 'string',
42 'operators' => [
43 'is',
44 'is_not',
45 ],
46 ];
47
48 // Remove the metadata & checkout.metadata attributes.
49 $this->attributes['attributes'] = array_values(
50 array_filter(
51 $this->attributes['attributes'],
52 function ( $attribute ) {
53 return ! in_array( $attribute->key, [ 'metadata', 'checkout.metadata' ], true );
54 }
55 )
56 );
57
58 return $this->attributes['attributes'];
59 }
60 }
61