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

标签 php wordpress woocommerce hook-woocommerce

我想为我的支付网关添加一个自定义图标。我已阅读 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/

相关文章:

wordpress - 如何将 WordPress 自动更新与 Git 作为版本控制相结合?

node.js - 集成 NodeJS 和 Wordpress

php - 仅显示产品分类的第一个和最后一个术语

php - WooCommerce csv 导入自定义字段 - 调整内置导入器以包含自定义字段?

php - 如何一次运行一个查询?

php - php系统中的python命令()

php - 使用 php 在 head 标签内设置一个 css 属性

php - header 重定向是否在不同的浏览器中产生不同的行为

mysql - 本地 WordPress 安装 - wp-admin 错误

php - 如何从 Woocommerce 产品小部件中删除要点