-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASUB-8301 OrderInformation #2048
Changes from all commits
21b0374
4ed45d0
3ccb86a
94c6dbb
96e3ee1
23d653b
9188b57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import React from "react"; | ||
import PropTypes from "@arc-fusion/prop-types"; | ||
import useSales from "../useSales"; | ||
import { Grid } from "@wpmedia/arc-themes-components"; | ||
import useSales from "../useSales"; | ||
import OfferCard from "../OfferCard"; | ||
|
||
export const ARCXP_CART = 'ArcXP_cart'; | ||
export const ARCXP_CAMPAIGN = 'ArcXP_campaignName'; | ||
|
||
const OfferToProductList = ({ offer, isLoggedIn, checkoutURL, loginURL, className }) => { | ||
const { Sales } = useSales(); | ||
|
||
|
@@ -21,7 +24,7 @@ const OfferToProductList = ({ offer, isLoggedIn, checkoutURL, loginURL, classNam | |
products[productIdx].attributes.length !== 0 | ||
? products[productIdx].attributes.map((feature) => ({ | ||
featureText: feature.value, | ||
})) | ||
})) | ||
: []; | ||
const { sku } = products[productIdx]; | ||
const { priceCode } = strategies[strategiesIdx]; | ||
|
@@ -32,21 +35,26 @@ const OfferToProductList = ({ offer, isLoggedIn, checkoutURL, loginURL, classNam | |
actionText: strategies[strategiesIdx].summary, | ||
actionEvent: () => { | ||
Sales.clearCart() | ||
.then(() => | ||
.then(() => { | ||
Sales.addItemToCart([ | ||
{ | ||
sku, | ||
priceCode, | ||
quantity: 1, | ||
}, | ||
]) | ||
) | ||
]); | ||
const allValidUntil = offer?.campaigns?.map(c => c.validUntil !== undefined && !Number.isNaN(c.validUntil)); | ||
const maxEndDate = allValidUntil.length ? Math.max(allValidUntil) : null; | ||
const liveCampaing = offer?.campaigns?.find(c => c.validUntil === null || c.validUntil === maxEndDate); | ||
localStorage.setItem(ARCXP_CAMPAIGN, liveCampaing?.name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ticket says There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @edwardcho1231 yes, by default we are using rememberMe true for login or signUp, for this reason, we need to save this info on localStorage. Thus, if the user opens a new page, the info is available |
||
}) | ||
.then(() => { | ||
if (isLoggedIn) { | ||
window.location.href = checkoutURL; | ||
return; | ||
} | ||
window.location.href = `${loginURL}?redirect=${checkoutURL}`; | ||
localStorage.setItem(ARCXP_CART, JSON.stringify({sku, priceCode})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
window.location.href = `${loginURL}&redirect=${checkoutURL}`; | ||
}); | ||
}, | ||
features, | ||
|
@@ -75,7 +83,7 @@ const OfferToProductList = ({ offer, isLoggedIn, checkoutURL, loginURL, classNam | |
className={className} | ||
/> | ||
))} | ||
</Grid> | ||
</Grid> | ||
); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React from "react"; | ||
|
||
import { usePhrases, Link, Heading, Paragraph, Stack } from "@wpmedia/arc-themes-components"; | ||
import { FeatureDetails } from "../OfferCard"; | ||
import currency from "../../utils/currency"; | ||
|
||
const OrderSummary = ({ orderDetails, className }) => { | ||
const phrases = usePhrases(); | ||
|
||
return ( | ||
<Stack className={`${className}__summary`}> | ||
<Heading>{phrases.t("checkout-block.order-summary")}</Heading> | ||
<Stack className={`${className}__summary--details`}> | ||
<Stack direction="horizontal" justification="space-between" className={`${className}__summary--details--item`}> | ||
<p>{phrases.t("checkout-block.subtotal")}</p> | ||
<p>{`${currency(orderDetails?.currency)}${orderDetails?.subtotal}`}</p> | ||
</Stack> | ||
<Stack direction="horizontal" justification="space-between" className={`${className}__summary--details--item`}> | ||
<p>{phrases.t("checkout-block.salesTax")}</p> | ||
<p> | ||
{orderDetails?.tax > 0 | ||
? `${currency(orderDetails?.currency)}${orderDetails?.tax}` | ||
: "--"} | ||
</p> | ||
</Stack> | ||
</Stack> | ||
<div className={`${className}__summary--dueToday`}> | ||
<p>{phrases.t("checkout-block.due-today")}</p> | ||
<p>{`${currency(orderDetails?.currency)}${orderDetails?.total}`}</p> | ||
</div> | ||
</Stack> | ||
); | ||
}; | ||
|
||
const ProductPriceDetails = ({ | ||
details = [], | ||
showPriceDescription, | ||
showProductFeatures, | ||
className, | ||
}) => { | ||
if (details?.items?.length) { | ||
return details?.items?.map((item) => | ||
<Stack as="div" className={`${className}__orderCard--productPrice`}> | ||
<Heading> {item.priceName}</Heading> | ||
{showPriceDescription && ( | ||
<Paragraph dangerouslySetInnerHTML={{ __html: item?.priceDescription }} /> | ||
)} | ||
{showProductFeatures && ( | ||
<FeatureDetails | ||
features={item?.productAttributes} | ||
className={`${className}__orderCard`} | ||
/> | ||
)} | ||
</Stack> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
const OrderInformation = ({ | ||
id, | ||
offerURL, | ||
showOfferURL, | ||
showPriceDescription, | ||
showProductFeatures, | ||
orderDetails, | ||
className, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ticket mentions passing |
||
}) => { | ||
const phrases = usePhrases(); | ||
|
||
return ( | ||
<section key={`orderInfo${id && `-${id}`}`} className={`${className}__orderCard`}> | ||
<ProductPriceDetails | ||
details={orderDetails} | ||
showPriceDescription={showPriceDescription} | ||
showProductFeatures={showProductFeatures} | ||
className={className} | ||
/> | ||
{showOfferURL && ( | ||
<Link href={offerURL}>{phrases.t("checkout-block.view-subscription-offers")}</Link> | ||
)} | ||
<OrderSummary orderDetails={orderDetails} className={`${className}__orderCard`} /> | ||
</section> | ||
); | ||
}; | ||
|
||
export default OrderInformation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
liveCampaign