我已经更改了eBay付款网关文件,因为我想更改PayPal按钮文本以表示其他内容。我认为这是最好的解决方案,因为我不熟悉自己的钩子/过滤器。
我已经检查了此修改后的模板文件的工作原理-确实可以。但是,当我将其加载到主题文件时,它不会被覆盖。
我试过了:
这些工作都没有...任何人都可以帮我吗?
提前致谢 :-)
似乎您的问题没有替代解决方案。但是您可以添加一个简单的扩展WC_Payment_Gateway
类的新的支付网关,换句话说,通过添加另一个支付网关。
步骤1
您可以复制文件:
plugins/woocommerce/includes/gateways/class-wc-gateway-paypal.php
在目录主题中,为了方便起见更改名称,并将其包含在functions.php中:
/* Custom gateway class */
require( get_template_directory() . '/path/to/class-wc-gateway-paypal-custom.php' );
第2步
该文件包含WC_Gateway_Paypal
扩展类WC_Payment_Gateway
。您可以编辑此文件以进行自定义。
切记更改扩展器类的名称:
class WC_Gateway_Paypal_Custom extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'paypal';
$this->icon = apply_filters( 'woocommerce_paypal_icon', WC()->plugin_url() . '/assets/images/icons/paypal.png' );
$this->has_fields = false;
// Change the text in the way you like it
$this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' );
$this->liveurl = 'https://www.paypal.com/cgi-bin/webscr';
$this->testurl = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$this->method_title = __( 'PayPal', 'woocommerce' );
$this->notify_url = WC()->api_request_url( 'WC_Gateway_Paypal' );
}
//other payment gateway stuff
}
试试看,让我们知道您是否卡住了!:)
更新06/13/2014
知道有一个允许您更改贝宝图像的过滤器也很有用,因此:
function paypal_checkout_icon() {
// pls return the new logo/image URL here
return 'http://www.url.to/your/new/logo.png';
}
add_filter( 'woocommerce_paypal_icon', 'paypal_checkout_icon' );
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句