Skip to content

Commit

Permalink
remove cart block checks from the script which is never run for cart …
Browse files Browse the repository at this point in the history
…block
  • Loading branch information
timur27 committed Feb 21, 2025
1 parent 94dd750 commit 5cc6540
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
12 changes: 12 additions & 0 deletions assets/css/admin.rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
background-image: url( '../images/cards/visa.svg' );
}

.payment-method__brand--alipay {
background-image: url( '../images/payment-methods/alipay-logo.svg' );
}

.payment-method__brand--cartes_bancaires {
background-image: url( '../images/cards/cartes_bancaires.svg' );
}
Expand Down Expand Up @@ -135,6 +139,14 @@
background-image: url( '../images/payment-methods/klarna.svg' );
}

.payment-method__brand--grabpay {
background-image: url( '../images/payment-methods/grabpay.svg' );
}

.payment-method__brand--wechat_pay {
background-image: url( '../images/payment-methods/wechat-pay.svg' );
}

.wc_gateways tr[data-gateway_id='woocommerce_payments'] .payment-method__icon {
border: 1px solid #ddd;
border-radius: 2px;
Expand Down
57 changes: 28 additions & 29 deletions client/product-details/bnpl-site-messaging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ export const initializeBnplSiteMessaging = async () => {
paymentMethods,
currencyCode,
isCart,
isCartBlock,
cartTotal,
isBnplAvailable,
} = window.wcpayStripeSiteMessaging;

// if ( ! isBnplAvailable ) {
// return;
// }

let amount;
let elementLocation = 'bnplProductPage';
const paymentMessageContainer = document.getElementById(
'payment-method-message'
);

if ( isCart || isCartBlock ) {
if ( isCart ) {
amount = parseInt( cartTotal, 10 ) || 0;
elementLocation = 'bnplClassicCart';
} else {
Expand All @@ -75,37 +78,33 @@ export const initializeBnplSiteMessaging = async () => {
}
}

let paymentMessageElement;

if ( ! isCartBlock ) {
const api = new WCPayAPI(
{
publishableKey: publishableKey,
accountId: accountId,
locale: locale,
},
apiRequest
);
const api = new WCPayAPI(
{
publishableKey: publishableKey,
accountId: accountId,
locale: locale,
},
apiRequest
);

const options = {
amount: amount,
currency: currencyCode || 'USD',
paymentMethodTypes: paymentMethods || [],
countryCode: country, // Customer's country or base country of the store.
};
const options = {
amount: amount,
currency: currencyCode || 'USD',
paymentMethodTypes: paymentMethods || [],
countryCode: country, // Customer's country or base country of the store.
};

const elementsOptions = {
appearance: await initializeAppearance( api, elementLocation ),
fonts: getFontRulesFromPage(),
};
const elementsOptions = {
appearance: await initializeAppearance( api, elementLocation ),
fonts: getFontRulesFromPage(),
};

const stripe = await api.getStripe();
const stripe = await api.getStripe();

paymentMessageElement = stripe
.elements( elementsOptions )
.create( 'paymentMethodMessaging', options );
paymentMessageElement.mount( '#payment-method-message' );
}
const paymentMessageElement = stripe
.elements( elementsOptions )
.create( 'paymentMethodMessaging', options );
paymentMessageElement.mount( '#payment-method-message' );

// This function converts relative units (rem/em) to pixels based on the current font size.
function convertToPixels( value, baseFontSize ) {
Expand Down

0 comments on commit 5cc6540

Please sign in to comment.