2021-09-09 12:25:13 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { render } from '@wordpress/element';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { PaymentPromotionRow } from './payment-promotion-row';
|
|
|
|
|
|
|
|
const PAYMENT_METHOD_PROMOTIONS = [
|
|
|
|
{
|
|
|
|
gatewayId: 'pre_install_woocommerce_payments_promotion',
|
|
|
|
pluginSlug: 'woocommerce-payments',
|
2023-11-06 11:45:26 +00:00
|
|
|
url: 'https://woo.com/payments/?utm_medium=product',
|
2021-09-09 12:25:13 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
PAYMENT_METHOD_PROMOTIONS.forEach( ( paymentMethod ) => {
|
|
|
|
const container = document.querySelector(
|
|
|
|
`[data-gateway_id="${ paymentMethod.gatewayId }"]`
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( container ) {
|
2021-11-18 04:53:50 +00:00
|
|
|
const columns = [ ...container.children ].map( ( child ) => {
|
|
|
|
return {
|
|
|
|
className: child.className,
|
|
|
|
html: child.innerHTML,
|
2022-04-18 17:42:08 +00:00
|
|
|
width: child.getAttribute( 'width' ) || undefined,
|
2021-11-18 04:53:50 +00:00
|
|
|
};
|
|
|
|
} );
|
2021-09-09 12:25:13 +00:00
|
|
|
const title = container.getElementsByClassName(
|
|
|
|
'wc-payment-gateway-method-title'
|
|
|
|
);
|
|
|
|
const subTitle = container.getElementsByClassName( 'gateway-subtitle' );
|
|
|
|
|
|
|
|
render(
|
|
|
|
<PaymentPromotionRow
|
2021-11-18 04:53:50 +00:00
|
|
|
columns={ columns }
|
2021-11-30 18:02:54 +00:00
|
|
|
paymentMethod={ paymentMethod }
|
2021-09-09 12:25:13 +00:00
|
|
|
title={ title.length === 1 ? title[ 0 ].innerHTML : undefined }
|
|
|
|
subTitleContent={
|
|
|
|
subTitle.length === 1 ? subTitle[ 0 ].innerHTML : undefined
|
|
|
|
}
|
|
|
|
/>,
|
|
|
|
container
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|