When "Is multiple allowed" set to YES, product "discount percentage box" only displays NAN%
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from Cyberwolf on August 27, 2020, 02:50Hi, just notice if I enable multiple currencies on my site by selecting YES in WooCommerce Currency Switcher plugin advanced options "Is multiple allowed", that the discount/sales percentage calculation for each product gets broken (shows only NAN%) in case I choose any currency other than site default currency.
I use Porto theme which is supposed to be fully compatible with the WooCommerce Currency Switcher plugin according to their manual. I did contact them about it and they disabled/enabled plugins and went through my site but didn't find anything wrong with the theme. Instead they directed me to contact Woocommerce Currency Switcher Support.
Is there a fix to this problem as I am Canadian and I use a site that needs to also show Euros and US dollars in the checkout process ...
(My purchase code can be found in hidden data field)
Hi, just notice if I enable multiple currencies on my site by selecting YES in WooCommerce Currency Switcher plugin advanced options"Is multiple allowed", that the discount/sales percentage calculation for each product gets broken (shows only NAN%) in case I choose any currency other than site default currency.
I use Porto theme which is supposed to be fully compatible with the WooCommerce Currency Switcher plugin according to their manual. I did contact them about it and they disabled/enabled plugins and went through my site but didn't find anything wrong with the theme. Instead they directed me to contact Woocommerce Currency Switcher Support.
Is there a fix to this problem as I am Canadian and I use a site that needs to also show Euros and US dollars in the checkout process ...
(My purchase code can be found in hidden data field)
Quote from Pablo Borysenco on August 27, 2020, 09:30Hello
Are you using third party discount plugins?
Please drop me exact link to the issue + wp-admin access
Hello
Are you using third party discount plugins?
Please drop me exact link to the issue + wp-admin access
Quote from Cyberwolf on August 27, 2020, 23:42Hi Pablo,
Added wordpress login info to hidden private data.
I am running Alidropship and Woocommerce Square but no other third party "discount" plugins. I have tried to disable Alidropship and Square and all other plugins but still problem continues...
Hi Pablo,
Added wordpress login info to hidden private data.
I am running Alidropship and Woocommerce Square but no other third party"discount" plugins. I have tried to disable Alidropship and Square and all other plugins but still problem continues...
Quote from Cyberwolf on August 27, 2020, 23:48a
a
Quote from Pablo Borysenco on August 28, 2020, 10:42Hello
This is not standard woocommerce functionality. This is the functionality of the current theme.
Unfortunately I do not know how the theme generates these labels.
Ask the author of the theme where and how they form these labels
Hello
This is not standard woocommerce functionality. This is the functionality of the current theme.
Unfortunately I do not know how the theme generates these labels.
Ask the author of the theme where and how they form these labels
Quote from Cyberwolf on August 29, 2020, 03:48The sale percentage is displayed by the Porto theme's sale-flash.php file, please see code below. According to my error log this file gives the following error message as well as displays NAN% in the box.
"Warning: Division by zero in /home2/gusxa8tp/public_html/wp-content/themes/porto/woocommerce/loop/sale-flash.php on line 26"
<?php
/**
* Product loop sale flash
*
* @version 1.6.4
*/if ( ! defined( 'ABSPATH' ) ) {
exit;
}global $post, $product, $porto_settings;
$labels = '';
if ( $porto_settings['product-hot'] ) {
$featured = $product->is_featured();
if ( $featured ) {
$hot_html = '<div class="onhot">' . ( ( isset( $porto_settings['product-hot-label'] ) && $porto_settings['product-hot-label'] ) ? esc_html( $porto_settings['product-hot-label'] ) : __( 'Hot', 'porto' ) ) . '</div>';
$labels .= $hot_html;
}
}
if ( $porto_settings['product-sale'] ) {
if ( $product->is_on_sale() ) {
$percentage = 0;
if ( $product->get_regular_price() ) {
$percentage = - round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
} elseif ( 'variable' == $product->get_type() && $product->get_variation_regular_price() ) {
$percentage = - round( ( ( $product->get_variation_regular_price() - $product->get_variation_sale_price() ) / $product->get_variation_regular_price() ) * 100 );
}
if ( $porto_settings['product-sale-percent'] && $percentage ) {
$sales_html = '<div class="onsale">' . $percentage . '%</div>';
} else {
$sales_html = apply_filters( 'woocommerce_sale_flash', '<div class="onsale">' . ( ( isset( $porto_settings['product-sale-label'] ) && $porto_settings['product-sale-label'] ) ? esc_html( $porto_settings['product-sale-label'] ) : esc_html__( 'Sale', 'porto' ) ) . '</div>', $post, $product );
}
$labels .= $sales_html;
}
}if ( $labels ) {
echo '<div class="labels">' . porto_filter_output( $labels ) . '</div>';
}$availability = $product->get_availability();
if ( 'out-of-stock' == $availability['class'] ) {
if ( $porto_settings['product-stock'] ) {
echo apply_filters( 'woocommerce_stock_html', '<div class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</div>', $availability['availability'] );
}
} else {
if ( '2' != $porto_settings['add-to-cart-notification'] ) {
echo '<div data-link="' . esc_url( get_permalink( wc_get_page_id( 'cart' ) ) ) . '" class="viewcart' . ' viewcart-' . $product->get_id() . '" title="' . esc_attr__( 'View Cart', 'porto' ) . '"></div>';
}
}
The sale percentage is displayed by the Porto theme's sale-flash.php file, please see code below. According to my error log this file gives the following error message as well as displays NAN% in the box.
"Warning: Division by zero in /home2/gusxa8tp/public_html/wp-content/themes/porto/woocommerce/loop/sale-flash.php on line 26"
<?php
/**
* Product loop sale flash
*
* @version 1.6.4
*/if ( ! defined( 'ABSPATH' ) ) {
exit;
}global $post, $product, $porto_settings;
$labels = '';
if ( $porto_settings['product-hot'] ) {
$featured = $product->is_featured();
if ( $featured ) {
$hot_html = '<div class="onhot">' . ( ( isset( $porto_settings['product-hot-label'] ) && $porto_settings['product-hot-label'] ) ? esc_html( $porto_settings['product-hot-label'] ) : __( 'Hot', 'porto' ) ) . '</div>';
$labels .= $hot_html;
}
}
if ( $porto_settings['product-sale'] ) {
if ( $product->is_on_sale() ) {
$percentage = 0;
if ( $product->get_regular_price() ) {
$percentage = - round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
} elseif ( 'variable' == $product->get_type() && $product->get_variation_regular_price() ) {
$percentage = - round( ( ( $product->get_variation_regular_price() - $product->get_variation_sale_price() ) / $product->get_variation_regular_price() ) * 100 );
}
if ( $porto_settings['product-sale-percent'] && $percentage ) {
$sales_html = '<div class="onsale">' . $percentage . '%</div>';
} else {
$sales_html = apply_filters( 'woocommerce_sale_flash', '<div class="onsale">' . ( ( isset( $porto_settings['product-sale-label'] ) && $porto_settings['product-sale-label'] ) ? esc_html( $porto_settings['product-sale-label'] ) : esc_html__( 'Sale', 'porto' ) ) . '</div>', $post, $product );
}
$labels .= $sales_html;
}
}if ( $labels ) {
echo '<div class="labels">' . porto_filter_output( $labels ) . '</div>';
}$availability = $product->get_availability();
if ( 'out-of-stock' == $availability['class'] ) {
if ( $porto_settings['product-stock'] ) {
echo apply_filters( 'woocommerce_stock_html', '<div class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</div>', $availability['availability'] );
}
} else {
if ( '2' != $porto_settings['add-to-cart-notification'] ) {
echo '<div data-link="' . esc_url( get_permalink( wc_get_page_id( 'cart' ) ) ) . '" class="viewcart' . ' viewcart-' . $product->get_id() . '" title="' . esc_attr__( 'View Cart', 'porto' ) . '"></div>';
}
}
Quote from Pablo Borysenco on August 31, 2020, 09:29Нello
Please add FTP access I will check/fix it
Нello
Please add FTP access I will check/fix it
Quote from Cyberwolf on August 31, 2020, 17:01Hi Pablo, please find FTP info in private data for this topic
Hi Pablo, please find FTP info in private data for this topic
Quote from Pablo Borysenco on September 1, 2020, 11:49Hello
Please do test
Hello
Please do test
Quote from Cyberwolf on September 1, 2020, 18:36Yes, "discount percentage" on home page and archives is working now. What change did you make for it to work?
I see still however, when opening a discounted product, a green box with NAN% is still displayed on top of main product image. If I turn it back to Canadian dollars it shows "SALE" in the green box. I don't know if this is in the same woocommerce sales flash file though
Yes,"discount percentage" on home page and archives is working now. What change did you make for it to work?
I see still however, when opening a discounted product, a green box with NAN% is still displayed on top of main product image. If I turn it back to Canadian dollars it shows"SALE" in the green box. I don't know if this is in the same woocommerce sales flash file though
Quote from Pablo Borysenco on September 2, 2020, 09:13Hello
I will check it today
Hello
I will check it today
Quote from Pablo Borysenco on September 3, 2020, 14:39Hello
https://c2n.me/48Xxdr5.png - Unfortunately I can not check your site
Hello
https://c2n.me/48Xxdr5.png - Unfortunately I can not check your site
Quote from Cyberwolf on September 6, 2020, 21:23Sorry, my Wordpress SEO plugin was out of date and made a fatal error, thats why we couldnt enter the site. Anyways, I looked at the code that you added and made the same changes to the sale-flash.php for single-product pages and now that page seems to be working too. Thank you so much Pablo for your amazing support!
I am guessing that this is your updated code?
$percentage = 0;
$reg_p=floatval($product->get_regular_price());
if ( $reg_p ) {
$percentage = - round( ( ( $reg_p - $product->get_sale_price() ) / $reg_p ) * 100 );
} elseif ( 'variable' == $product->get_type() && $product->get_variation_regular_price() ) {
$percentage = - round( ( ( $product->get_variation_regular_price() - $product->get_variation_sale_price() ) / $product->get_variation_regular_price() ) * 100 );
}
Sorry, my Wordpress SEO plugin was out of date and made a fatal error, thats why we couldnt enter the site. Anyways, I looked at the code that you added and made the same changes to the sale-flash.php for single-product pages and now that page seems to be working too. Thank you so much Pablo for your amazing support!
I am guessing that this is your updated code?
$percentage = 0;
$reg_p=floatval($product->get_regular_price());
if ( $reg_p ) {
$percentage = - round( ( ( $reg_p - $product->get_sale_price() ) / $reg_p ) * 100 );
} elseif ( 'variable' == $product->get_type() && $product->get_variation_regular_price() ) {
$percentage = - round( ( ( $product->get_variation_regular_price() - $product->get_variation_sale_price() ) / $product->get_variation_regular_price() ) * 100 );
}
Quote from Pablo Borysenco on September 7, 2020, 15:28Hello
I am guessing that this is your updated code? - Yes! correct!
Welcome and thank you;)
Hello
I am guessing that this is your updated code? - Yes! correct!
Welcome and thank you;)