| 1 |
<?php defined( 'ABSPATH' ) || die; |
| 2 |
|
| 3 |
use TierPricingTable\Core\FileManager; |
| 4 |
use TierPricingTable\Addons\RoleBasedPricing\RoleBasedPriceManager; |
| 5 |
use TierPricingTable\Addons\RoleBasedPricing\RoleBasedPricingAddon; |
| 6 |
|
| 7 |
/** |
| 8 |
* Available variables |
| 9 |
* |
| 10 |
* @var FileManager $fileManager |
| 11 |
* @var int $product_id |
| 12 |
* @var int $loop |
| 13 |
*/ |
| 14 |
|
| 15 |
?> |
| 16 |
<div class="form-row form-row-full show_if_variable_roles_tiered_pricing form-field"> |
| 17 |
<div class="form-field tpt-role-based-block tpt-role-based-block--variation" |
| 18 |
id="tpt-role-based-block-<?php echo esc_attr( $product_id ); ?>" |
| 19 |
data-product-type="variation" |
| 20 |
data-add-action="<?php echo esc_attr( RoleBasedPricingAddon::GET_ROLE_ROW_HTML__ACTION ); ?>" |
| 21 |
data-add-action-nonce="<?php echo esc_attr( wp_create_nonce( RoleBasedPricingAddon::GET_ROLE_ROW_HTML__ACTION ) ); ?>" |
| 22 |
data-product-id="<?php echo esc_attr( $product_id ); ?>" |
| 23 |
data-loop="<?php echo esc_attr( $loop ); ?>" |
| 24 |
> |
| 25 |
<label class="tpt-role-based-block__name"><?php esc_attr_e( 'Role based pricing', 'tier-pricing-table' ); ?></label> |
| 26 |
<div class="tpt-role-based-block__content"> |
| 27 |
|
| 28 |
<div class="tpt-role-based-roles"> |
| 29 |
|
| 30 |
<?php |
| 31 |
|
| 32 |
$presentRoles = array(); |
| 33 |
|
| 34 |
foreach ( wp_roles()->roles as $WPRole => $role_data ) { |
| 35 |
if ( RoleBasedPriceManager::roleHasRules( $WPRole, $product_id, 'edit' ) ) { |
| 36 |
|
| 37 |
$fileManager->includeTemplate( 'addons/role-based-pricing/variation/role.php', array( |
| 38 |
'fileManager' => $fileManager, |
| 39 |
'minimum_amount' => RoleBasedPriceManager::getProductQtyMin( $product_id, $WPRole, 'edit' ), |
| 40 |
'price_rules_fixed' => RoleBasedPriceManager::getFixedPriceRules( $product_id, $WPRole, 'edit' ), |
| 41 |
'price_rules_percentage' => RoleBasedPriceManager::getPercentagePriceRules( $product_id, $WPRole, 'edit' ), |
| 42 |
'type' => RoleBasedPriceManager::getPricingType( $product_id, $WPRole, 'fixed', 'edit' ), |
| 43 |
'regular_price' => RoleBasedPriceManager::getProductRegularRolePrice( $product_id, $WPRole, 'edit' ), |
| 44 |
'sale_price' => RoleBasedPriceManager::getProductSaleRolePrice( $product_id, $WPRole, 'edit' ), |
| 45 |
'role' => $WPRole, |
| 46 |
'loop' => $loop, |
| 47 |
) ); |
| 48 |
|
| 49 |
$presentRoles[] = $WPRole; |
| 50 |
} |
| 51 |
} |
| 52 |
?> |
| 53 |
</div> |
| 54 |
|
| 55 |
<div class="tpt-role-based-no-roles" |
| 56 |
style="<?php echo esc_attr( ! empty( $presentRoles ) ? 'display: none;' : '' ); ?>"> |
| 57 |
<span><?php esc_attr_e( 'Set up separate rules for different roles of customers. Choose role and click "Setup for role" button.', 'tier-pricing-table' ); ?></span> |
| 58 |
</div> |
| 59 |
|
| 60 |
<div class="tpt-role-based-adding-form"> |
| 61 |
<select class="tpt-role-based-adding-form__role-selector" style="margin: 0; width: 150px"> |
| 62 |
<?php foreach ( wp_roles()->roles as $key => $WPRole ) : ?> |
| 63 |
<?php if ( ! in_array( $key, $presentRoles ) ) : ?> |
| 64 |
<option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $WPRole['name'] ); ?></option> |
| 65 |
<?php endif; ?> |
| 66 |
<?php endforeach; ?> |
| 67 |
</select> |
| 68 |
|
| 69 |
<button class="button tpt-role-based-adding-form__add-button" |
| 70 |
style="height: 40px"> |
| 71 |
<?php esc_attr_e( 'Setup for role', 'tier-pricing-table' ); ?> |
| 72 |
</button> |
| 73 |
|
| 74 |
<div class="clear"></div> |
| 75 |
</div> |
| 76 |
|
| 77 |
<select name="tiered_price_rules_roles_to_delete_variable[<?php echo esc_attr( $loop ); ?>][]" |
| 78 |
class="tiered_price_rules_roles_to_delete" multiple |
| 79 |
style="display:none;"> |
| 80 |
<?php foreach ( wp_roles()->roles as $key => $WPRole ) : ?> |
| 81 |
<option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $WPRole['name'] ); ?></option> |
| 82 |
<?php endforeach; ?> |
| 83 |
</select> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
</div> |
| 87 |
|