我想覆盖woocommerce中的一个函数,特别是- woocommerce/includes/wc-cart-functions.php ( wc_cart_totals_order_total_html函数)。
我可以直接编辑函数(它输出需要更改的html ),但我不希望这样做,因为我会在更新时丢失更改。
我相信这是一件很常见的事情,我只是不太确定该怎么做。如果我在我的主题中将函数复制到functions.php,我会得到一个关于重新声明函数的错误。
发布于 2016-06-18 14:17:33
这是一个古老的话题,但也许我能帮上一点忙。我也遇到过类似的问题。我想覆盖货币,并添加自定义货币。这些函数位于woocommerce/includes/wc-core-functions.php中
function get_woocommerce_currencies() {
return array_unique(
apply_filters( 'woocommerce_currencies',
array(另一个函数是:
function get_woocommerce_currency_symbol( $currency = '' ) {
if ( ! $currency ) {
$currency = get_woocommerce_currency();
}
switch ( $currency ) {
...
return apply_filters( 'woocommerce_currency_symbol', $currency_symbol, $currency );这是我放在我的子主题的functions.php中的代码:
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['RSD'] = __( 'Serbian dinar', 'woocommerce' );
return $currencies;
}https://stackoverflow.com/questions/37893861
复制相似问题