Skip to content

Commit

Permalink
Show paylater amount in editor if cart/checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexP11223 committed Dec 14, 2023
1 parent c8632e3 commit 90d8fcc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/ppcp-paylater-block/resources/js/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export default function Edit( { attributes, clientId, setAttributes } ) {

const [rendered, setRendered] = useState(false);

let amount = undefined;
const postContent = String(wp.data.select('core/editor')?.getEditedPostContent());
if (postContent.includes('woocommerce/checkout') || postContent.includes('woocommerce/cart')) {
amount = 50.0;
}

const previewStyle = {
layout,
logo: {
Expand Down Expand Up @@ -152,6 +158,7 @@ export default function Edit( { attributes, clientId, setAttributes } ) {
<div className={'ppcp-overlay-child'}>
<PayPalMessages
style={previewStyle}
amount={amount}
onRender={() => setRendered(true)}
/>
</div>
Expand Down

0 comments on commit 90d8fcc

Please sign in to comment.