javascript - 使用 API 使用 javascript 转换货币
问题描述
我在 Wordpress 中构建了页面,并且在页面中有一个产品循环,它有多个值和
这是php循环:
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' =>'product',
'posts_per_page' => 24,
'publish_status' => 'published',
'paged' => $paged,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="col3">
<div class="post">
<div class="featured">
<?php the_post_thumbnail(); ?>
</div>
<div class="title">
<a href="<?php the_permalink(); ?>"
><h3>
<?php the_title(); ?>
</h3></a
>
</div>
<div class="categories">
<?php echo get_the_term_list( $post->ID, 'products_cat', '<span> ', ', ', '</span> ' ); ?>
</div>
<?php if( get_field('brand') ): ?>
<div class="brand">
<span>Brand: <?php the_field('brand'); ?></span>
</div>
<?php endif; ?>
<?php if( get_field('modal') ): ?>
<div class="modal">Model: <span><?php the_field('modal'); ?></span></div>
<?php endif; ?>
<?php
if(have_rows('price') ):
while (have_rows('price') ) : the_row();
$flag = get_sub_field('flag');
?>
<div class="prices">
<h4><?php the_sub_field('title'); ?></h4>
<?php
if(have_rows('prices') ):
while (have_rows('prices') ) : the_row();
$flag = get_sub_field('flag');
?>
<div class="details">
<div class="img"><img src="<?php switch($flag) {
case 'Canada':
echo 'https://themoneysaver.co/wp-content/uploads/2021/03/canada-png.png';
break;
case 'Italy':
echo 'https://themoneysaver.co/wp-content/uploads/2021/03/1280px-Flag_of_Italy.svg.png';
break;
case 'France':
echo 'https://themoneysaver.co/wp-content/uploads/2021/03/1500px-Flag_of_France.svg.png';
break;
case 'United Kingdom':
echo 'https://themoneysaver.co/wp-content/uploads/2021/03/640px-Flag_of_the_United_Kingdom.svg.png';
break;
case 'Spain':
echo 'https://themoneysaver.co/wp-content/uploads/2021/03/spain-flag-png-large-1.jpg';
break;
case 'USA':
echo 'https://themoneysaver.co/wp-content/uploads/2021/03/Us_flag_large_38_stars.png';
break;
};?>" alt="" /></div>
<a href="<?php the_sub_field('link'); ?>" target="_blank">
<span class="price"><?php the_sub_field('sign'); ?></span>
<span class="shipping"><?php the_sub_field('original'); ?></span>+
<span><?php the_sub_field('plus'); ?></span>
<?php if( get_sub_field('down') ): ?>
<span class="down"
>(<i class="fas fa-arrow-down"></i> <?php the_sub_field('down'); ?>)</span>
<?php endif; ?>
<span><i class="fas fa-external-link-alt"></i></span>
</a>
</div>
<?php endwhile;
endif;
?>
</div>
<?php endwhile;
endif;
?>
<?php if( get_field('discrption') ): ?>
<div class="discription">
<h4>Description</h4>
<p>
<?php the_field('discrption'); ?>
</p>
</div>
<?php endif; ?>
</div>
</div>
<?php
endwhile;
wp_reset_query();
wp_reset_postdata();
?>
我正在使用ACF来获取额外的字段。我想将其转换为符号 + 价格 + 运费,默认为美元和。我想在 5 个国家/地区进行转换
解决方案
推荐阅读
- database - 用于在 GB 规模(流式和静态)数据集上查询和警报的技术堆栈
- python - 如何生成 N 个整数(比如 365),总和为某个值 K(比如 20)?
- python - python 浮点数列表,总和为 1.0,但 (sum(list) == 1.0) 给出 False。为什么?
- ios - 控制缩放行为 ARKit
- java - IntelliJ 说它无法解析 getValue()
- javascript - 如何按最后一个空值的多个日期时间属性排序?
- python-3.7 - 未检测到我的变量中的数字
- php - 如何在linux ubuntu上服务器离线时安装php5-ldap扩展
- c# - C#如果x = 1,如何选择按钮(X)然后它继续添加?
- c# - 批处理管道在 Azure 数据工厂中不起作用