在woocommerce中实现不受支持的Paypal货币的最佳方法 [英] Best way to implement unsupported paypal currency into woocommerce

查看:385
本文介绍了在woocommerce中实现不受支持的Paypal货币的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个网上商店,并且正在使用woocommerce.问题如下:

I'm making a webshop and I'm using woocommerce. The problem is following:

我的客户现在只想在克罗地亚销售商品,这意味着我必须在库纳斯(HRK)中显示价格...

My customer wants to sell only in Croatia, for now which means I have to display price in Kunas (HRK)...

我有用于woocommerce的PayPal网关,并且已通过使用以下代码将克罗地亚语Kuna实施到woocommerce系统中(我仅将其发布以进行完整描述):

I have PayPal gateway for woocommerce, and I have implemented Croatian Kuna into woocommerce system by using following code (I'm only posting this to make full description):

<?php
// Add currency / symbol
add_filter( 'woocommerce_currencies', 'add_rand_currency' );
add_filter( 'woocommerce_currency_symbol', 'add_rand_currency_symbol' );

function add_rand_currency( $currencies ) {
    $currencies['HRK'] = __( 'Croatian Kuna (kn)', 'woothemes' );
    return $currencies;
}

function add_rand_currency_symbol( $symbol ) {
    $currency = get_option( 'woocommerce_currency' );
    switch( $currency ) {
        case 'HRK': $symbol = 'kn'; break;
    }
    return $symbol;
}
?>

如果从管理中为我的货币选择了克罗地亚库纳,则PayPal网关说不支持货币.好的,所以我知道我无法以Kunas的价格向客户发送订单,但是我可以以欧元为单位.

If I select Croatian Kuna for my currency from administration, PayPal gateway says currency is not supported. Ok, so I understand I can't send customers order in Kunas but I can do that in Euros for example.

所以这是我的主意,我想听听您对此的看法.

So here's my Idea, and I'd like to hear what you think about it.

我将使用默认货币欧元(这意味着我必须以欧元输入产品价格),并且在前端,我将使用jQuery获得所有价格(用.price css类很好地包装)并将它们重新计算为从欧元到库纳(从视觉上来说),而woocommerce会将结帐的所有产品发送给以欧元付款的朋友.

I'll make my default currency Euros (which means I'll have to enter product prices in euros), and on the front end I'll get all prices (that are nicely wrapped with .price css class) with jQuery and recalculate them to from Euro to Kuna (just visually), while woocommerce will send on checkout all products to pay pal in Euros.

只需补充一点,我正在按时完成任务,这只是剩下要解决的问题,所以这就是我使用JavaScript进行操作的主要原因.如果有更好的消息让我知道,我可能会使用yahoo api进行货币转换.

Just to add, I'm running on deadline and this is only problem left to solve, so this is the main reason why I'm doing it with JavaScript. I'll probably use yahoo api for currency conversion, if there's something better let me know.

推荐答案

前段时间,我在博客中制作了有关此主题的教程.它处理

Some time ago I made a tutorial about this topic in my blog. It deals with

  1. 如何添加新货币;
  2. 货币符号;
  3. 允许Paypal使用您的新货币,并在Paypal付款之前将金额转换为Paypal支持的货币.

http://devseon.com/zh-CN/wordpress-tutorials/woocommerce-add-a-paypal-unsupported-currency/

请检查一下.我想对于当前问题,您只需要本教程的第3部分.但是George是正确的,为了允许Paypal使用新货币,您必须在插件文件中编辑is_valid_for_use()函数: 确切地说,是wp-content/plugins/woocommerce/classes/gateways/paypal/class-wc-paypal.php.我的博客中介绍了付款过滤器之前的货币转换.

Please check it out. I guess that for the current problem you need only part 3 of my tutorial. But George was right that in order to allow Paypal with the new currency you have to edit the is_valid_for_use() function in a plugin file: wp-content/plugins/woocommerce/classes/gateways/paypal/class-wc-paypal.php to be exact. The currency transformation before payment filter is described in my blog.

这篇关于在woocommerce中实现不受支持的Paypal货币的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆