- Открыть
wp-content/themes/royal/functions.php
- Добавить функцию
/**
* Check whether user is a cardholder or not.
* @return bool
*/
function is_cardholder()
{
if (!is_user_logged_in()) {
return false;
}
$user = wp_get_current_user();
return in_array('cardholder', $user->roles, true);
}
- Открыть
wp-content/themes/royal/woocommerce/content-single-product.php
Заменить:
<div class="product_side_bar" style="width:255px;">
На это:
<div class="product_side_bar" style="width:255px; <?= is_cardholder() ? 'display: none; opacity: 0; z-index: -9999' : '' ?>">
Заменить:
<div class="tabs tabs-default">
<div class="col-md-9">
На:
<div class="tabs tabs-default">
<div class="<?= is_cardholder() ? 'col-xs-12' : 'col-md-9' ?>">
- Открыть
wp-content/plugins/woocommerce/templates/single-product/cart-top-small.php
Заменить:
<?php
$sales_price = stips_get_sales_price($product);
if ($product->is_on_sale()) {
?>
<div class="stips-product-short-price-amount"><?php echo $sales_price ?> </div>
<div class="footer-product-price-regular-single">
<del><?php echo $current_price = stips_get_current_price($product); ?></del>
</div>
<?php
} else {
?>
<div class="stips-product-short-price-amount"><?php echo $current_price = stips_get_current_price($product); ?></div>
<?php
}
?>
На:
<?php
if (!is_cardholder()):
$sales_price = stips_get_sales_price($product);
if ($product->is_on_sale()) {
?>
<div class="stips-product-short-price-amount"><?php echo $sales_price ?> </div>
<div class="footer-product-price-regular-single">
<del><?php echo $current_price = stips_get_current_price($product); ?></del>
</div>
<?php
} else {
?>
<div class="stips-product-short-price-amount"><?php echo $current_price = stips_get_current_price($product); ?></div>
<?php
}
endif;
?>
Заменить:
<p><a href="/?add-to-cart=<?php echo get_the_ID(); ?>&a=redirect"><?= __('Zaplatit hned', ETHEME_DOMAIN) ?></a>
</p>
На:
<?php if (!is_cardholder()) : ?>
<p>
<a href="/?add-to-cart=<?php echo get_the_ID(); ?>&a=redirect"><?= __('Zaplatit hned', ETHEME_DOMAIN) ?></a>
</p>
<?php endif; ?>
Заменить:
<div class="stips-product-short-price-varients">
<ul>
<li>
<?php $mapkey = get_post_meta($product->id, 'eg-slug');
$maplocation = $mapkey[0];
$locations = (explode(",", $maplocation));
$belolocation = get_post_meta($product->id, 'eg-title');
$loc2 = $belolocation[0];
$loc = (explode("and", $loc2));
foreach ($locations as $key => $val) {
$val2 = $loc[$key];
$siteurl = get_site_url();
$str = preg_replace('/\s+/', '', $val);
?>
<a href="<?php echo $siteurl; ?>/<?php echo $str; ?>"><?php echo $val2; ?></a>
<br>
<?php
}
?>
</li>
</ul>
</div>
На:
<?php if (!is_cardholder()): ?>
<div class="stips-product-short-price-varients">
<ul>
<li>
<?php $mapkey = get_post_meta($product->id, 'eg-slug');
$maplocation = $mapkey[0];
$locations = (explode(",", $maplocation));
$belolocation = get_post_meta($product->id, 'eg-title');
$loc2 = $belolocation[0];
$loc = (explode("and", $loc2));
foreach ($locations as $key => $val) {
$val2 = $loc[$key];
$siteurl = get_site_url();
$str = preg_replace('/\s+/', '', $val);
?>
<a href="<?php echo $siteurl; ?>/<?php echo $str; ?>"><?php echo $val2; ?></a>
<br>
<?php
}
?>
</li>
</ul>
</div>
<?php endif; ?>
- Открыть
wp-content/themes/royal/woocommerce/content-product.php
Заменить:
<?php
/**
* If product is on sale
*/
if ($product->is_on_sale()): ?>
<div class="footer-product-price-sale"><?= stips_get_sales_price($product) ?></div>
<!-- /.footer-product-price -->
<div class="footer-product-price-regular">
<del><?= stips_get_current_price($product) ?></del>
</div>
<!-- /.footer-product-price-regular -->
<?php else: ?>
<div class="footer-product-price-regular"><?= stips_get_current_price($product) ?></div>
<!-- /.footer-product-price-regular -->
<?php endif; ?>
На:
<?php
if (!is_cardholder()):
/**
* If product is on sale
*/
if ($product->is_on_sale()): ?>
<div class="footer-product-price-sale"><?= stips_get_sales_price($product) ?></div>
<!-- /.footer-product-price -->
<div class="footer-product-price-regular">
<del><?= stips_get_current_price($product) ?></del>
</div>
<!-- /.footer-product-price-regular -->
<?php else: ?>
<div class="footer-product-price-regular"><?= stips_get_current_price($product) ?></div>
<!-- /.footer-product-price-regular -->
<?php endif; ?>
<?php endif; ?>