mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
✨ Integrate ACDC icons in AXO gateway
This commit is contained in:
parent
487038c0d3
commit
cbd3fe24e4
3 changed files with 68 additions and 28 deletions
|
@ -76,7 +76,7 @@ return array(
|
|||
$container->get( 'wcgateway.settings' ),
|
||||
$container->get( 'wcgateway.url' ),
|
||||
$container->get( 'wcgateway.order-processor' ),
|
||||
$container->get( 'axo.card_icons' ),
|
||||
$container->get( 'wcgateway.credit-card-icons' ),
|
||||
$container->get( 'api.endpoint.order' ),
|
||||
$container->get( 'api.factory.purchase-unit' ),
|
||||
$container->get( 'api.factory.shipping-preference' ),
|
||||
|
@ -86,27 +86,6 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'axo.card_icons' => static function ( ContainerInterface $container ): array {
|
||||
return array(
|
||||
array(
|
||||
'title' => 'Visa',
|
||||
'file' => 'visa-dark.svg',
|
||||
),
|
||||
array(
|
||||
'title' => 'MasterCard',
|
||||
'file' => 'mastercard-dark.svg',
|
||||
),
|
||||
array(
|
||||
'title' => 'American Express',
|
||||
'file' => 'amex.svg',
|
||||
),
|
||||
array(
|
||||
'title' => 'Discover',
|
||||
'file' => 'discover.svg',
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* The matrix which countries and currency combinations can be used for AXO.
|
||||
*/
|
||||
|
|
|
@ -119,7 +119,7 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
* @param ContainerInterface $ppcp_settings The settings.
|
||||
* @param string $wcgateway_module_url The WcGateway module URL.
|
||||
* @param OrderProcessor $order_processor The Order processor.
|
||||
* @param array $card_icons The card icons.
|
||||
* @param array $card_icons The card icons.
|
||||
* @param OrderEndpoint $order_endpoint The order endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory The purchase unit factory.
|
||||
* @param ShippingPreferenceFactory $shipping_preference_factory The shipping preference factory.
|
||||
|
@ -285,9 +285,8 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
* @return string
|
||||
*/
|
||||
public function get_icon() {
|
||||
$icon = parent::get_icon();
|
||||
$icons = $this->card_icons;
|
||||
$icons_src = esc_url( $this->wcgateway_module_url ) . 'assets/images/';
|
||||
$icon = parent::get_icon();
|
||||
$icons = $this->card_icons;
|
||||
|
||||
if ( ! $icons ) {
|
||||
return $icon;
|
||||
|
@ -298,8 +297,8 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
foreach ( $icons as $card ) {
|
||||
$images[] = '<img
|
||||
class="ppcp-card-icon"
|
||||
title="' . $card['title'] . '"
|
||||
src="' . $icons_src . $card['file'] . '"
|
||||
title="' . esc_attr( $card['title'] ) . '"
|
||||
src="' . esc_url( $card['url'] ) . '"
|
||||
> ';
|
||||
}
|
||||
|
||||
|
|
|
@ -153,6 +153,68 @@ return array(
|
|||
$logger
|
||||
);
|
||||
},
|
||||
'wcgateway.credit-card-labels' => static function ( ContainerInterface $container ) : array {
|
||||
return array(
|
||||
'visa' => _x(
|
||||
'Visa',
|
||||
'Name of credit card',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'mastercard' => _x(
|
||||
'Mastercard',
|
||||
'Name of credit card',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'amex' => _x(
|
||||
'American Express',
|
||||
'Name of credit card',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'discover' => _x(
|
||||
'Discover',
|
||||
'Name of credit card',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'jcb' => _x(
|
||||
'JCB',
|
||||
'Name of credit card',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'elo' => _x(
|
||||
'Elo',
|
||||
'Name of credit card',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'hiper' => _x(
|
||||
'Hiper',
|
||||
'Name of credit card',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
);
|
||||
},
|
||||
'wcgateway.credit-card-icons' => static function ( ContainerInterface $container ) : array {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
$icons = $settings->has( 'card_icons' ) ? (array) $settings->get( 'card_icons' ) : array();
|
||||
$labels = $container->get( 'wcgateway.credit-card-labels' );
|
||||
|
||||
$module_url = $container->get( 'wcgateway.url' );
|
||||
$url_root = esc_url( $module_url ) . 'assets/images/';
|
||||
|
||||
$icons_with_label = array();
|
||||
foreach ( $icons as $icon ) {
|
||||
$type = str_replace( '-dark', '', $icon );
|
||||
|
||||
$icons_with_label[] = array(
|
||||
'type' => $type,
|
||||
'title' => ucwords( $labels[ $type ] ?? $type ),
|
||||
'url' => "$url_root/$icon.svg",
|
||||
);
|
||||
}
|
||||
|
||||
return $icons_with_label;
|
||||
},
|
||||
'wcgateway.card-button-gateway' => static function ( ContainerInterface $container ): CardButtonGateway {
|
||||
return new CardButtonGateway(
|
||||
$container->get( 'wcgateway.settings.render' ),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue