PluginProbe
Tiered Pricing Table for WooCommerce / 6.4.0
Tiered Pricing Table for WooCommerce v6.4.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 2.3.3 All 91 releases
tier-pricing-table / src / Addons / GlobalTieredPricing / Formatter.php

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

36 lines 1011 B
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 $roles = wp_roles()->roles;
27
28 if ( array_key_exists( $roleSlug, $roles ) ) {
29 return $roles[ $roleSlug ]['name'];
30 }
31
32 return 'Undefined role';
33 }
34
35 }
36