is_on_sale()) {
$percentage = '';
if ($product->get_type() == 'variable') {
$available_variations = $product->get_variation_prices();
$max_percentage = 0;
foreach ($available_variations['regular_price'] as $key => $regular_price) {
$sale_price = $available_variations['sale_price'][$key];
if ($sale_price < $regular_price) {
$percentage = round((($regular_price - $sale_price) / $regular_price) * 100);
if ($percentage > $max_percentage) {
$max_percentage = $percentage;
}
}
}
$percentage = $max_percentage;
} elseif (($product->get_type() == 'simple' || $product->get_type() == 'external')) {
$percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
}
if ($percentage) {
printf('
%1$s%2$s
', esc_html($percentage), esc_html__('% off', 'ultimate-store-kit'));
}
}
}
protected function render_navigation()
{
$settings = $this->get_settings_for_display();
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? ' bdt-visible@m' : '';
if ('arrows' == $settings['navigation']): ?>
get_settings_for_display();
if ('dots' == $settings['navigation'] or 'arrows-fraction' == $settings['navigation']): ?>
get_settings_for_display();
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : '';
?>
get_settings_for_display();
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : ''; ?>
get_settings_for_display(); ?>