Skip to content

Commit

Permalink
fix: Paynow in blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Gomis committed Jan 9, 2025
1 parent 7553243 commit 27641bc
Show file tree
Hide file tree
Showing 12 changed files with 47,884 additions and 41 deletions.
3 changes: 3 additions & 0 deletions src/assets/js/alma-checkout-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ import '../css/alma-checkout-blocks.css';
const setInPage = (inPageInstance) => {
inPage = inPageInstance
}
const isPayNow = (settings.gateway_name === "alma_pay_now" || settings.gateway_name === "alma_in_page_pay_now");

return is_in_page ? (
<DisplayAlmaInPageBlocks
isPayNow={isPayNow}
store_key={store_key}
settings={settings}
cartTotal={cartTotal}
Expand All @@ -86,6 +88,7 @@ import '../css/alma-checkout-blocks.css';
/>
) : (
<DisplayAlmaBlocks
isPayNow={isPayNow}
store_key={store_key}
settings={settings}
cartTotal={cartTotal}
Expand Down
3 changes: 2 additions & 1 deletion src/assets/js/components/DisplayAlmaBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useEffect, useState} from '@wordpress/element';
import {AlmaBlocks} from "./alma-blocks-component.tsx";

export const DisplayAlmaBlocks = (props) => {
const {eventRegistration, emitResponse, settings, gateway, store_key} = props;
const {eventRegistration, emitResponse, settings, gateway, store_key, isPayNow} = props;
const {onPaymentSetup} = eventRegistration;

const {CART_STORE_KEY} = window.wc.wcBlocksData
Expand Down Expand Up @@ -62,6 +62,7 @@ export const DisplayAlmaBlocks = (props) => {

return isLoading ? <div></div> : <AlmaBlocks
hasInPage={settings.is_in_page}
isPayNow={isPayNow}
totalPrice={cartTotal.total_price}
settings={settings}
selectedFeePlan={plan.planKey}
Expand Down
7 changes: 4 additions & 3 deletions src/assets/js/components/DisplayAlmaInPageBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useEffect, useState} from '@wordpress/element';
import {AlmaBlocks} from "./alma-blocks-component.tsx";

export const DisplayAlmaInPageBlocks = (props) => {
const {settings, gateway, store_key, setInPage} = props;
const {settings, gateway, store_key, setInPage, isPayNow} = props;

const {CART_STORE_KEY} = window.wc.wcBlocksData
const {cartTotal} = useSelect((select) => ({
Expand Down Expand Up @@ -63,16 +63,17 @@ export const DisplayAlmaInPageBlocks = (props) => {
}
}, [selectedFeePlan, cartTotal, isLoading])


const displayInstallments = isPayNow ? 'none' : 'block';
return isLoading ? <div></div> : <><AlmaBlocks
hasInPage={settings.is_in_page}
isPayNow={isPayNow}
totalPrice={cartTotal.total_price}
settings={settings}
selectedFeePlan={plan.planKey}
setSelectedFeePlan={setSelectedFeePlan}
plans={eligibility[gateway]}
/>
<div id="alma-inpage-alma_in_page"></div>
<div id="alma-inpage-alma_in_page" style={{display: displayInstallments}}></div>
</>

}
4 changes: 2 additions & 2 deletions src/assets/js/components/alma-blocks-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type AlmaBlocksProps = {
selectedFeePlan: string;
setSelectedFeePlan: (value: string) => void;
hasInPage: boolean;
isPayNow: boolean;
totalPrice: number
};

Expand All @@ -63,6 +64,7 @@ export const AlmaBlocks: React.FC<AlmaBlocksProps> = (
selectedFeePlan,
setSelectedFeePlan,
hasInPage,
isPayNow,
totalPrice,
plans
}
Expand All @@ -89,8 +91,6 @@ export const AlmaBlocks: React.FC<AlmaBlocksProps> = (
setSelectedFeePlan(optionKey);
};

const isPayNow = settings.gateway_name === "alma_pay_now";

const label = (
<div className="toggleButtonFieldLabel">{settings.description}</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/build/alma-checkout-blocks.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-data', 'wp-element'), 'version' => '13b1b261f42717270b07');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-data', 'wp-element'), 'version' => '47624a2f8e34398a65fb');
283 changes: 279 additions & 4 deletions src/build/alma-checkout-blocks.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47,381 changes: 47,357 additions & 24 deletions src/build/alma-checkout-blocks.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/build/alma-store.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-data'), 'version' => '31f9d6e589628f51f977');
<?php return array('dependencies' => array('wp-data'), 'version' => '796406d9d07b12bc8f48');
Loading

0 comments on commit 27641bc

Please sign in to comment.