Added Icons to WC plugin checkout page

This commit is contained in:
2025-10-25 13:19:29 +02:00
parent 462cb0127a
commit fea84cc50e
8 changed files with 166 additions and 0 deletions

View File

@@ -135,6 +135,8 @@ class WC_Aluxpay_Payment_Gateway extends WC_Payment_Gateway {
add_action('woocommerce_api_' . $this->id, array($this, 'webhook_handler'));
add_action('woocommerce_thankyou_' . $this->id, array($this, 'thankyou_page'));
add_action('wp_enqueue_scripts', array($this, 'enqueue_checkout_styles'));
// Customer Emails - Success
add_action('woocommerce_email_before_order_table', array($this, 'email_instructions'), 10, 3);
@@ -142,6 +144,62 @@ class WC_Aluxpay_Payment_Gateway extends WC_Payment_Gateway {
add_action('woocommerce_email_before_order_table', array($this, 'failed_email_instructions'), 10, 3);
}
// SVG icons on checkout
public function get_icon() {
$icons = array(
'discover' => array(
'file' => 'discover.svg',
'alt' => 'Discover'
),
'amex' => array(
'file' => 'american-express.svg',
'alt' => 'American Express'
),
'visa' => array(
'file' => 'visa.svg',
'alt' => 'Visa'
),
'mastercard' => array(
'file' => 'mastercard-alt.svg',
'alt' => 'Mastercard'
),
'paypal' => array(
'file' => 'paypal.svg',
'alt' => 'PayPal'
),
);
$icons_html = '<span class="aluxpay-payment-icons">';
foreach ($icons as $key => $icon) {
// Use the constant defined in main plugin file
$icon_url = ALUXPAY_PLUGIN_URL . 'assets/images/' . $icon['file'];
$icons_html .= sprintf(
'<img src="%s" alt="%s" class="aluxpay-icon aluxpay-icon-%s" />',
esc_url($icon_url),
esc_attr($icon['alt']),
esc_attr($key)
);
}
$icons_html .= '</span>';
return $icons_html;
}
/**
* Enqueue checkout styles
*/
public function enqueue_checkout_styles() {
if (is_checkout()) {
wp_enqueue_style(
'aluxpay-checkout',
ALUXPAY_PLUGIN_URL . 'assets/css/checkout.css',
array(),
'1.0.1'
);
}
}
/**
* Initialize Gateway Settings Form Fields