更新时间:2023-12-01 16:58:22
您的问题似乎没有覆盖解决方案.但是你可以添加一个全新的支付网关只需扩展 WC_Payment_Gateway
类,即添加另一个支付网关.
It seems there is no override solution to your question. But you can add a brand new payment gateway
simply extending the WC_Payment_Gateway
class, in other words by adding another payment gateway.
第一步
您可以复制文件:
plugins/woocommerce/includes/gateways/class-wc-gateway-paypal.php
在您的目录主题中,为方便起见更改其名称并将其包含在 functions.php 中:
in your directory theme, change its name for convenience and include it in functions.php:
/* Custom gateway class */
require( get_template_directory() . '/path/to/class-wc-gateway-paypal-custom.php' );
第 2 步
此文件包含扩展 WC_Payment_Gateway
的 WC_Gateway_Paypal
类.您可以编辑此文件以进行自定义.
This file holds the WC_Gateway_Paypal
class which extends WC_Payment_Gateway
. You can edit this file for your customizations.
记得修改扩展类的名字:
Remember to change the name of the extender class:
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
}
尝试一下,如果您遇到困难,请告诉我们!:)
Give it a try, let us know if you get stuck! : )
更新 06/13/2014
UPDATE 06/13/2014
知道有一个过滤器可以让您更改贝宝图片也很有用,所以:
It's also useful to know that there's a filter that allows you to change the paypal image, so:
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' );