PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.4
Tiered Pricing Table for WooCommerce v7.1.4
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
tier-pricing-table / src / Services / API / ProductFields / RoleBasedPricingData.php

RoleBasedPricingData.php in Tiered Pricing Table for WooCommerce 7.1.4, at src/Services/API/ProductFields/RoleBasedPricingData.php

42 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 TierPricingTable\Services\API\ProductFields;
4
5 use TierPricingTable\Addons\RoleBasedPricing\RoleBasedPriceManager;
6 use TierPricingTable\Addons\RoleBasedPricing\RoleBasedPricingRule;
7 use WC_Product;
8 class RoleBasedPricingData extends ProductField {
9 public function getFieldSlug() : string {
10 return 'tiered_pricing_roles_data';
11 }
12
13 public function sanitizeValue( $value, $productId ) : array {
14 $value = ( is_array( $value ) ? $value : array() );
15 $sanitizedValue = array();
16 wp_roles()->roles;
17 foreach ( $value as $role => $roleData ) {
18 if ( array_key_exists( $role, wp_roles()->roles ) ) {
19 $roleBasedRule = RoleBasedPricingRule::build( $productId, $role );
20 $sanitizedValue[$role] = wp_parse_args( $roleData, $roleBasedRule->asArray() );
21 }
22 }
23 return $sanitizedValue;
24 }
25
26 public function getValue( array $product ) : array {
27 return array();
28 }
29
30 public function updateValue( $value, WC_Product $product ) {
31 }
32
33 public function getType() : string {
34 return 'object';
35 }
36
37 public function getDescription() : string {
38 return 'Roles pricing data. See RoleBasedPricingRule class to get more information about the structure of the data.';
39 }
40
41 }
42