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.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Blocks / BlockTypes / PaymentMethodIcons.php
woocommerce / src / Blocks / BlockTypes Last commit date
Accordion 1 year ago AddToCartWithOptions 1 week ago OrderConfirmation 2 months ago ProductCollection 3 weeks ago Reviews 2 months ago AbstractBlock.php 4 weeks ago AbstractDynamicBlock.php 2 years ago AbstractInnerBlock.php 1 year ago AbstractProductGrid.php 3 months ago ActiveFilters.php 2 years ago AddToCartForm.php 4 weeks ago AddToWishlistButton.php 4 weeks ago AllProducts.php 2 years ago AllReviews.php 2 years ago AtomicBlock.php 2 years ago AttributeFilter.php 1 year ago Breadcrumbs.php 1 year ago Cart.php 2 months ago CartAcceptedPaymentMethodsBlock.php 2 years ago CartCrossSellsBlock.php 2 years ago CartCrossSellsProductsBlock.php 2 years ago CartExpressPaymentBlock.php 1 year ago CartItemsBlock.php 2 years ago CartLineItemsBlock.php 2 years ago CartLink.php 2 months ago CartOrderSummaryBlock.php 2 years ago CartOrderSummaryCouponFormBlock.php 2 years ago CartOrderSummaryDiscountBlock.php 2 years ago CartOrderSummaryFeeBlock.php 2 years ago CartOrderSummaryHeadingBlock.php 2 years ago CartOrderSummaryShippingBlock.php 2 years ago CartOrderSummarySubtotalBlock.php 2 years ago CartOrderSummaryTaxesBlock.php 2 years ago CartOrderSummaryTotalsBlock.php 2 years ago CartTotalsBlock.php 2 years ago CatalogSorting.php 4 weeks ago CategoryDescription.php 2 months ago CategoryTitle.php 2 months ago Checkout.php 2 months ago CheckoutActionsBlock.php 1 year ago CheckoutAdditionalInformationBlock.php 2 years ago CheckoutBillingAddressBlock.php 2 years ago CheckoutContactInformationBlock.php 2 years ago CheckoutExpressPaymentBlock.php 9 months ago CheckoutFieldsBlock.php 2 years ago CheckoutOrderNoteBlock.php 2 years ago CheckoutOrderSummaryBlock.php 2 years ago CheckoutOrderSummaryCartItemsBlock.php 2 years ago CheckoutOrderSummaryCouponFormBlock.php 2 years ago CheckoutOrderSummaryDiscountBlock.php 2 years ago CheckoutOrderSummaryFeeBlock.php 2 years ago CheckoutOrderSummaryShippingBlock.php 2 years ago CheckoutOrderSummarySubtotalBlock.php 2 years ago CheckoutOrderSummaryTaxesBlock.php 2 years ago CheckoutOrderSummaryTotalsBlock.php 2 years ago CheckoutPaymentBlock.php 2 years ago CheckoutPickupOptionsBlock.php 2 years ago CheckoutShippingAddressBlock.php 2 years ago CheckoutShippingMethodBlock.php 2 years ago CheckoutShippingMethodsBlock.php 2 years ago CheckoutTermsBlock.php 2 years ago CheckoutTotalsBlock.php 2 years ago ClassicShortcode.php 1 year ago ClassicTemplate.php 4 months ago ComingSoon.php 1 year ago CouponCode.php 2 months ago CustomerAccount.php 3 months ago Dropdown.php 4 weeks ago EmailContent.php 5 months ago EmptyCartBlock.php 2 years ago EmptyMiniCartContentsBlock.php 11 months ago EnableBlockJsonAssetsTrait.php 1 year ago FeaturedCategory.php 7 months ago FeaturedItem.php 7 months ago FeaturedProduct.php 7 months ago FilledCartBlock.php 2 years ago FilledMiniCartContentsBlock.php 4 months ago FilterWrapper.php 2 years ago HandpickedProducts.php 1 year ago MiniCart.php 4 weeks ago MiniCartCartButtonBlock.php 11 months ago MiniCartCheckoutButtonBlock.php 11 months ago MiniCartContents.php 3 months ago MiniCartFooterBlock.php 4 weeks ago MiniCartItemsBlock.php 11 months ago MiniCartProductsTableBlock.php 4 weeks ago MiniCartShoppingButtonBlock.php 9 months ago MiniCartTitleBlock.php 11 months ago MiniCartTitleItemsCounterBlock.php 11 months ago MiniCartTitleLabelBlock.php 11 months ago NextPreviousButtons.php 5 months ago PageContentWrapper.php 2 years ago PaymentMethodIcons.php 11 months ago PriceFilter.php 1 year ago ProceedToCheckoutBlock.php 2 years ago ProductAverageRating.php 1 year ago ProductBestSellers.php 2 years ago ProductButton.php 2 months ago ProductCategories.php 4 weeks ago ProductCategory.php 2 years ago ProductDescription.php 9 months ago ProductDetails.php 5 months ago ProductFilterActive.php 4 weeks ago ProductFilterAttribute.php 4 weeks ago ProductFilterCheckboxList.php 4 weeks ago ProductFilterChips.php 4 weeks ago ProductFilterClearButton.php 4 weeks ago ProductFilterPrice.php 4 weeks ago ProductFilterPriceSlider.php 4 weeks ago ProductFilterRating.php 4 weeks ago ProductFilterRemovableChips.php 4 weeks ago ProductFilterStatus.php 4 weeks ago ProductFilterTaxonomy.php 4 weeks ago ProductFilters.php 3 weeks ago ProductGallery.php 4 weeks ago ProductGalleryLargeImage.php 4 weeks ago ProductGalleryThumbnails.php 4 weeks ago ProductImage.php 4 weeks ago ProductImageGallery.php 7 months ago ProductMeta.php 1 year ago ProductNew.php 2 years ago ProductOnSale.php 2 years ago ProductPrice.php 2 months ago ProductQuery.php 4 weeks ago ProductRating.php 1 year ago ProductRatingCounter.php 1 year ago ProductRatingStars.php 1 year ago ProductResultsCount.php 2 months ago ProductSKU.php 2 months ago ProductSaleBadge.php 1 year ago ProductSearch.php 10 months ago ProductSpecifications.php 2 months ago ProductStockIndicator.php 2 months ago ProductSummary.php 7 months ago ProductTag.php 2 years ago ProductTemplate.php 2 months ago ProductTitle.php 1 year ago ProductTopRated.php 2 years ago ProductsByAttribute.php 2 years ago RatingFilter.php 2 years ago RelatedProducts.php 3 months ago ReviewsByCategory.php 2 years ago ReviewsByProduct.php 2 years ago SavedForLater.php 4 weeks ago SingleProduct.php 2 months ago StockFilter.php 2 years ago StoreNotices.php 1 year ago Wishlist.php 4 weeks ago
PaymentMethodIcons.php
227 lines
1 <?php
2 declare( strict_types = 1 );
3
4 namespace Automattic\WooCommerce\Blocks\BlockTypes;
5
6 use WP_Block;
7 use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils;
8
9 /**
10 * PaymentMethodIcons class.
11 */
12 class PaymentMethodIcons extends AbstractBlock {
13 /**
14 * Block name.
15 *
16 * @var string
17 */
18 protected $block_name = 'payment-method-icons';
19
20 /**
21 * Get the frontend script handle for this block type.
22 *
23 * @param string $key Data to get, or default to everything.
24 * @return array|string
25 */
26 protected function get_block_type_script( $key = null ) {
27 return null;
28 }
29
30 /**
31 * Get the frontend style handle for this block type.
32 *
33 * @return string[]
34 */
35 protected function get_block_type_style() {
36 return array_merge( parent::get_block_type_style(), [ 'wc-blocks-packages-style' ] );
37 }
38
39 /**
40 * Extra data passed through from server to client for block.
41 *
42 * @param array $attributes Any attributes that currently are available from the block.
43 */
44 protected function enqueue_data( array $attributes = [] ) {
45 parent::enqueue_data( $attributes );
46 $this->asset_data_registry->add( 'availablePaymentMethods', $this->get_available_payment_methods() );
47 }
48
49 /**
50 * Render the block.
51 *
52 * @param array $attributes Block attributes.
53 * @param string $content Block content.
54 * @param WP_Block $block Block instance.
55 * @return string Rendered block type output.
56 */
57 protected function render( $attributes, $content, $block ) {
58 $payment_methods = $this->get_available_payment_methods();
59
60 if ( empty( $payment_methods ) ) {
61 return '';
62 }
63
64 $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
65 $wrapper_attributes = get_block_wrapper_attributes(
66 array(
67 'class' => esc_attr( $classes_and_styles['classes'] ),
68 'style' => esc_attr( $classes_and_styles['styles'] ),
69 )
70 );
71
72 $output = '<div ' . $wrapper_attributes . '>';
73 $output .= '<div class="wc-block-payment-method-icons">';
74 $output .= $this->render_payment_method_icons( $attributes );
75 $output .= '</div>';
76 $output .= '</div>';
77
78 return $output;
79 }
80
81 /**
82 * Render payment method icons.
83 *
84 * @param array $attributes Block attributes.
85 * @return string Rendered block type output.
86 */
87 private function render_payment_method_icons( $attributes ) {
88 $output = '';
89
90 $all_payment_methods = $this->get_available_payment_methods();
91 $number_of_icons = $attributes['numberOfIcons'] ?? 0;
92
93 if ( 0 === $number_of_icons ) {
94 $number_of_icons = count( $all_payment_methods );
95 } else {
96 $number_of_icons = max( 0, min( intval( $number_of_icons ), count( $all_payment_methods ) ) );
97 }
98
99 if ( ! empty( $all_payment_methods ) ) {
100 for ( $i = 0; $i < $number_of_icons; $i++ ) {
101 $payment_method = $all_payment_methods[ $i ];
102 $output .= '<div class="wc-block-payment-method-icons__item">';
103 $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>';
104 $output .= '</div>';
105 }
106 }
107
108 return $output;
109 }
110
111 /**
112 * Check if WooPayments is enabled.
113 *
114 * @return bool WooPayments enabled.
115 */
116 private function is_woopayments_enabled() {
117 $payment_gateways = WC()->payment_gateways->get_available_payment_gateways();
118
119 return isset( $payment_gateways['woocommerce_payments'] ) && 'yes' === $payment_gateways['woocommerce_payments']->enabled;
120 }
121
122 /**
123 * Get the enabled card types for WooPayments.
124 *
125 * Note: This uses hardcoded cards based on the default card types provided by WooPayments. This should be updated when these icons can be accessed via an API.
126 *
127 * @return array Enabled card types.
128 */
129 private function get_enabled_card_types() {
130 if ( ! $this->is_woopayments_enabled() ) {
131 return array();
132 }
133
134 $card_types = array(
135 'visa' => array(
136 'name' => 'Visa',
137 'icon' => $this->get_card_type_icon_url( 'visa' ),
138 ),
139 'mastercard' => array(
140 'name' => 'Mastercard',
141 'icon' => $this->get_card_type_icon_url( 'mastercard' ),
142 ),
143 'amex' => array(
144 'name' => 'American Express',
145 'icon' => $this->get_card_type_icon_url( 'amex' ),
146 ),
147 'discover' => array(
148 'name' => 'Discover',
149 'icon' => $this->get_card_type_icon_url( 'discover' ),
150 ),
151 'jcb' => array(
152 'name' => 'JCB',
153 'icon' => $this->get_card_type_icon_url( 'jcb' ),
154 ),
155 );
156
157 return $card_types;
158 }
159
160 /**
161 * Get the card type icon URL.
162 *
163 * @param string $card_type Card type.
164 * @return string Card type icon URL.
165 */
166 private function get_card_type_icon_url( $card_type ) {
167 $assets_path = 'assets/images/payment-methods-cards/';
168 $icon_path = WC_ABSPATH . $assets_path . $card_type . '.svg';
169 $icon_url = \plugins_url( $assets_path . $card_type . '.svg', WC_PLUGIN_FILE );
170
171 return file_exists( $icon_path ) ? $icon_url : '';
172 }
173
174 /**
175 * Get other payment method icons from available gateways.
176 *
177 * @return array Other payment method icons.
178 */
179 private function get_other_payment_method_icons() {
180 $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
181 $other_payment_methods = array();
182
183 if ( empty( $available_gateways ) ) {
184 return $other_payment_methods;
185 }
186
187 foreach ( $available_gateways as $gateway ) {
188 if ( 'yes' === $gateway->enabled ) {
189 if ( 'woocommerce_payments' === $gateway->id ) {
190 continue;
191 }
192
193 $icon_url = '';
194 if ( is_callable( array( $gateway, 'get_icon_url' ) ) ) {
195 $icon_url = $gateway->get_icon_url();
196 }
197 if ( ! empty( $icon_url ) ) {
198 $other_payment_methods[] = array(
199 'name' => $gateway->get_title(),
200 'icon' => $icon_url,
201 );
202 }
203 }
204 }
205
206 usort(
207 $other_payment_methods,
208 function ( $a, $b ) {
209 return strcmp( $a['name'], $b['name'] );
210 }
211 );
212
213 return $other_payment_methods;
214 }
215
216 /**
217 * Get the available payment methods.
218 *
219 * @return array Available payment methods.
220 */
221 private function get_available_payment_methods() {
222 $enabled_cards = array_values( $this->get_enabled_card_types() );
223 $payment_methods = array_merge( $enabled_cards, $this->get_other_payment_method_icons() );
224 return $payment_methods;
225 }
226 }
227