Automattic\WooCommerce\Blocks\BlockTypes
PaymentMethodIcons::render_payment_method_icons
Render payment method icons.
Method of the class: PaymentMethodIcons{}
No Hooks.
Returns
String. Rendered block type output.
Usage
// private - for code of main (parent) class only $result = $this->render_payment_method_icons( $attributes );
- $attributes(array) (required)
- Block attributes.
PaymentMethodIcons::render_payment_method_icons() PaymentMethodIcons::render payment method icons code WC 10.3.6
private function render_payment_method_icons( $attributes ) {
$output = '';
$all_payment_methods = $this->get_available_payment_methods();
$number_of_icons = $attributes['numberOfIcons'] ?? 0;
if ( 0 === $number_of_icons ) {
$number_of_icons = count( $all_payment_methods );
} else {
$number_of_icons = max( 0, min( intval( $number_of_icons ), count( $all_payment_methods ) ) );
}
if ( ! empty( $all_payment_methods ) ) {
for ( $i = 0; $i < $number_of_icons; $i++ ) {
$payment_method = $all_payment_methods[ $i ];
$output .= '<div class="wc-block-payment-method-icons__item">';
$output .= '<span class="wc-block-payment-method-icons__icon" style="background-image: url(\'' . \esc_url( $payment_method['icon'] ) . '\');" role="img" aria-label="' . \esc_attr( $payment_method['name'] ) . '"></span>';
$output .= '</div>';
}
}
return $output;
}