PluginProbe
Tiered Pricing Table for WooCommerce / 8.1.0
Tiered Pricing Table for WooCommerce v8.1.0
8.1.0 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 All 92 releases
tier-pricing-table / src / Addons / GlobalTieredPricing / Formatter.php

Formatter.php in Tiered Pricing Table for WooCommerce 8.1.0, at src/Addons/GlobalTieredPricing/Formatter.php

40 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Addons\GlobalTieredPricing;
2
3 use WC_Customer;
4
5 class Formatter {
6
7 public static function formatCustomerString( WC_Customer $customer, $link = false ) {
8 $firstName = $customer->get_billing_first_name() ? $customer->get_billing_first_name() : $customer->get_shipping_first_name();
9 $lastName = $customer->get_billing_last_name() ? $customer->get_billing_last_name() : $customer->get_shipping_last_name();
10 $email = $customer->get_billing_email() ? $customer->get_billing_email() : $customer->get_email();
11
12 if ( ! $email ) {
13 return 'Undefined';
14 }
15
16 $name = sprintf( '%s %s (%s)', $firstName, $lastName, $email );
17
18 if ( $link ) {
19 return sprintf( '<a href="%s">%s</a>', get_edit_user_link( $customer->get_id() ), $name );
20 }
21
22 return $name;
23 }
24
25 public static function formatRoleString( $roleSlug ) {
26 if ( GlobalPricingRule::GUEST_ROLE === $roleSlug ) {
27 return __( 'Guests (not logged in)', 'tier-pricing-table' );
28 }
29
30 $roles = wp_roles()->roles;
31
32 if ( array_key_exists( $roleSlug, $roles ) ) {
33 return $roles[ $roleSlug ]['name'];
34 }
35
36 return 'Undefined role';
37 }
38
39 }
40