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

Up-sell product error

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! I use your plugin. An error occurs while changing the currency on the product page. The price of related products does not change, only the currency. Here is my code in up-sells.php How to correctly call the price here, so that the price also changes?

<?php
/**
* Single Product Up-Sells
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/up-sells.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.0.0
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( $upsells ) : ?>
<div class="product-bottom">
<div class="wrapper">
<div class="contnet">
<div class="head-section">
<h5 class="heading"><?php esc_html_e( 'Вам также понравится', 'woocommerce'); ?></h5>
</div>

<div class="ao-grid">
<?php foreach ( $upsells as $upsell ) : ?>
<?php
global $product;
$post_object = get_post( $upsell->get_id() );

setup_postdata( $GLOBALS['post'] =& $post_object );

$img_url = get_the_post_thumbnail_url( $post_object->ID, 'full' );
$img_url_post = get_the_post_thumbnail_url( $post_object->post_parent, 'full' );

$img_url = !empty($img_url) ? $img_url : $img_url_post;

$new_product_label = get_field('new_product_label', $post_object->ID);
$coming_soon_label = get_field('coming_soon_label', $post_object->ID);
$sold_out_label = get_field('sold_out_product', $post_object->ID);
$sale_p = get_field('sale_product', $post_object->ID);

echo '<div class="item">
<a class="link" href="'.get_post_permalink($post_object->ID).'">

<div class="img-wrap" style="background-image: url('.$img_url.');">
<button class="favorite wishlist-toggle" type="button" data-product="'.esc_attr($product->get_id()).'"><span class="icon-star js-icon-star"></span></button>';
echo '<div class="labels">';
if (!empty($new_product_label)) : echo '<span class="new">new</span>'; endif;

if (!empty($coming_soon_label)) : echo '<span class="soon">coming soon</span>'; endif;

if (!empty($sold_out_label)) : echo '<span class="new">' . __('sold out') . '</span>'; endif;

if (!empty($sale_p)) : echo '<span class="discount"><img src="/wp-content/themes/yuliawave/img/discount.svg"/></span>'; endif;
echo '</div></div>

<p class="title">'.get_the_title($post_object->ID).'</p>

<span class="price">'.get_post_meta( $post_object->ID, '_price', true) . sprintf(get_woocommerce_currency_symbol() ) .'</span></a></div>';
?>

<?php endforeach; ?>
</div>
</div>
</div>
</div>

<?php endif;

wp_reset_postdata();

Здравствуйте

Используйте  стандартную   функцию  продукта  ->get_price()

или  если  хотите   использовать  мета  данные   - тогда  конвертируйте  их -  https://currency-switcher.com/function/woocs-woocs_exchange_value/

Не подскажете строчку, которую нужно изменить и как?

Здравствуйте

Эту  строчку - https://c2n.me/48k1gFs.png

Вам  следует  либо конвертировать полученную сумму либо  по ID получить  объект   продукта  и  воспользоваться   методом -  ->get_price() (это  более правильный  вариант)

Если  у  Вас  нет опыта  в  программировании   попросите разработчика  который  создал  для  Вас  этот код