gpt4 book ai didi

php - 将图标添加到自定义 WooCommerce 支付网关

转载 作者:行者123 更新时间:2023-12-05 08:56:26 29 4
gpt4 key购买 nike

我想为我的支付网关添加一个自定义图标。我已阅读 WOO 网关 API 并获得零帮助。这是我下面的代码。请帮助我找到一种包含图标的功能方法,以便我的前端有一个图标。谢谢

<?php if ( ! defined( 'ABSPATH' ) ) { exit; }

add_filter( 'woocommerce_payment_gateways', 'init_wpuw_gateway' );
function init_wpuw_gateway ( $methods )
{
$methods[] = 'WC_Gateway_WPUW';
return $methods;
}


if( class_exists('WC_Payment_Gateway') ):
class WC_Gateway_WPUW extends WC_Payment_Gateway {

/**
* Constructor for the gateway.
*/
public function __construct() {

$plugin_dir = plugin_dir_url(__FILE__);

$this->id = 'wpuw';

//If you want to show an image next to the gateway’s name on the frontend, enter a URL to an image.
$this->icon = apply_filters( 'woocommerce_gateway_icon', ''.$plugin_dir.'/assets/paysecure.png' );
$this->method_title = __( 'User Wallet', 'woocommerce' );
$this->method_description = __( 'Have your customers pay with their user wallet balance.', 'woocommerce' );
$this->has_fields = false;

最佳答案

尝试使用反斜杠而不是斜杠,而不将初始空字符串与变量 $plugin_dir 连接起来

$this->icon = apply_filters( 'woocommerce_gateway_icon', $plugin_dir.'\assets\paysecure.png' );

关于php - 将图标添加到自定义 WooCommerce 支付网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40723517/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com