PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
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 8.0.2, at views/addons/role-based-pricing/role-based-block.php

114 lines 3.8 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" style="line-height: normal"><?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 specific pricing and rules for different user roles.',
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 // translators: %s: settings link
77 echo wp_kses_post( sprintf( __( 'You can disable this feature in the %s if you don\'t need role-based pricing.',
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( 'Add role pricing', 'tier-pricing-table' );
99 ?>
100 </button>
101 <div class="clear"></div>
102 </div>
103
104 <?php $rolesToDeleteName = ! is_null( $loop ) ? "tiered_price_rules_roles_to_delete_variation[$loop][]" : 'tiered_price_rules_roles_to_delete[]'; ?>
105
106 <select name="<?php echo esc_attr( $rolesToDeleteName ); ?>" class="tiered_price_rules_roles_to_delete" multiple
107 style="display:none;">
108 <?php foreach ( wp_roles()->roles as $key => $WPRole ) : ?>
109 <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $WPRole['name'] ); ?></option>
110 <?php endforeach; ?>
111 </select>
112 </div>
113 </div>
114