问题描述
我已使用此代码成功重命名了我的 woocommerce 结帐页面的“shipping_country”标签:
add_filter( 'woocommerce_checkout_fields','rename_woo_checkout_fields' );
function rename_woo_checkout_fields( $fields ) {
$fields['shipping']['shipping_country']['label'] = 'Country';
return $fields;
}
但是当我尝试添加要更改的其他标签和占位符时,它不起作用。好吧,实际上发生了一些奇怪的事情。当我刷新页面以应用更改时,它似乎工作,但页面仍在加载,一秒钟后,恢复到原来的状态。 (shipping_country 字段仍然有效,但我在上面添加的所有其他字段都会发生。
我尝试更改顺序,但没关系。
我试图更改但不起作用的字段是:
$fields['billing']['billing_address_1']['label'] = 'Address';
$fields['billing']['billing_address_1']['placeholder'] = 'Street and house number';
$fields['billing']['billing_city']['label'] = 'City';
$fields['billing']['billing_postcode']['label'] = 'Postcode';
$fields['shipping']['shipping_postcode']['label'] = 'Postcode';
$fields['shipping']['shipping_city']['label'] = 'City';
$fields['shipping']['shipping_city']['placeholder'] = 'City';
$fields['shipping']['shipping_address_1']['label'] = 'Address';
$fields['shipping']['shipping_address_1']['placeholder'] = 'Street and house number';
$fields['order']['order_comments']['placeholder'] = 'Special notes';
解决方法
请尝试以下操作:
import numpy as np
windowSize = 4
features = np.array(
[[ 1,2],[ 3,4],[ 5,6],[ 7,8],[ 9,10],[11,12],[13,14],[15,16],[17,18],[19,20]]
)
indices = np.add.outer(np.arange(len(features) - windowSize + 1),np.arange(windowSize))
# indices:
# [[0 1 2 3]
# [1 2 3 4]
# [2 3 4 5]
# [3 4 5 6]
# [4 5 6 7]
# [5 6 7 8]
# [6 7 8 9]]
features[indices] # indices must be of type np.ndarray or this won't work
# features[indices]:
# [[[ 1 2]
# [ 3 4]
# [ 5 6]
# [ 7 8]]
# [[ 3 4]
# [ 5 6]
# [ 7 8]
# [ 9 10]]
# [[ 5 6]
# [ 7 8]
# [ 9 10]
# [11 12]]
# [[ 7 8]
# [ 9 10]
# [11 12]
# [13 14]]
# [[ 9 10]
# [11 12]
# [13 14]
# [15 16]]
# [[11 12]
# [13 14]
# [15 16]
# [17 18]]
# [[13 14]
# [15 16]
# [17 18]
# [19 20]]]
代码位于活动子主题(或活动主题)的functions.php 文件中。在最新的 WooCommerce 版本 (5.0.0) 上测试并运行。