nykek5i 发表于 2024-10-5 09:41:22

Wordpress建站教程:修改Woocommerce商店的默认货币符号


    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/a7c6467da9a74777be847f89fdca6d7a~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728302216&amp;x-signature=ZG5Ff9rIwzAfoE%2FyY5A6WwyobB8%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">继续分享wordpress建站教程,今天分享一个woocommerce插件修改默认转向符号的<span style="color: black;">办法</span>。<span style="color: black;">倘若</span>你<span style="color: black;">运用</span>woocommerce建设B2B展示型外贸网站,那<span style="color: black;">通常</span>不会有这个<span style="color: black;">需要</span>,<span style="color: black;">倘若</span>你需要制作B2C<span style="color: black;">或</span>是有支付<span style="color: black;">需要</span>的网站,那就可能会遇到货币符号的问题了,<span style="color: black;">尤其</span>是针对国内用户的<span style="color: black;">运用</span>。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">作者:悦然WordPress建站</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;">(此处已添加小程序,请到今日头条客户端查看)</div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">下面以悦然wordrpess建站<span style="color: black;">近期</span>遇到的一个<span style="color: black;">需要</span>为例,客户<span style="color: black;">运用</span>的是澳门货币,woocommerce默认的货币符号是【P】,而客户想改成【MOP $】。<span style="color: black;">办法</span>有<span style="color: black;">非常多</span>,<span style="color: black;">例如</span><span style="color: black;">运用</span>插件,<span style="color: black;">不外</span>今天<span style="color: black;">咱们</span><span style="color: black;">不消</span>插件,就用下面这段代码号,<span style="color: black;">一样</span><span style="color: black;">亦</span>简单。代码如下:</span></span></p><span style="color: black;">/*
      修改WooCommerce货币符号
      */</span>
    <span style="color: black;"><span style="color: black;">function</span> <span style="color: black;">change_existing_currency_symbol</span><span style="color: black;">( $currency_symbol, $currency )</span> </span>{
    <span style="color: black;">switch</span>( $currency ) {
    <span style="color: black;">case</span> <span style="color: black;">MOP</span>: $currency_symbol =<span style="color: black;">MOP $</span>; <span style="color: black;">break</span>;
    }
    <span style="color: black;">return</span> $currency_symbol;
    }
    add_filter(<span style="color: black;">woocommerce_currency_symbol</span>, <span style="color: black;">change_existing_currency_symbol</span>, <span style="color: black;">10</span>, <span style="color: black;">2</span>);<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">以上代码是以前在大胡子博客看到的,<span style="color: black;">大众</span>在搜索时可能<span style="color: black;">亦</span>看到了类似的代码,但类似教程基本都<span style="color: black;">无</span>讲的很清楚,新手看的不是很明白。</span></span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/ab7995e082d5474cb92da725419b2462~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728302216&amp;x-signature=6JJkLgPmr%2BWCeyxHs3CTPbPho7o%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">这儿</span>我简单说明一下,上面的代码只需要修改红框部分的内容就<span style="color: black;">能够</span>,前面是你所<span style="color: black;">运用</span>的地区货币代码(不清楚的<span style="color: black;">能够</span>百度一下,这个标准是通用的),后面第2个红框中的代码<span style="color: black;">便是</span><span style="color: black;">咱们</span>需要修改成的样式。确定好后把代码放到当前wordpress建站<span style="color: black;">运用</span>的主题function.php文件中<span style="color: black;">就可</span>。</span></span></p>




4zhvml8 发表于 2024-11-11 11:58:59

“NB”(牛×的缩写,表示叹为观止)‌
页: [1]
查看完整版本: Wordpress建站教程:修改Woocommerce商店的默认货币符号