PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Wrong regular price when disabling variation

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 please
If 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.

Hello guys,

I'm running this function to display only the highest price on variation:

function wpglorify_variation_price_format( $price, $product ) {

// Main Price
$prices = array( $product->get_variation_price( 'max', true ), $product->get_variation_price( 'min', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

// Sale Price
$prices = array( $product->get_variation_regular_price( 'max', true ), $product->get_variation_regular_price( 'min', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

if ( $price !== $saleprice ) {
$price = '<del>' . $saleprice . $product->get_price_suffix() . '</del> <ins>' . $price . $product->get_price_suffix() . '</ins>';
}
return $price;
}

On base currency everything works well (USD)

But when changing to other currency, regular price (sale price looks correct) is incorrect,

On this pic: https://imgur.com/a/bL3KY2y you can see the price in Mexican Peso which is ridiculously high.

Thanks in advance!

 

Update:

After setting"Is multiple allowed" to"NO" problem solved but I need to be able to checkout with customer currency which i can't with these settings.

BTW I'm using Sober Theme and licensed WOOCS plugin.

 

Regards,

Hello

Paste your license key here - https://c2n.me/43SC6rb.png -> https://c2n.me/42HBIt7.png

Just added requested info

Hello

you need to customize this third party code

Try  to  paste  this  code :

if (class_exists('WOOCS')) {
global $WOOCS;
if ($WOOCS->is_multiple_allowed) {
$currrent = $WOOCS->current_currency;
if ($currrent != $WOOCS->default_currency) {
$currencies = $WOOCS->get_currencies();
$rate = $currencies[$currrent]['rate'];
$prices[0] = $prices[0]/ $rate;
}
}
}

Paste  here - https://c2n.me/4ashg5q.png

Still same... This is how code look inside functions.php, maybe I didn't paste is correctly...

function wpglorify_variation_price_format( $price, $product ) {

// Main Price
$prices = array( $product->get_variation_price( 'max', true ), $product->get_variation_price( 'min', true ) );
if (class_exists('WOOCS')) {
global $WOOCS;
if ($WOOCS->is_multiple_allowed) {
$currrent = $WOOCS->current_currency;
if ($currrent != $WOOCS->default_currency) {
$currencies = $WOOCS->get_currencies();
$rate = $currencies[$currrent]['rate'];
$prices[0] = $prices[0]/ $rate;
}
}
}
$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

// Sale Price
$prices = array( $product->get_variation_regular_price( 'max', true ), $product->get_variation_regular_price( 'min', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

if ( $price !== $saleprice ) {
$price = '<del>' . $saleprice . $product->get_price_suffix() . '</del> <ins>' . $price . $product->get_price_suffix() . '</ins>';
}
return $price;
}

Hello

Ok!  Try to  add  the same  code  here - https://c2n.me/4asRRDH.png

Now its giving wrong price (wrong conversion)

Final price is OK - Regular price when there is a Sale price becoming akward.

Please advise.

Hello

Please  drop  me  wp-admin + FTP access - https://c2n.me/43SC6rb.png ->https://c2n.me/42BAoj4.png