如何添加与保存在 WooCommerce 用户帐户中的每种付款方式对应的图标?
How can I add the icon corresponding to each payment method that is saved in a WooCommerce user's account?
我正在寻找已保存的支付方式部分,以包含用户使用的每张卡(Visa、万事达卡、美国运通卡)的图标,我如何将其添加到 WooCommerce?
当前支付方式部分:
enter image description here
最终想法:
enter image description here
add_action('woocommerce_account_payment_methods_column_method', 'woocommerce_account_payment_methods_column_data', 10, 1);
function woocommerce_account_payment_methods_column_data($method) {
if (!empty($method['method']['brand'])) {
$card = strtolower($method['method']['brand']);
$card_url = "https://woocommerce.com/wp-content/plugins/woocommerce-payments/assets/images/cards/$card.svg";
}
if (!empty($method['method']['last4']) && isset($card_url)) {
/* translators: 1: credit card type 2: last 4 digits */
echo '<span><p style="float:left;margin-right:5px;"><img height="40px" width="40px;" src=' . $card_url . ' /></p><p style="float:left">' . sprintf(esc_html__('%1$s ending in %2$s', 'woocommerce'), esc_html(wc_get_credit_card_type_label($method['method']['brand'])), esc_html($method['method']['last4'])) . "</p></span>";
} else {
echo esc_html(wc_get_credit_card_type_label($method['method']['brand']));
}
}
我正在寻找已保存的支付方式部分,以包含用户使用的每张卡(Visa、万事达卡、美国运通卡)的图标,我如何将其添加到 WooCommerce?
当前支付方式部分:
enter image description here
最终想法:
enter image description here
add_action('woocommerce_account_payment_methods_column_method', 'woocommerce_account_payment_methods_column_data', 10, 1);
function woocommerce_account_payment_methods_column_data($method) {
if (!empty($method['method']['brand'])) {
$card = strtolower($method['method']['brand']);
$card_url = "https://woocommerce.com/wp-content/plugins/woocommerce-payments/assets/images/cards/$card.svg";
}
if (!empty($method['method']['last4']) && isset($card_url)) {
/* translators: 1: credit card type 2: last 4 digits */
echo '<span><p style="float:left;margin-right:5px;"><img height="40px" width="40px;" src=' . $card_url . ' /></p><p style="float:left">' . sprintf(esc_html__('%1$s ending in %2$s', 'woocommerce'), esc_html(wc_get_credit_card_type_label($method['method']['brand'])), esc_html($method['method']['last4'])) . "</p></span>";
} else {
echo esc_html(wc_get_credit_card_type_label($method['method']['brand']));
}
}