Skip to content

Commit

Permalink
update: show LPM icon on order success page
Browse files Browse the repository at this point in the history
  • Loading branch information
frosso committed Nov 7, 2024
1 parent ed04c34 commit 8b9fc81
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions assets/css/success.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
align-items: center;
flex-wrap: wrap;
line-height: 1;
padding-top: 4px;
}

.wc-payment-gateway-method-logo-wrapper img {
margin-right: 0.5rem;
padding-top: 4px;
}

.wc-payment-gateway-method-logo-wrapper.wc-payment-bnpl-logo img {
max-height: 30px;
.wc-payment-gateway-method-logo-wrapper.wc-payment-lpm-logo img {
max-height: 26px;
}
6 changes: 3 additions & 3 deletions assets/css/success.rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
align-items: center;
flex-wrap: wrap;
line-height: 1;
padding-top: 4px;
}

.wc-payment-gateway-method-logo-wrapper img {
margin-left: 0.5rem;
padding-top: 4px;
}

.wc-payment-gateway-method-logo-wrapper.wc-payment-bnpl-logo img {
max-height: 30px;
.wc-payment-gateway-method-logo-wrapper.wc-payment-lpm-logo img {
max-height: 26px;
}
4 changes: 4 additions & 0 deletions changelog/update-order-success-lpm-icon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: update

update: show LPM payment method icon on order success page
21 changes: 12 additions & 9 deletions includes/class-wc-payments-order-success-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WooCommerce\Payments
*/

use WCPay\Constants\Payment_Method;
use WCPay\Duplicate_Payment_Prevention_Service;

/**
Expand Down Expand Up @@ -78,14 +79,16 @@ public function show_woocommerce_payments_payment_method_name( $payment_method_t
}

$payment_method = $gateway->get_payment_method( $order );
// GooglePay/ApplePay/Link/Card to be supported later.
if ( $payment_method->get_id() === Payment_Method::CARD ) {
return $payment_method_title;
}

// If this is a BNPL order, return the html for the BNPL payment method name.
if ( $payment_method->is_bnpl() ) {
$bnpl_output = $this->show_bnpl_payment_method_name( $gateway, $payment_method );
// If this is an LPM (BNPL or local payment method) order, return the html for the payment method name.
$name_output = $this->show_lpm_payment_method_name( $gateway, $payment_method );

if ( false !== $bnpl_output ) {
return $bnpl_output;
}
if ( false !== $name_output ) {
return $name_output;
}

return $payment_method_title;
Expand Down Expand Up @@ -116,14 +119,14 @@ public function show_woopay_payment_method_name( $order ) {
}

/**
* Add the BNPL logo to the payment method name on the order received page.
* Add the LPM logo to the payment method name on the order received page.
*
* @param WC_Payment_Gateway_WCPay $gateway the gateway being shown.
* @param WCPay\Payment_Methods\UPE_Payment_Method $payment_method the payment method being shown.
*
* @return string|false
*/
public function show_bnpl_payment_method_name( $gateway, $payment_method ) {
public function show_lpm_payment_method_name( $gateway, $payment_method ) {
$method_logo_url = apply_filters(
'wc_payments_thank_you_page_bnpl_payment_method_logo_url',
$payment_method->get_payment_method_icon_for_location( 'checkout', false, $gateway->get_account_country() ),
Expand All @@ -137,7 +140,7 @@ public function show_bnpl_payment_method_name( $gateway, $payment_method ) {

ob_start();
?>
<div class="wc-payment-gateway-method-logo-wrapper wc-payment-bnpl-logo <?php echo esc_attr( $payment_method->get_id() ); ?>">
<div class="wc-payment-gateway-method-logo-wrapper wc-payment-lpm-logo wc-payment-lpm-logo--<?php echo esc_attr( $payment_method->get_id() ); ?>">
<img alt="<?php echo esc_attr( $payment_method->get_title() ); ?>" src="<?php echo esc_url_raw( $method_logo_url ); ?>">
</div>
<?php
Expand Down

0 comments on commit 8b9fc81

Please sign in to comment.