php-Woocommerce BACS付款网关帐户详细信息修改
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-Woocommerce BACS付款网关帐户详细信息修改,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3347字,纯文字阅读大概需要5分钟。
内容图文
![php-Woocommerce BACS付款网关帐户详细信息修改](/upload/InfoBanner/zyjiaocheng/665/d6b8fd69609943ce9fa49999a5118572.jpg)
我想知道是否可以像mytheme / includes / bacs / class-wc-gateway-bacs.php中的模板文件一样更改woocommerce / includes / bacs / class-wc-gateway-bacs.php吗?目前,我更改了插件核心中的代码,但更新后它将再次更改.
或者,也许有人知道如何在具有钩子之类的function.php文件中执行此操作?
我需要更改此功能:
/**
* Get bank details and place into a list format.
*
* @param int $order_id
*/
private function bank_details( $order_id = '' ) {
if ( empty( $this->account_details ) ) {
return;
}
// Get order and store in $order
$order = wc_get_order( $order_id );
// Get the order country and country $locale
$country = $order->billing_country;
$locale = $this->get_country_locale();
// Get sortcode label in the $locale array and use appropriate one
$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort Code', 'woocommerce' );
$bacs_accounts = apply_filters( 'woocommerce_bacs_accounts', $this->account_details );
if ( ! empty( $bacs_accounts ) ) {
echo '<h2 class="wc-bacs-bank-details-heading">' . __( 'Our Bank Details', 'woocommerce' ) . '</h2>' . PHP_EOL;
foreach ( $bacs_accounts as $bacs_account ) {
$bacs_account = (object) $bacs_account;
if ( $bacs_account->account_name || $bacs_account->bank_name ) {
echo '<h3>' . wp_unslash( implode( ' - ', array_filter( array( $bacs_account->account_name, $bacs_account->bank_name ) ) ) ) . '</h3>' . PHP_EOL;
}
echo '<ul class="wc-bacs-bank-details order_details bacs_details">' . PHP_EOL;
// BACS account fields shown on the thanks page and in emails
$account_fields = apply_filters( 'woocommerce_bacs_account_fields', array(
'account_number'=> array(
'label' => __( 'Account Number', 'woocommerce' ),
'value' => $bacs_account->account_number
),
'sort_code' => array(
'label' => $sortcode,
'value' => $bacs_account->sort_code
),
'iban' => array(
'label' => __( 'IBAN', 'woocommerce' ),
'value' => $bacs_account->iban
),
'bic' => array(
'label' => __( 'BIC', 'woocommerce' ),
'value' => $bacs_account->bic
)
), $order_id );
foreach ( $account_fields as $field_key => $field ) {
if ( ! empty( $field['value'] ) ) {
echo '<li class="' . esc_attr( $field_key ) . '">' . esc_attr( $field['label'] ) . ': <strong>' . wptexturize( $field['value'] ) . '</strong></li>' . PHP_EOL;
}
}
echo '</ul>';
}
}
}
我真的需要帮助,在此先谢谢您:)
解决方法:
问题解决了:
我刚刚创建了额外的文件filename.php,插入了默认的woocommerce / includes / bacs / class-wc-gateway-bacs.php代码,并更改了$this-> id =’bacs’;到$this-> id =’YOUR ID NAME’;并将所有带有“ bacs”的变量更改为“ YOUR ID NAME”.该文件进入plugins文件夹并在wordpress中激活它:)
Full code example fiddle(sorry for jsfiddle)
<?php
/*
Plugin Name: Custom Payment Gateway
Description: Custom payment gateway
Author: Baivaras
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Custom Payment Gateway.
*
* Provides a Custom Payment Gateway, mainly for testing purposes.
*/
add_action('plugins_loaded', 'init_custom_gateway_class');
function init_custom_gateway_class(){
class WC_Gateway_Custom extends WC_Payment_Gateway {
public $domain;
/* class-wc-gateway-bacs.php from public function __construct CODE GOES HERE */
}
}
add_filter( 'woocommerce_payment_gateways', 'add_custom_gateway_class' );
function add_custom_gateway_class( $methods ) {
$methods[] = 'WC_Gateway_Custom';
return $methods;
}
如果有什么问题对不起我的英语:)
内容总结
以上是互联网集市为您收集整理的php-Woocommerce BACS付款网关帐户详细信息修改全部内容,希望文章能够帮你解决php-Woocommerce BACS付款网关帐户详细信息修改所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。