PluginProbe
Tiered Pricing Table for WooCommerce / 6.1.0
Tiered Pricing Table for WooCommerce v6.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 2.3.3 All 91 releases
tier-pricing-table / views / addons / role-based-pricing / role-based-block.php

role-based-block.php in Tiered Pricing Table for WooCommerce 6.1.0, at views/addons/role-based-pricing/role-based-block.php

126 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php defined( 'ABSPATH' ) || die;
2
3 use TierPricingTable\Addons\RoleBasedPricing\ProductManager;
4 use TierPricingTable\Addons\RoleBasedPricing\RoleBasedPricingRule;
5 use TierPricingTable\Addons\RoleBasedPricing\RoleBasedPriceManager;
6 use TierPricingTable\Core\ServiceContainer;
7
8 /**
9 * Available variables
10 *
11 * @var int $product_id
12 * @var int $loop
13 */
14
15 $product = wc_get_product( $product_id );
16
17 if ( ! $product ) {
18 return;
19 }
20
21 $loop = ! is_null( $loop ) ? $loop : null;
22
23 $fileManager = ServiceContainer::getInstance()->getFileManager();
24
25 ?>
26
27 <div class="form-field tpt-role-based-block" id="tpt-role-based-block-<?php echo esc_attr( $product_id ); ?>"
28 data-product-type="<?php echo esc_attr( $product->get_type() ); ?>"
29 data-add-action="<?php echo esc_attr( ProductManager::GET_ROLE_ROW_HTML__ACTION ); ?>"
30 data-add-action-nonce="<?php echo esc_attr( wp_create_nonce( ProductManager::GET_ROLE_ROW_HTML__ACTION ) ); ?>"
31 data-product-id="<?php echo esc_attr( $product_id ); ?>"
32 data-loop="<?php echo esc_attr( $loop ); ?>">
33 <label class="tpt-role-based-block__name"><?php esc_attr_e( 'Role-based pricing', 'tier-pricing-table' ); ?></label>
34 <div class="tpt-role-based-block__content">
35 <div class="tpt-role-based-roles">
36 <?php
37
38 $presentRoles = array();
39
40 foreach ( wp_roles()->roles as $WPRole => $role_data ) {
41
42 if ( RoleBasedPriceManager::roleHasRules( $WPRole, $product_id, 'edit' ) ) {
43
44 $roleBasedRule = RoleBasedPricingRule::build( $product_id, $WPRole );
45
46 $fileManager->includeTemplate( 'addons/role-based-pricing/role.php', array(
47 'pricing_rule' => $roleBasedRule,
48 'role' => $WPRole,
49 'product_id' => $product_id,
50 'product' => $product,
51 'loop' => $loop,
52 ) );
53
54 $presentRoles[] = $WPRole;
55 }
56 }
57 ?>
58 </div>
59
60 <div class="tpt-role-based-no-roles"
61 style="<?php echo esc_attr( ! empty( $presentRoles ) ? 'display: none;' : '' ); ?>">
62 <span>
63 <?php
64 esc_attr_e( 'Set up separate rules for different roles of customers. Choose a role and click the "Setup for role" button.',
65 'tier-pricing-table' );
66 ?>
67 </span>
68 <p class="description" style="display: block; margin: 0">
69 <?php
70 $settingsLink = add_query_arg( array(
71 'section' => 'advanced',
72 ), ServiceContainer::getInstance()->getSettings()->getLink() );
73
74 $settingsLink = sprintf( '<a target="_blank" href="%s">%s</a>', esc_url( $settingsLink ),
75 esc_html__( 'settings', 'tier-pricing-table' ) );
76
77 echo wp_kses_post( sprintf( __( 'If you do not use this feature, you can disable it in the %s to simplify the interface.',
78 'tier-pricing-table' ), $settingsLink ) );
79
80 ?>
81
82 </p>
83 </div>
84
85 <div class="tpt-role-based-adding-form">
86 <select class="tpt-role-based-adding-form__role-selector">
87 <?php foreach ( wp_roles()->roles as $key => $WPRole ) : ?>
88 <?php if ( ! in_array( $key, $presentRoles ) ) : ?>
89 <option value="<?php echo esc_attr( $key ); ?>">
90 <?php echo esc_attr( $WPRole['name'] ); ?>
91 </option>
92 <?php endif; ?>
93 <?php endforeach; ?>
94 </select>
95
96 <button class="button tpt-role-based-adding-form__add-button">
97 <?php
98 esc_attr_e( 'Setup for role', 'tier-pricing-table' );
99 ?>
100 </button>
101 <?php
102 $roleManagementLink = add_query_arg( [
103 'section' => 'tools',
104 ], ServiceContainer::getInstance()->getSettings()->getLink() );
105
106 $roleManagementLink .= '#roles';
107 ?>
108 <a style="margin-left: auto" target="_blank"
109 href="<?php echo esc_url( $roleManagementLink ); ?>">
110 <?php esc_html_e( 'Manage user roles', 'tier-pricing-table' ); ?>
111 </a>
112
113 <div class="clear"></div>
114 </div>
115
116 <?php $rolesToDeleteName = ! is_null( $loop ) ? "tiered_price_rules_roles_to_delete_variation[$loop][]" : 'tiered_price_rules_roles_to_delete[]'; ?>
117
118 <select name="<?php echo esc_attr( $rolesToDeleteName ); ?>" class="tiered_price_rules_roles_to_delete" multiple
119 style="display:none;">
120 <?php foreach ( wp_roles()->roles as $key => $WPRole ) : ?>
121 <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $WPRole['name'] ); ?></option>
122 <?php endforeach; ?>
123 </select>
124 </div>
125 </div>
126