DefaultPromotions.php
1 year ago
Init.php
1 year ago
WCPayPromotionDataSourcePoller.php
1 year ago
WCPaymentGatewayPreInstallWCPayPromotion.php
10 months ago
DefaultPromotions.php
87 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Gets a list of fallback promotions if remote fetching is disabled. |
| 4 | */ |
| 5 | |
| 6 | declare( strict_types = 1 ); |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Internal\Admin\WCPayPromotion; |
| 9 | |
| 10 | use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\DefaultPaymentGateways; |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | /** |
| 15 | * Default Promotions |
| 16 | */ |
| 17 | class DefaultPromotions { |
| 18 | |
| 19 | /** |
| 20 | * Get the specs. |
| 21 | * |
| 22 | * @return array Suggestion specs. |
| 23 | */ |
| 24 | public static function get_all(): array { |
| 25 | return array( |
| 26 | array( |
| 27 | 'id' => 'woocommerce_payments:woopay', |
| 28 | 'title' => __( 'WooPayments', 'woocommerce' ), |
| 29 | 'content' => __( 'Payments made simple — including WooPay, a new express checkout feature.', 'woocommerce' ), |
| 30 | 'image' => plugins_url( 'assets/images/onboarding/wcpay.svg', WC_PLUGIN_FILE ), |
| 31 | 'plugins' => array( 'woocommerce-payments' ), |
| 32 | 'is_visible' => array( |
| 33 | DefaultPaymentGateways::get_rules_for_cbd( false ), |
| 34 | DefaultPaymentGateways::get_rules_for_countries( self::get_woopay_available_countries() ), |
| 35 | ), |
| 36 | 'sub_title' => self::get_wcpay_payment_icons(), |
| 37 | ), |
| 38 | array( |
| 39 | 'id' => 'woocommerce_payments', |
| 40 | 'title' => __( 'WooPayments', 'woocommerce' ), |
| 41 | 'content' => __( 'Payments made simple, with no monthly fees – designed exclusively for WooCommerce stores. Accept credit cards, debit cards, and other popular payment methods.', 'woocommerce' ), |
| 42 | 'image' => plugins_url( 'assets/images/onboarding/wcpay.svg', WC_PLUGIN_FILE ), |
| 43 | 'plugins' => array( 'woocommerce-payments' ), |
| 44 | 'is_visible' => array( |
| 45 | DefaultPaymentGateways::get_rules_for_cbd( false ), |
| 46 | DefaultPaymentGateways::get_rules_for_countries( DefaultPaymentGateways::get_wcpay_countries() ), |
| 47 | ), |
| 48 | 'sub_title' => self::get_wcpay_payment_icons(), |
| 49 | ), |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get the list of WooPay available countries. |
| 55 | * |
| 56 | * @return array The list of WooPay available countries. |
| 57 | */ |
| 58 | private static function get_woopay_available_countries(): array { |
| 59 | return array( 'US' ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Get the list of payment icons as HTML img tags. |
| 64 | * |
| 65 | * @return string Payment icons as HTML img tags. |
| 66 | */ |
| 67 | private static function get_wcpay_payment_icons(): string { |
| 68 | $icons = array( |
| 69 | 'visa', |
| 70 | 'mastercard', |
| 71 | 'amex', |
| 72 | 'googlepay', |
| 73 | 'applepay', |
| 74 | ); |
| 75 | $convert_to_img_tag = function ( $icon ) { |
| 76 | return sprintf( |
| 77 | '<img class="wcpay-%s-icon wcpay-icon" src="%s" alt="%s">', |
| 78 | $icon, |
| 79 | plugins_url( "assets/images/payment-methods/$icon.svg", WC_PLUGIN_FILE ), |
| 80 | ucfirst( $icon ) |
| 81 | ); |
| 82 | }; |
| 83 | |
| 84 | return implode( '', array_map( $convert_to_img_tag, $icons ) ); |
| 85 | } |
| 86 | } |
| 87 |